Typescript: When using a subfolder in a project, parent node_modules to tsconfig.json get checked

Created on 3 Jul 2017  路  1Comment  路  Source: microsoft/TypeScript

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.

Working as Intended

Most helpful comment

This is the intended behavior. Please refer to http://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types for information on how to control this behavior in your _tsconfig.json_ file.

>All comments

This is the intended behavior. Please refer to http://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types for information on how to control this behavior in your _tsconfig.json_ file.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dlaberge picture dlaberge  路  3Comments

Roam-Cooper picture Roam-Cooper  路  3Comments

Zlatkovsky picture Zlatkovsky  路  3Comments

uber5001 picture uber5001  路  3Comments

blendsdk picture blendsdk  路  3Comments