TypeScript tsconfig.json path-mapping not being used
See original GitHub issueContext: https://stackoverflow.com/questions/37372816/what-does-symbol-mean-in-import-component-from-angular-core-statem https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
Our app has imports like: import { Foo } from "@services/foo";
with the following in tsconfig.json
:
{
"compilerOptions": {
"baseUrl": ".", // This must be specified if "paths" is.
"paths": {
"@service": ["src/app/services/*"] // This mapping is relative to "baseUrl"
}
}
}
Then depcheck outputs:
Missing dependencies
* @services/foo: ./src/bar.ts
Expected behavior: depcheck should find and read paths in tsconfig files.
PS: Not sure, but maybe https://github.com/depcheck/depcheck/issues/544 is related.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:19 (5 by maintainers)
Top Results From Across the Web
Why are these tsconfig paths not working? - Stack Overflow
In case anyone is using VSCode and having trouble getting the /* solution to work. Try Cmd+Shift+P > Typescript: Restart TS Server. –...
Read more >Tsconfig.json is not being used on 0.78.1 - support - HUGO
I'm using for my website a module written with Typescript. It has a tsconfig.json that contains a path mapping configuration:
Read more >Documentation - Module Resolution - TypeScript
The TypeScript compiler supports the declaration of such mappings using paths property in tsconfig. json files. Here is an example for how to...
Read more >Paths mapping | ts-jest - GitHub Pages
If you use "baseUrl" and "paths" options in your tsconfig file, ... option in your Jest config is setup accordingly. ... tsconfig.json
Read more >tsconfig.json path mapping not working in Nuxt.js project
json file with the following path mappings. Unfortunately, the editor is flagging any import that uses these paths in our vue and js...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
They shouldn’t be 😃
Here’s my take on why I don’t want to implement this in depcheck.
I am not a fan of it. That’s just an opinion granted, but I would like to think my opinion is important for my project.
Path aliases add an unnecessary indirection, I have worked on multiple project that use them and, as a new developer to the project, I found it very hard to know just from looking at the code if an import is a local one or one from a dependency. It’s also hard, for someone new, to know and remember all the path aliases. The tooling around is pretty much non-existent so my IDE is always complaining about unknown dependencies.
I you look at the examples in the typescript documentation you can see that they talk about
paths
as a tool for some exceptional setups (modules not underbaseUrl
, generated code, etc). The--ignores
flag exists exactly for these exceptional cases. The problem here is that, instead of using lerna/webpack workspaces you use aliases.I’m torn, really torn, you’ll open the PR and then I’m left maintaining something I don’t want to maintain and don’t like… So no.