Skip to content

"My Types Are Missing" when "types" and "typeRoots" are both provided. #1132

@pelepelin

Description

@pelepelin

Expected Behavior

Same as tsc or documented in "My Types Are Missing"
According to https://www.typescriptlang.org/tsconfig#types :

This option does not affect how @types/* are included in your application code

Actual Behavior

When both types and typeRoots are specified, tsc resolves imported types from typeRoots, but ts-node does not. It is not documented.
ts-node --files src/index.ts resolves the types, but it's not clear why, as neither include nor files are used.
Without types ts-node src/index.ts resolves types in typeRoots as well as tsc does.

Steps to reproduce the problem

Run ts-node src/index.ts in the reproduction below

Minimal reproduction

TypeStrong/ts-node-repros#6

Specifications

  • ts-node version: 9.0.0
  • node version: 12.14.0
  • TypeScript version: 4.0.3
  • tsconfig.json, if you're using one:
{
  "compilerOptions": {
    "strict": true,
    "esModuleInterop": true,
    "outDir": "dist",
    "types": ["node"],
    "typeRoots": ["node_modules/@types", "src/typings"]
  }
}
  • Operating system and version: Ubuntu 18.04.5 LTS

Metadata

Metadata

Assignees

No one assigned

    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