Search code examples
phpstormconfigfile-type

How to change file type of a file in PhpStorm?


I have a TypeScript project I manage with PhpStorm. All the *.ts files are properly recognized as TypeScript files and in my file types setting I have the *.ts file map TypeScript.

All the files? No, one file stubbornly won't be treated as a TypeScript file but is shown as plain text. I have no idea how to mark this one as a TypeScript file.

All the *.ts file have the proper ts icon next to them. This one hasn't.

When I open the rogue .ts file, PhpStorm tells me that there are plugins for that file type, yet if I try to follow that route, all it leads me to is for PhpStorm to try to install the TypoScript plugin for which I have no need at all.

I tried:

  • renaming file from *.ts to *.txt and back to *.ts;
  • deleting it within PhpStorm and checking it out via git again;
  • right clicking the file in the Project pane hoping a setting is there in order to mark it as a TypeScript file, yet no such things seems to exist;
  • invalidating the cache and restart.

It remains a simple text file without syntax highlighting and other TypeScript code importing this file have the error that the references cannot be found within PhpStorm.

It's a valid TypeScript project though, tsc on command line runs fine.

How can I tell PhpStorm to treat this rogue .ts file as a TypeScript file as well?


Solution

  • Go to Preferences > File Types > Text Files and see if the name of the file is listed there. If it is, delete it from that list.