Daniel Kucal
Daniel Kucal

Reputation: 9232

handling .d.ts files with Awesome Typescript Loader

I've recently upgraded my Angular2 version to the Final one and have a problem with awesome-typescript-loader that wants one declaration file. How can I do it and where to link that typings file? I use the angular2-webpack-starter. I have a few .d.ts files in my app providers definitions.

For now all the tries to compile them end with something like:

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

The advice from ATL readme:

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.

Thanks in advance!

Upvotes: 0

Views: 2128

Answers (2)

Daniel Kucal
Daniel Kucal

Reputation: 9232

As my .d.ts files contained interfaces only, I've renamed them all to [something].interface.ts. Now I've just custom-typings.d.ts that is linked in tsconfig.json for other things.

Upvotes: 0

Richard Collette
Richard Collette

Reputation: 5703

I excluded .d.ts files from input sources and instead defined the location of .d.ts files using the typingsRoot property of tsconfig.json. It does seem silly that an error should be thrown when an input file results in no output. This would be fairly common such as a file containing only an interface definition.

Upvotes: 2

Related Questions