【问题标题】:Angular Typescript: avoid multiple reference pathAngular Typescript:避免多个引用路径
【发布时间】:2016-05-27 11:51:13
【问题描述】:

我将 Typescript 设置为 Angular 1.5 应用程序。为了使 gulp 编译的 TS 文件没有错误,我必须添加以下内容:

///<reference path="../../../../typings/angularjs/angular.d.ts" />

Typings 文件夹已使用节点模块“tsd”填满。

所以这意味着:

  • 我必须定期运行“tsd update”以始终保持最新状态
  • 在每个 TS 文件中我都必须写 TS 文件的相对路径……真的很烦人

有没有办法自动获取 TSD 文件,并自动插入 gulp 编译?

【问题讨论】:

  • 如果我的回答有效,你能接受吗?
  • 另外 tsd 已被弃用使用类型

标签: angularjs typescript tsd


【解决方案1】:

在您的tsconfig.json 中使用exclude。将您不希望 tsc 使用的路径放在那里。 tsc 会自动找到你项目中的所有打字稿文件。

tsconfig.jsonexclude 的示例:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "isolatedModules": false,
        "jsx": "react",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "declaration": false,
        "noImplicitAny": false,
        "noImplicitUseStrict": false,
        "removeComments": true,
        "noLib": false,
        "preserveConstEnums": true,
        "suppressImplicitAnyIndexErrors": true
    },
    "exclude": [
        "node_modules",
        "typings/browser",
        "typings/browser.d.ts"
    ],
    "compileOnSave": true,
    "buildOnSave": false,
    "atom": {
        "rewriteTsconfig": false
    }
}

【讨论】:

  • 对不起,请解释一下,为什么排除 TS 文件会帮助 gulp 找到它们?
  • @Rolintocour 使用 exclude ts 将自动查找不在排除文件夹中的所有内容。
  • @Rolintocour 在我的示例 ts 中会找到 typings/main.d.ts
猜你喜欢
  • 2017-05-18
  • 1970-01-01
  • 1970-01-01
  • 2021-10-23
  • 1970-01-01
  • 2020-04-12
  • 2011-01-07
  • 2018-12-14
相关资源
最近更新 更多