-
Notifications
You must be signed in to change notification settings - Fork 12.8k
typeRoots and types not working #37708
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
…ectory Fixes #37708 Bug 2 part of the issue
Fixes #37708 Bug 1 part of the issue
This will probably be breaking change and will be part of broader work to improve type reference directive resolution |
I have
https://www.typescriptlang.org/tsconfig#typeRoots I assume this is the same issue? |
I'm working on a web app and have @types/node installed from a transient dependency. I have types set to an empty array in compiler options and it still uses the node types. |
I'm also experiencing the same problem. |
same problem with @types/node, I can use process.env in a client app |
…ectory when its not default typeRoots Fixes #37708 Bug 2 part of the issue
Fixes #37708 Bug 1 part of the issue
…ectory when its not default typeRoots Fixes #37708 Bug 2 part of the issue
Fixes #37708 Bug 1 part of the issue
TypeScript Version: 3.8.3
Code
This is my
tsconfig.json
In my project root, I got
package.json, package-lock.json, main.ts(empty one), tsconfig.json
.tsconfig.json
contains the above code.typings
folder which I wrote intypeRoots
is empty.After that, I run the following command in terminal:
tsc --traceResolution
The idea is I am trying to use
Phaser
as a global variable in mymain.ts
file.Bug 1)
Expected behavior:
What should happen is
Phaser
shouldn't get resolved because compiler should start looking into my custom foldertypings
.Actual behavior:
Somehow it still gets resolved. And this is what it prints:
Type reference directive 'Phaser' was successfully resolved to '/Applications/XAMPP/xamppfiles/htdocs/phaser-test/node_modules/Phaser/types/phaser.d.ts' with Pac kage ID 'phaser/types/[email protected]', primary: false.
.I don't know how it finds it since in my
typeRoots
, I don't havenode_modules
specified.What I have tried:
I tried to exclude
node_modules
folder, I thought maybe they still get compiled and that's why this happens, but I couldn't makeexclude
work."exclude": ["node_modules/*"]
"exclude": ["./node_modules/*"]
"exclude": ["./node_modules"]
but none of these worked. , but i don't think that will help because i created one file
test.ts
and put something like this in there, but compilation is successful, So I guess the bug is related totypeRoots
.Bug 2)
Let's change the above
tsconfig.json
to the following:What should happen now is
Phaser
should be resolved from./node_modules/phaser/types
and not take care of anything else such as trying to findpackage.json
innode_modules/phaser
and looking attypes
property in thatpackage.json
. But what actually happens is this doesn't get resolved at all onUbuntu
versions, since ubuntu is 'case-sensitive. This config works fine on
OS x and windowsbecause
Phasergets resolved from
node_modules/phaser/package.json's types propertywhich shouldn't be happening because of my
typeRoots`.Basically both things are so much related to each other.
The text was updated successfully, but these errors were encountered: