使用Awesome Typescript Loader处理.d.ts文件

时间:2016-10-06 12:47:42

标签: angular typescript webpack

我最近将我的Angular2版本升级到最终版本,并且awesome-typescript-loader有一个问题需要一个声明文件。我该怎么做以及在哪里链接该打字文件? 我使用angular2-webpack-starter。我的应用提供商定义中有几个.d.ts文件。

现在所有编译它们的尝试都以类似的结尾:

Module build failed: Error: Debug Failure. False expression: Output generation failed
at Object.assert (node_modules\typescript\lib\typescript.js:2407:23)
at Object.transpileModule (node_modules\typescript\lib\typescript.js:54401:18)
at State.fastEmit (node_modules\awesome-typescript-loader\src\host.ts:264:39)
at transform (node_modules\awesome-typescript-loader\src\index.ts:164:28)
at transformationFunction (node_modules\awesome-typescript-loader\src\index.ts:89:48)
at compiler (node_modules\awesome-typescript-loader\src\index.ts:105:34)
at Object.loader (node_modules\awesome-typescript-loader\src\index.ts:18:18)
@ ./src/app/providers/socket/index.ts 6:9-40
@ ./src/app/providers/socket/chat-service.ts
@ ./src/app/pages/restricted/restricted.ts
@ ./src/app/app.routes.ts
@ ./src/app/app.module.ts
@ ./src/app/index.ts
@ ./src/main.browser.ts
@ multi main

ATL自述的建议:

All declaration files should be resolvable from the entry file. The easiest way to do this is to create a references.d.ts file which contains references to all of your declaration files. Then reference references.d.ts from your entry file.

提前致谢!

2 个答案:

答案 0 :(得分:1)

我从输入源中排除了.d.ts文件,而是使用tsconfig.json的typingsRoot属性定义了.d.ts文件的位置。当输入文件没有输出时,应该抛出错误似乎很愚蠢。这很常见,例如只包含接口定义的文件。

答案 1 :(得分:0)

由于我的.d.ts文件只包含接口,我已将它们全部重命名为[something] .interface.ts。现在我只是custom-typings.d.tstsconfig.json中链接了其他内容。

相关问题