【发布时间】:2017-11-15 22:20:11
【问题描述】:
Here is the full NPM package on GitHub.
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs"
}
}
global.d.ts
interface Foo { }
index.ts
const x: Foo = {};
这就是我们构建时发生的情况:
$ \node_modules\.bin\tsc .\index.ts
index.ts(1,10): error TS2304: Cannot find name 'Foo'.
这是我们的版本:
$ .\node_modules\.bin\tsc --version
Version 2.3.4
这些是 tsc 列出的文件:
$ .\node_modules\.bin\tsc --listFiles
C:/temp/node_modules/typescript/lib/lib.d.ts
C:/temp/global.d.ts
C:/temp/index.ts
我们如何自动将Foo 加载到 index.ts 文件中?
研究
The documentation on global.d.ts 表示上面应该可以工作。
【问题讨论】:
-
这应该可以。你有
tsconfig.json吗?如果是,请发布。 -
@Saravana 我已经发布了 tsconfig 文件。
标签: typescript