Skip to content

composite typescript project types should not leak into excluded files #282842

@valler

Description

@valler

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: any
  • OS Version: any

Steps to Reproduce:

Create a root tsconfig that references two other configs with inclusion patterns that don't overlap in applicability, and two corresponding TypeScript files. The configs use type fields, to exclude/include certain types, where the root config explicitly uses no additional types. Some of the types are assumed to be installed as dev dependencies.

  1. Relevant files and content:
// tsconfig.json
{
  "compilerOptions": {
    "types": []
  },
  "files": [],
  "include": [],
  "references": [
    {
      "path": "tsconfig.alice.json"
    },
    {
      "path": "tsconfig.bob.json"
    },
  ]
}
// tsconfig.alice.json
{
  "compilerOptions": {
    "composite": true,
    "types": [
      "node"
    ]
  },
  "include": [
    "*.alice.ts"
  ]
}
// tsconfig.bob.json
{
  "compilerOptions": {
    "composite": true,
    "types": [
      "@webgpu/types"
    ]
  },
  "include": [
    "*.bob.ts"
  ]
}
{
  "// package.json": "",
  "devDependencies":
  {
    "@types/node": "*",
    "@webgpu/types": "*",
  }
}
// module.alice.ts
import "node:fs"; // should be ok.
export const gpu = navigator.gpu; // should be marked as an error, but it's not.
// module.bob.ts
import "node:fs"; // should be marked as an error, but it's not.
export const gpu = navigator.gpu; // should be ok.
  1. VSC shows no errors and has type information from ambient types.

  2. tsc --build --noEmit reports errors as expected: alice does not have WebGPU types and bob does not have Node.js types.

Which approach should be taken to let the IDE align with the type checker? Enforcing structural patterns due to IDE limitations is not a solution. This is clearly a bug.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions