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

Marin, CA
Andrew Branch retweeted
The new TypeScript is *really* fast
9
13
237
30,372
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…
158
1,331
6,699
1,316,700
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…
18
165
854
90,129
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…
1
1
22
3,232
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…
1
6
41
4,868
Update for 2024: do whatever you want 🙃
Do not use `import type` unless you need to.
Community note
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…
9
48
502
155,093
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.
3
4
39
4,925
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.
1
48
4,063
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? 🤞🏼
3
6
45
16,862
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…
9
183
857
129,426
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…
9
40
271
46,120
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/…
3
23
130
15,322
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…
2
7
75
9,525
Touched some rock this weekend 😎
11
888
`--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.)
1
1
17
1,172
[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.]
1
5
839