3 ms·
Both `.d.ts` and `.js` files can be created without understanding the TS type system (this is what JSR does). Creating both of those is just a TS syntax transfo
by lucacasonato 3y ago
Both `.d.ts` and `.js` files can be created without understanding the TS type system (this is what JSR does). Creating both of those is just a TS syntax transform - one that is highly stable (esbuild and friends all do it already).
- seniorsassycat 3y agoI know .is can be emitted as an ast transformation, but I'm surprised by d.ts files. Even inferred types?
- mhagemeister 3y agoWe do some basic inference, but that's why we require explicit return types in the public API, see https://jsr.io/docs/about-slow-types https://jsr.io/docs/about-slow-types . TypeScript itself will ship with a new `isolatedDeclarations` option in the next release which is the same thing. The point is that no inference other than simple literal inference needs to be done to get the type of the public API. That way generating .d.ts files can be done by any tool by merely looking at the syntax without type inference.