Skip to content

When using a subfolder in a project, parent node_modules to tsconfig.json get checked #16911

@vinz243

Description

@vinz243

TypeScript Version: 2.4.1

Code

{
  "compilerOptions": {
    "sourceMap": false,
    "outDir": "./dist/",
    "noImplicitAny": true,
    "module": "commonjs",
    "target": "es6",
    "declaration": true,
    "lib": ["es2016", "es7"]
  },
  "include": [
    "./src/**/*"
  ]
}
+-- project
    +-- node_modules
    |   + @types
    |   |   + react
    |   |   + react-router
    |   |   + ...
    |   + ...
    |
    +-- frontend
    |   + MyReactApp.tsx
    |   + tsconfig.json
    |   + ...
    |
    +-- subproject
        + ReactThingy.ts
        + tsconfig.json
        + ...

Expected behavior:

My TS files should work fine

Actual behavior:

Instead, typescript, will look for definitions in node_modules in parent folders, so it will try to compile using @types/react-router and so. Thus, failing to compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions