filipesilva / angular-quickstart-lib

MIT License
305 stars 75 forks source link

How do I make custom typings for dependant modules #65

Open Bengreen opened 6 years ago

Bengreen commented 6 years ago

In my library I am creating I am using some dependant libraries to provide some parts. But these dependant (JS) libraries do not have typescript typings and/or have broken typings (in definitely typed @types). I am going to go through the process of making pull requests to these to improve these BUT for some of these it will not be feasible. Is there are way to create my own local custom typings for modules I am using in the process of building a module ? I tried in index.d.ts, but couldn't get it working it seemed to be parsing those definitions after the index.ts which meant that type errors stopped my build in the index.ts.

Any help or pointers or suggestions would be much appreciated ?

mlwilkerson commented 6 years ago

@Bengreen I faced the same thing and did a temporary solution. If you run tsc with --traceResolution you can see the various locations where tsc looks for type definition files. One of those places is under node_modules/@types. So I created my type definitions for dependent modules within my repo under src/lib somewhere, and then made a symlink to it from node_modules/@types. This was just to try it out as a temporary solution. Since it's working, I plan to add a step to build.js to set up this symlink during the build process (because as of right now, as soon as node_modules is removed, my link will disappear.)