Skip to content

The existence of /// reference directives in dependencies breaks explicit typeRoots orderingΒ #62849

@a-non-a-mouse

Description

@a-non-a-mouse

πŸ”Ž Search Terms

typeroots triple slash directives ordering

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about reference directives

⏯ Playground Link

No response

πŸ’» Code

We are explicitly including our own types in typeRoots before node_modules/@types:

{
  "compilerOptions": {
    "typeRoots": ["src/types", "node_modules/@types"]

because we're making some custom changes to js/node types. This has been working great until we recently tried to switch to vitest which includes vite which has:

/// <reference types="node" />

in a file, which breaks some of our types as we have conflicting interfaces with @types/node

πŸ™ Actual behavior

vitest β‡’ vite β‡’ node types is discovered before typeRoots is processed, meaning typeRoots ordering is effectively useless as any dependency can just force type injections before they're processed.

πŸ™‚ Expected behavior

typeRoots ordering should apply first, THEN types from dependencies

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs More InfoThe issue still hasn't been fully clarified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions