【问题标题】:Visual Studio locates systemjs typescript definitions, but cannot locate them on compileVisual Studio 定位 systemjs 打字稿定义,但无法在编译时定位它们
【发布时间】:2016-05-28 10:05:30
【问题描述】:

我在 Visual Studio 中有一个 TypeScript 项目,通过 systemjs 安装了模块。我有以下代码:

app.ts

import { Aurelia } from 'aurelia-framework';

例如,悬停 Aurelia 并按 F12(转到定义)会打开由 systemjs 安装的正确 aurelia-framework.d.ts 文件。但是,当我单击构建时,我得到以下输出:

error TS2307: Build: Cannot find module 'aurelia-router'.

这是我的 tsconfig 供参考。

tsconfig.json

{
  "version": "1.8.0",
  "compilerOptions": {
    "rootDir": "src/",
    "outDir": "dist/",
    "target": "es5",
    "module": "system",
    "declaration": false,
    "noImplicitAny": false,
    "removeComments": true,
    "noLib": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  }
}

【问题讨论】:

  • Aurelia 只是拒绝在 VS2015 中很好地使用 Typescript,不是吗?我可以让 ES2015 框架运行,但 TS 编译器甚至拒绝让我的项目启动,不管它们通过 gulp 完美编译的事实。
  • 当然,.NET Core 可能会有所不同,但让我们现实一点 - 很多 webhosts 不支持 Core,有很多 MVC1-5 项目需要一个附加了现代 JS 框架...这是一个巨大的痛苦。

标签: visual-studio typescript visual-studio-2015 typescript1.8


【解决方案1】:

答案似乎是在您的 aurelia 应用程序的根目录中添加一个文件 - 我称之为 typings.d.ts - /src 或您所称的任何内容 - 带有一个 /// 对索引的引用.d.ts 文件在您的类型文件夹中。

然后一切都很好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-22
    • 1970-01-01
    • 2023-03-24
    • 2020-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多