Andrew Branch retweeted
Today we're thrilled to announce our effort to port the TypeScript compiler and language service to native code, gaining a 10x speed boost in build times and editor responsiveness!
devblogs.microsoft.com/types…
Andrew Branch retweeted
Node.js v23.6.0 is out! 🥳🎉
This release enables the flag --experimental-strip-types by default.
Node.js will execute TypeScript files without additional configuration!
⚠️ This feature is experimental, has limitations and is subject to change.
nodejs.org/en/blog/release/v…
Editing with @britto_gab's work on region-prioritized diagnostics has been so great:
> in our testing on TypeScript’s own checker.ts, a full semantic diagnostics response took 3330ms. In contrast, the response for the first region-based diagnostics response took 143ms!
👏
The release candidate for TypeScript 5.6 is now available for testing! Give it a try today for more new checks, ways to speed-up your builds, new JS features, and more!
devblogs.microsoft.com/types…
Andrew Branch retweeted
Dual publishing ESM and CJS is hard. Getting the types incorrect in your package.json is disappointingly easy. If you want something to help you with both, then maybe tsup and Are the Types Wrong can help. Thanks to @atcb for his assistance with this ❤️🌻
johnnyreilly.com/dual-publis…
Update for 2024: do whatever you want 🙃
Do not use `import type` unless you need to.
Readers added context they thought people might want to know
This comment was written before TypeScript shipped the `verbatimModuleSyntax` configuration option, which improves upon the behavior of `import type`:
typescriptlang.org/tsconfig/#verb…
Several experts on TypeScript, including the original author of this comment, no longer stand by this guidance:
x.com/atcb/status/17…
x.com/mattpocockuk/s…
Early on, I was reluctant to make type-only imports easier to adopt as a wholesale stylistic choice because I thought it would add to the confusion. Eventually, you all changed my mind, and I added a VS Code preference to make auto-imports use them as much as possible.
This brings up some great questions about a confusing topic, but the advice Brandon found in his research is bad advice! My full explanation via blog post: blog.andrewbran.ch/default-e…
Apparently, I've been doing NPM package exports in TSC wrong my entire life. I usually use the ESM `export default _` if I'm doing a default export.
This generated CJS output appears to break when require'd in a CJS environment, requiring a property ref of `packageName.default` instead of simply `packageName`.
After much research, it appears the generally recommended fix is to use `module.exports =` in your main ESM file that TSC processes. WHAT. That's not a typo.
You can use any ESM imports or syntax you need in that file, but for the CJS output file to use `module.exports`, the ESM needs to use it too. Why can't TSC convert `export default` to `module.exports =` for the CJS target?
Doing this also appears to mess with the export types, so the `.d.ts` files sometimes get emptied out unless you export your exports with both ESM and CJS syntax together, even like this:
export default myFunction;
module.exports = myFunction;
Has anyone else run into this? Twilight Zone moment with a simple fix? 🤞🏼
Andrew Branch retweeted
Announcing TypeScript 5.5 Beta! 📣
Now with type predicate inference, more type narrowing, an @import tag for JSDoc, the --isolatedDeclarations flag, performance & reliability improvements, and much more!
devblogs.microsoft.com/types…
Andrew Branch retweeted
TypeScript excitement 😉
Congrats to @TitianCernicova @TechAtBloomberg on landing --isolatedDeclarations in upstream TypeScript 🎉
It's the start of a journey to faster type-checking at scale 🔥
An epic collab between folk in TS, Bloomberg & Google 👍
github.com/microsoft/TypeScr…
Andrew Branch retweeted
Node excitement 😉
Congrats to @JoyeeCheung at @igalia on landing **experimental** support for require(ESM) in Node 🎉
The intent is to allow more CommonJS packages to migrate to ESM without breaking compatibility. This should help eliminate the [ERR_REQUIRE_ESM] error 👍
Landed experimental support for synchronous require(esm) to load ES modules without top-level await 🥳 github.com/nodejs/node/pull/…
Andrew Branch retweeted
For my PR to infer type predicates, I needed to understand TypeScript's control flow graph. So I added a graph visualization to @DavidSherret's amazing TypeScript AST Viewer. It's live now and very fun to play with! Edges go backwards in execution order.
ts-ast-viewer.com/#code/GYVw…
`--module preserve` allows you to write imports and requires in the same file. When combined with `--moduleResolution bundler`, these get resolved with accurate conditional package.json "exports" lookups. (TS is shown here, but `const pkg2 = require("pkg")` works in JS files.)
[Video description: VS Code screen capture with code:
import pkg1 from "pkg";
import pkg2 = require("pkg");
console.log({
import: pkg1,
require: pkg2,
});
Terminal:
> bun index.ts
{
import: "import.mjs",
require: "require.js"
}
TS hovers show the same thing.]
Pull request: github.com/microsoft/TypeScr…














