←
Andrew Branch3,224 posts
Andrew Branch avatar

Andrew Branch

@atcb

Working on TypeScript at Microsoft. I appear when someone says “module resolution” three times in the dark. He/him

◷ Joined January 2013▧ 228 Photos and videos
alistair avatar
⟳ Andrew Branch retweeted
alistair@alistaiir·11 Mar 2025

The new TypeScript is *really* fast

0:03
Marco Ippolito avatar
⟳ Andrew Branch retweeted
Marco Ippolito@satanacchio·7 Jan 2025

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…

Andrew Branch avatar
Andrew Branch@atcb·23 Aug 2024

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! 👏

TypeScript@typescript23 Aug 2024

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…

John Reilly ❤️🌻 avatar
⟳ Andrew Branch retweeted
John Reilly ❤️🌻@johnny_reilly·15 Jun 2024

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…

Andrew Branch avatar
Andrew Branch@atcb·27 May 2024

I personally tend to use type-only imports via auto-imports (with `verbatimModuleSyntax`) in new projects, but maybe I just like using stuff I made 😄Do what makes you happy, and go deeper into understanding how your tools work if you can. It might be more complex than you think.

Andrew Branch avatar
Andrew Branch@atcb·27 May 2024

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.

Post attachment
Andrew Branch avatar
Andrew Branch@atcb·27 May 2024

I like people to know why they’re writing the code they’re writing. But even when I told people it was having no effect on their output, most folks kept using type-only imports as a signal of explicit intent. They just *liked* using them. I now think that’s a fine reason.

Andrew Branch avatar
Andrew Branch@atcb·27 May 2024

Single-file transpilers were always able to handle 99% of removing imports only used for types with cheap usage analysis. The remaining 1% are isolatedModules errors. For a long time I fought this misconception by saying “you don’t need this, you’re already getting what you want”

Andrew Branch avatar
Andrew Branch@atcb·27 May 2024

The problem with type-only imports is that as soon as they existed, everyone became convinced that using them would be the *only* way to drop runtime-unnecessary imports from their output, whether they were using tsc or other tools. This was never true.

Andrew Branch avatar
Andrew Branch@atcb·28 Apr 2024

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? 🤞🏼

TypeScript avatar
⟳ Andrew Branch retweeted
TypeScript@typescript·25 Apr 2024

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…

Rob Palmer avatar
⟳ Andrew Branch retweeted
Rob Palmer@robpalmer2·19 Apr 2024

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…

Rob Palmer avatar
⟳ Andrew Branch retweeted
Rob Palmer@robpalmer2·18 Mar 2024

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