ilearnio / module-alias

Register aliases of directories and custom module paths in Node
MIT License
1.76k stars 69 forks source link

IDE throws TS2415 while the compiler works #130

Closed SDries closed 2 years ago

SDries commented 2 years ago

Hello,

I'm using the module for an angular application. My case is as follows: I have an angular project that uses an angular library. During development I use npm link to be able to make & view changes in my application without having to publish every change to npm. I use the module so that I can alias some dependencies within my project that are otherwise used from within my library. The tsc compilation would throw errors such as this: TS2345: Argument of type 'import(".../node_modules/@angular/common/http/index").HttpClient' is not assignable to parameter of type 'import(".../node_modules/@angular/common/http/index").HttpClient'.

Now that I'm using the module by adding this to my package.json the code compiles just fine which is wonderful

"_moduleAliases": {
  "@angular/common/http": "./node_modules/@angular/common/http"
},

The issue that I'm now facing is that the linting in my IDE (both webstorm & VS Code do this) still gives me the same error. (ng lint gives no errors)

TS2415: Class 'X' incorrectly extends base class 'Y'.   Types of property 'http' are incompatible.

Does anyone know how I can tell my IDE that the module has been aliased? I already tried adding a webpack.config.js file as was suggested here: https://github.com/ilearnio/module-alias/issues/105

Thank you

SDries commented 2 years ago

I ended up removing the module & using the tsconfig paths: https://www.typescriptlang.org/tsconfig#paths