简体   繁体   中英

WebStorm/IntelliJ does not associate TypeScript file type

I cannot get IntelliJ/WebStorm to associate a ".ts" file as TypeScript file.

I have created a file named confirmationRequiredRenderer . Initially I created this file by just creating a text file and then adding a .ts at the end of the file name.

在此处输入图像描述

Now, no matter what I do, I cannot associated this file as a TypeScript file type. It thinks it is a text file.

These are the actions I have gone through to fix this problem and nothing has worked:

  • rebuild project
  • restart IDE
  • Invalidate caches
  • creating a TS file through the wizard, and then renaming it
  • npm build

Any advice on why my IDE is so confused with this file?

I have created a file named confirmationRequiredRenderer . Initially I created this file by just creating a text file and then adding a .ts at the end of the file name.

That is the source of the problem: the confirmationRequiredRenderer file name is now associated with the Text file type. And it has a "priority" because it's longer/more specific than just default *.ts .

You need to go into the IDE Settings/Preferences and remove such a association for more broad *.ts to be used instead.

  1. Go to Settings/Preferences | Editor | File Types Settings/Preferences | Editor | File Types
  2. Locate Text file type there
  3. Locate and remove the offending entry -- should be confirmationRequiredRenderer or very similar to that.
  4. Save the settings, let IDE reindex that file and see how it goes.

If still nothing (pretty unlikely but still possible): it may still have an association in another file type, so may need to check other files types for the same.

在此处输入图像描述


PS Another alternative is to hard-override the file type for that specific file . Just right click on the file in the Project View panel and choose the right action ( Override File Type ).

It will work for that specific file but will still be an issue for the file with the same name in another project/another folder. So it's much better to fix the original source of the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM