Repository navigation
Folders from typesRoot should be used in looking up for types for imports as well as @types folder #37958
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 17, 2020 sheetalkamat commented
on Jul 22, 2020 MemberMore actionsThis will be breaking change..
timocov commented
on Jul 23, 2020 ContributorAuthorMore actionsThis will be breaking change..
Yeah, but I think it should be more intuitive behavior rather than the current one, because it looks like a bit inconsistent right now how typesRoot, referenece types and resolving modules in types folders works though.
- addedRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
on Dec 11, 2020 3 remaining items
- addedFix AvailableA PR has been opened for this issueA PR has been opened for this issue
on Dec 2, 2022 - linked a pull request that will close this issueUpdates to type reference directive resolution and module resolution when failed #51715
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
Search Terms
typesRoot, Types (@types)
Suggestion
typesRootis folders you can specify where the compiler will looking up for types for modules without own types. But it looks like (according output with--traceResolution) it is used for/// <reference typesdirective, and isn't used to looking up modules when you import something. I think it'd be better to use it there as well.Use Cases
For instance, you might have custom types folder with types for some packages (possible some packages has wrong declarations or even don't have them yet).
Examples
In the case above you can specify
typesRootto something like["./custom-types","node_modules/@types"]and expect that the compiler will try to load types fromcustom-typesfolder if no typings exists innode_modules/@types.Yeah, you can specify
typesoption as well to load that type globally, but I'm not sure that loading every type globally is good idea.As workaround right now you can "load" the types file with
/// <reference types="type-name" />and then import declared there modules (viadeclare module).I'm not sure whether it's intended behaviour or not, but maybe we need to put some lights to the docs if so.
Checklist
My suggestion meets these guidelines: