How to handle a project with multiple tsconfig.json files?

后端 未结 2 1425
粉色の甜心
粉色の甜心 2020-12-20 21:45

I\'m working on a project structured like this:

\\
|- built
|- src
|- perf
   |- tsconfig.json
|- typings
|- tsconfig.json

My tsconfi

相关标签:
2条回答
  • 2020-12-20 22:29

    Is there a way to tell TypeScript where to look for typings

    Quickest solution

    Move typings into pref.

    Long term solution

    Use filesGlob once it is supported in tsc : https://github.com/Microsoft/TypeScript/issues/1927

    0 讨论(0)
  • 2020-12-20 22:34

    you can do this by extending your base tsconfig.json file:

    tsconfig extension

    just do not exclude directories in the base tsconfig.json and typescript should be able to resolve your typings for you (know this is true using node_modules/@types, or the typings module)

    For example:

    configs/base.json:

    {
      "compilerOptions": {
        "noImplicitAny": true,
        "strictNullChecks": true
      }
    }
    

    tsconfig.json:

    {
      "extends": "./configs/base",
      "files": [
        "main.ts",
        "supplemental.ts"
      ]
    }
    

    tsconfig.nostrictnull.json:

    {
       "extends": "./tsconfig",
       "compilerOptions": {
         "strictNullChecks": false
       }
    }
    
    0 讨论(0)
提交回复
热议问题