Open NikhilVerma opened 4 years ago
Wouldn't adding the lib-reference in the source file only already solve this issue?
My mistake, won't do. :-)
@MartinJohns when i used /// reference
it actually includes the types for the whole project (it's similar to adding lib
option in tsconfig.json)
And the Typescript documentation seems to suggest so: https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-lib-
For example, adding ///
to one of the files in a compilation is equivalent to compiling with --lib es2017.string.
Search Terms
export library interface
Suggestion
Right now Typescript declares it's libraries using
d.ts
(e.g.lib.dom.d.ts
) so if you include this in your project you get the entire DOM library and it's interfaces. This is great however it makes development of isomorphic code harder.Your only option is to add the
dom
library to your NodeJS project. This means that consumers could accidentally write unsafe code.My proposal is really simple. Along with existing d.ts imports, we also export (in a separate file) the interfaces for those libraries
Use Cases
Isomorphic code could be be implemented in an easier way. Right now we need to either include the whole library or use dependency injection. Which is not always trivial.
Here is an example of an issue encountered from the puppeteer repo - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/24419#issuecomment-637700421
Examples
Checklist
My suggestion meets these guidelines: