Adding ".ts" suffix during refactoring to import statements in TypeScript files

PHPStorm 2016.1

I have an Angular2 TypeScript app. This app has folder structure:

app/
---- firstComponent/
--------- firstComponent.comp.ts
--------- firstComponent.comp.js
--------- firstComponent.comp.map
---- secondComponent/
--------- secondComponent.comp.ts
--------- secondComponent.comp.js
--------- secondComponent.comp.map
---- thirdComponent/
-- empty--

The .js and .map files are the result of the TypeScript compiler in PHPStorm. So I edit only .ts files.

In my app, the first component imports a class from the second component. So, file firstComponent.comp.ts contains this line:
import {SecondComponentClass} from './../secondComponent/secondComponent.comp'

Notice that the file name in import statement must be 'secondComponent.comp' and not 'secondComponent.comp.ts'.

What happens if I move all files from secondComponent directory to thirdComponent directory? PHPStorm automatically updates references (good) but it adds .ts suffix to the import line (bad). The line becomes:
import {SecondComponentClass} from './../thirdComponent/secondComponent.comp.ts'

So I have to manually delete the .ts suffix from all import statements in all files that import this secondComponent. And in real app there are many such files.

So in this case I search globally for files containing string "*.comp.ts" and "*.service.ts" and possibly other types of files in the future and do edit/replace in those files.

I think it's either a bug, or maybe there is an option which I am not aware of, to configure PHPStorm to not add the .ts suffix to import statements during refactoring.



Please sign in to leave a comment.