-
Notifications
You must be signed in to change notification settings - Fork 12.8k
tsc will attempt to compile source files in 'node_modules' when it shouldn't #12320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
@vladima OK, right - so is there a way to make tsc prefer the @types declaration instead of the included declarations? Or am I simply unable to use this package until it gets fixed by the package developers? If I'm understanding this right, it feels like a major problem for package compatibility. If I have my tsc set up to have a stricter/different configuration than the developer of a package, or if a package doesn't get updated for a while and tsc has breaking changes, so long as the package 'helpfully' includes .d.ts files, I'm stuck? |
The core of the issue here is that the aws-sdk package has an inviald declaration file. i owuld log a bug on thier repo first. To override the typings I would use path mapping : {
"compilerOptions": {
"baseUrl" : "./",
"paths": {
"*" : ["./node_modules/@types/*", "*"]
}
}
} More info can be found about the original question at https://github.com/Microsoft/TypeScript/wiki/FAQ#why-is-a-file-in-the-exclude-list-still-picked-up-by-the-compiler |
@mhegazy Thank you! |
Add a path mapping in your tsconfig.json to map |
TypeScript Version: 2.0.8
It appears that tsc will attempt to compile source files in
node_modules
that are part of modules being imported, even whennode_modules
is excluded and type definition files are present. It is my understanding that this is not intended behaviour.In researching this issue, I came across #6964 which looks like it should have fixed the exact bug I am still encountering.
The reproduction is very simple - just try to import a package that contains broken ts code (In this case, the guilty party is aws-sdk):
in
package.json
:tsconfig.json
(this is just the default tsconfig):and finally, the entry point,
index.ts
:When compiling, tsc will throw errors as if it is compiling the AWS project itself.
The text was updated successfully, but these errors were encountered: