Skip to content

Instantly share code, notes, and snippets.

View andrewbranch's full-sized avatar

Andrew Branch andrewbranch

View GitHub Profile
@andrewbranch
andrewbranch / tsc-ts-vs-dts.md
Last active March 28, 2025 14:26
tsc performance consuming .ts vs .d.ts files in npm packages

Original Tweet

tsc performance consuming .ts vs .d.ts files in npm packages

What if TypeScript libraries published just .ts sources to npm instead of .js and .d.ts files? This might already be tempting for Bun-only libraries, but how will that impact users? This is easy to answer by experimenting on existing libraries that ship .js, .d.ts, and .ts files.

RxJS ships .js and .d.ts files, but also .ts files for debugability purposes. By tweaking its package.json "exports", we can compare tsc performance on this file with imports resolving to .d.ts files vs .ts source files:

import {} from "rxjs";
@andrewbranch
andrewbranch / writing-type-definitions.md
Last active November 3, 2023 19:07
Writing type definitions, on a scale of 1–5

Writing type definitions, on a scale of 1–5

By hand With tsc With 3rd party tool
Ease 1 5 4
Avg. correctness 2 5 2
Flexibility 5 1 3