如何处理具有多个tsconfig.json文件的项目?

时间:2015-11-09 21:36:04

标签: typescript tsconfig

我正在开发一个像这样结构的项目:

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

我的tsconfig.json在根

"target": "es6",
"outDir": "built",
"rootDir": "./src",

我需要perf文件夹上的其他配置,就像其他目标一样。

"target": "es5",

但是,我的typings文件夹位于项目的根目录下,而不在perf文件夹中。因此,执行tsc ./perf会导致很多错误。

有没有办法告诉TypeScript在哪里查找typings?我正在使用

npm install -g typescript@next
// typescript@1.8.0-dev.20151109

或者根据文件夹进行不同配置的方法?

2 个答案:

答案 0 :(得分:7)

您可以通过扩展基本tsconfig.json文件来完成此操作:

tsconfig extension

只是不排除基础tsconfig.json中的目录,打字稿应该能够解决你的打字(使用node_modules / @ types或者typings模块知道这是真的)

例如:

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
   }
}

答案 1 :(得分:1)

  

有没有办法告诉TypeScript在哪里寻找打字

最快的解决方案

typings移至pref。

长期解决方案

filesGlobhttps://github.com/Microsoft/TypeScript/issues/1927

支持tsc后使用let size = CGSize(width: 300, height: 400) UIGraphicsBeginImageContext(size) let areaSize = CGRect(x: 0, y: 0, width: size.width, height: size.height) bottomImage.drawInRect(areaSize) topImage.drawInRect(areaSize, blendMode: CGBlendMode.Normal, alpha: 1.0) let newImage: UIImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext()
相关问题