简体   繁体   中英

Can I put tsconfig file in one project and use it in another?

I have submodule in my solution projects. Both of them(1st 2nd projects) have .ts files, so I want to put tsconfig.json in submodule and share it for both of them.

In file system they are located like this:

~/solution
--project1
  --Scripts
    --(ts files)
--submodule
  --tsconfig.json(I want to put it here)

~/solution
--project2
  --Scripts
    --(ts files)
--submodule

project1's name is equal with project2's name

I have tried to add rootDir to compilerOptions

   "rootDir": "..\\project1\\Scripts\\**\\*"

I tried to add

  "include": [
    "..\\project1\\Scripts\\**\\*"
  ]

None of them work for me.

here is my tsconfig.json

{
  "compileOnSave": true,
  "buildOnSave": true,
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": true,
    "sourceMap": false,
    "target": "es5",
    "module": "none",
    "types": [],
    "emitBOM": false,
    "charset": "utf8"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

If you want to share a tsconfig between two projects, you can extend a tsconfig.json file. For example you have a shared file shared.json . Each project would have it's own tsconfig.json file and extending the base file shared.json , like so:

{
  "extends": "../shared",
  <options here that are different>
}

More info on this page: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM