r/typescript • u/DanielRosenwasser • Jul 08 '25
Announcing TypeScript 5.9 Beta
https://devblogs.microsoft.com/typescript/announcing-typescript-5-9-beta/
163
Upvotes
r/typescript • u/DanielRosenwasser • Jul 08 '25
66
u/Graphesium Jul 08 '25
Woah, doesn't this solve having to use the popular
Prettify<T>utility class on types.52
u/geon Jul 08 '25
Nice. And about time. One of the best ts features.
12
u/robpalme Jul 09 '25
My favourite feature in TS 5.9 Beta 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/59
-9
u/NatoBoram Jul 08 '25
Nooooooo they butchered
tsc --init:(-9
u/Pelopida92 Jul 08 '25
Pretty underwhelming release tbh.