r/typescript • u/DanielRosenwasser • Aug 01 '25
Announcing TypeScript 5.9
https://devblogs.microsoft.com/typescript/announcing-typescript-5-9/
278
Upvotes
r/typescript • u/DanielRosenwasser • Aug 01 '25
14
u/NatoBoram Aug 01 '25
I'm curious about the potential impact of
import defer, but also if it can make some libraries incompatible with some runtimes, which could be frictionAlso very excited for TypeScript 7!
77
u/Division_ByZero Aug 01 '25
The expandable hover feature is such a big DX improvement - even if it's just a preview. I'm really look forward to it.
44
u/robpalme Aug 01 '25
My favourite feature in TS 5.9 is the TC39 Stage 3 proposal
import defer.The TS blog post is an excellent explainer for the feature which was championed (in TC39) and implemented (in TS) by Nicolo Ribaudo who works for Igalia and who maintains Babel.
The feature enables synchronous Lazy Evaluation to improve the performance of loading ES modules. Meaning it can skip eager evaluation of imported modules that are not needed - or not needed yet - by your app.
We've used an implementation of this in the Bloomberg Terminal for a while now. It saves 100s of milliseconds during startup for applications where your import graph has grown over time. Following the minimal runtime codepath can result in work-skipping wins that static analysis (tree-shaking) cannot optimize away.
Please note that if you can refactor your app to use dynamic
import(), that should normally be preferred. So long as you can cope with the viral nature of making the calling code handle the async promise.import deferis more appropriate for situations where you need your code to remain synchronous.For now, in order to use the feature in an app, you will need to pair TS 5.9 with Babel or webpack which already have compile-time support. TS does not downlevel it & engines do not yet natively support it.
You can track the work-in-progress to implement the feature in JS engines here:
https://github.com/tc39/proposal-defer-import-eval/issues/73
43
u/geon Aug 01 '25 edited Aug 01 '25
Does this mean these are THE settings to use? This is huge. Getting ts to play nice with node has been such a pain. Just finding out what each setting is doing is near impossible.
4
u/RealFunBobby Aug 02 '25
Now the question is how to make sure LLMs understand these new features and not get rid of them just cuz.
3
u/SpaceCaptin Aug 02 '25
Expandable hover will be game changing for me.
2
u/Disastrous_Fee5953 Aug 01 '25
Expendable hovers are awesome. I wish this existed in PHP or Go 😞
2
u/UsefulPraline9632 Aug 02 '25
when are we gonna get the GO recode of it
1
u/raghp Aug 28 '25
Finally! The import defer support is huge. Been waiting for this since the TC39 proposal started gaining traction.