Live data from Hacker News

Speeding up the JavaScript ecosystem – Isolated Declarations

marvinh.dev

1–10 of 57 posts

Re: Speeding up the JavaScript ecosystem – Isolated Declarations

#2
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)

Re: Speeding up the JavaScript ecosystem – Isolated Declarations

#3
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

Re: Speeding up the JavaScript ecosystem – Isolated Declarations

#4
post #3

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 typ…

[deleted]

Re: Speeding up the JavaScript ecosystem – Isolated Declarations

#5
post #2

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)

The TypeScript compiler is, in most or even all cases, backward compatible. You just need to have the latest version installed.

Re: Speeding up the JavaScript ecosystem – Isolated Declarations

#6
whilst reducing the time to create type definition files from minutes, sometimes even hours, down to less than a second.

WTF. What kind of project would take long to compile from TS? Windows 11 (if it were TS)?

I had a long time personal project that was several megs of code with several hundred types/interfaces. It took 13 seconds to compile. If your application takes hours to compile and is less than a petabyte of source code you have some catastrophic mistakes in your approach.

Re: Speeding up the JavaScript ecosystem – Isolated Declarations

#8

whilst reducing the time to create type definition files from minutes, sometimes even hours, down to less than a second. WTF. What kind of project would take long to compile from TS? Windows 11 (if it were TS)? I had a long time personal project that was several megs of code with several hundred types/interfaces. It took 13 seconds to compile. If your application takes hours to compile and is less than a petabyte of…

I think they are referring to the manual creation of type definitions. As they mention it in the article.

Re: Speeding up the JavaScript ecosystem – Isolated Declarations

#9

The blog doesn't explain how to take advantage of isolated modules without using JSR, or how JSR transforms published packages. How would a project configure node and typescript to use a npm module that has exported .ts files?

You wouldn't, you would use JSR.

Re: Speeding up the JavaScript ecosystem – Isolated Declarations

#10
From what I understand, the author is persuading library authors to stop compiling TS->JS, and instead ship your TS files to the users over npm. I like the idea of it, but will it actually work in practice? What if some dependency only compiles with some version of tsc? What if it needs different tsconfig-s?
Post reply on HN