TypeScript-Sublime-Plugin: tsconfig's compilerOptions' paths setting ignored
TypeScript allows to modify module resolution using the paths
configuration option on the compilerOptions
object. The mechanics of this are described in https://www.typescriptlang.org/docs/handbook/module-resolution.html. This feature is necessary for avoiding the relative path hell by aliasing the root of the current project, and importing files relative to that root.
Currently imports that contain an alias from the paths
configuration are reported with the “Cannot find module” error, even though tsc resolves them correctly.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 17
- Comments: 16 (1 by maintainers)
+1 for this issue.
Has anyone ever gotten this to work? I define paths and if I use them e.g. in triple slash directives and hover over them, however, I get: Cannot find type definition file for ‘@yadayada/test’. So it seems the @yadayada is not even resolved in the first place…?
I had a similar problem where in tsconfig.json:
…would let me import from the “utils/index.ts” file, but it would give me an error in Sublime when importing modules in subfolders:
Funny thing is that the compiler wouldn’t complain, only Sublime would have problems finding it. However, adding a second alias in tsconfig.json would let me find modules both from
"~Utils"
and"~Utils/subfolder"
now they both work
(using Sublime TypeScript plugin 3.7.3)
I am facing this issue as well
I have these configs in the
tsconfig
file:Compiling tsc works just fine.
I’m also experiencing this issue. I’m using Sublime Text 4 (build 4113) with the TypeScript plugin v4.3.2.
In my tsconfig.json:
In one of my TypeScript files:
Compiling this works absolutely fine, but within Sublime the
'@cipscis/csv'
string has a red underline, and hovering over it the error message is:The workarounds suggested in other comments in this thread haven’t helped me. I’m setting up my aliases this way so I can work with a Node.js package using Webpack using the same syntax as if it had been installed via npm.