[HN Gopher] Speeding up the JavaScript ecosystem - Isolated Decl...
___________________________________________________________________
Speeding up the JavaScript ecosystem - Isolated Declarations
Author : realshadow
Score : 13 points
Date : 2024-07-06 20:27 UTC (2 hours ago)
(HTM) web link (marvinh.dev)
(TXT) w3m dump (marvinh.dev)
| viraptor wrote:
| I feel like the point is skipped in the post: if you ship TS
| sources, it means you need the TS compiler on the installed side,
| right? And specifically the right TS version for each installed
| package... which in some cases may mean conflicting requirements?
|
| (If you own code is in JS, that is)
| maxloh wrote:
| The TypeScript compiler is, in most or even all cases, backward
| compatible. You just need to have the latest version installed.
| rtsao wrote:
| I've heard of `isolatedDeclarations` in TS 5.5, but this post
| left me with more questions than answers because it conflates so
| many distinct things (TS 5.5, Deno, JSR).
|
| I'll try my best to break it down succinctly:
|
| 1) Historically, .d.ts generation is slow because it requires the
| full TypeScript type checker in order to correctly handle all
| cases (e.g. exported functions with inferred return types)
|
| 2) However, if types were to be fully explicit, then .d.ts
| generation could be performed without a full type checker (i.e.
| by a faster compiler via mere syntax transformation)
|
| 3) The isolatedDeclarations flag causes the TS compiler to
| trigger errors when any exports would require inference in order
| to generate .d.ts
|
| 4) Thus, the isolatedDeclarations flag can be used to guarantee
| compatibility with faster, simpler .d.ts generation using syntax-
| based transformation
|
| 5) A consequence of simpler .d.ts generation is that it can be
| trivially done in parallel, which can be helpful for large
| monorepos
___________________________________________________________________
(page generated 2024-07-06 23:00 UTC)