TypeScript Reference Type Definitions

I am creating an Aurelia application in TypeScript that uses the SystemJS / jspm and TypeScript definition manager . I have .ts source files in /app/** and .d.ts files under /typings/** and /jspm_packages/** (since some definition files are sent via jspm).

Obviously, the TypeScript compiler does not understand SystemJS / jspm or TSD, so I need to somehow refer to their type definitions. I tried to pass all the .ts files .ts compiler so that it referenced both the source and the definitions, but this would cause the rabbit hole to load all type definitions imported by all type definitions. It ends with a start type definition (Yo dawg I heard that you like type definitions). It seems that the compiler should only care about things exported by type definitions that directly reference the source (and not on things imported by these definitions).

In any case, I get the feeling that I did the wrong thing, and I wonder if there is a better / correct way of referencing definition files.

PS: It seems that there may be some solutions that have editors / plugins, but I am looking for a strictly CLI approach, since this is part of an automatic assembly.

+6
source share
1 answer

I don't like file links. I just use the exclude option in tsconfig.json . This ensures that all sample files are included in my entire project, and I no longer need to use <reference> .

Just use the following tsconfig and you should be good to go:

 { "compilerOptions": { "target": "es5", // or es6 "module": "system", "sourceMap": true, "declaration": true }, "exclude": [ "node_modules" ] } 

Here is my main file in this module. Please note that there are no links to the creative.

+1
source

All Articles