Repository navigation
typeRoots and types not working #37708
Copy link
Copy link
Closed
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
Description
Activity
- addedNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.
on Apr 3, 2020 - added 2 commits that reference this issue
on Jul 22, 2020 sheetalkamat commented
on Jul 22, 2020 MemberMore actionsThis will probably be breaking change and will be part of broader work to improve type reference directive resolution
- addedRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
on Dec 11, 2020 11 remaining items
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 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.
Reacted by uallmight, wn90674, Roberto Molina, Wessel Kronemeijer and Mediansame problem with @types/node, I can use process.env in a client app
- added 4 commits that reference this issue
on Dec 1, 2022 - addedFix AvailableA PR has been opened for this issueA PR has been opened for this issue
on Dec 2, 2022
Metadata
Metadata
Assignees
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
TypeScript Version: 3.8.3
Code
This is my
tsconfig.json{ "compilerOptions": { "typeRoots": [ "./typings" ], "types": ["Phaser"] } }In my project root, I got
package.json, package-lock.json, main.ts(empty one), tsconfig.json.tsconfig.jsoncontains the above code.typingsfolder which I wrote intypeRootsis empty.After that, I run the following command in terminal:
tsc --traceResolutionThe idea is I am trying to use
Phaseras a global variable in mymain.tsfile.Bug 1)
Expected behavior:
What should happen is
Phasershouldn'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_modulesspecified.What I have tried:
I tried to exclude
node_modulesfolder, I thought maybe they still get compiled and that's why this happens, but I couldn't makeexcludework."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.tsand 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.jsonto the following:What should happen now is
Phasershould be resolved from./node_modules/phaser/typesand not take care of anything else such as trying to findpackage.jsoninnode_modules/phaserand looking attypesproperty in thatpackage.json. But what actually happens is this doesn't get resolved at all onUbuntuversions, since ubuntu is 'case-sensitive. This config works fine onOS x and windowsbecausePhasergets resolved fromnode_modules/phaser/package.json's types propertywhich shouldn't be happening because of mytypeRoots`.Basically both things are so much related to each other.