cat toothscript.d.ts
09 / 19
toothscript
TypeScript utility types that stay out of your global namespace.
- role
- author
- year
- 2024
- access
- -r--r--r-- (archived, read-only)
- problem
- TypeScript keeps new utility types out of the language on purpose, and libraries that fill the gap often declare theirs globally, in your namespace.
- approach
- Eighteen small types, each imported by name, nothing global.
- outcome
- On npm since November 2024, built with nothing but tsc.
TL;DR
// overview
Assert, StrictOmit, NullableKeys, DeepPartial, Negate, Nominal and friends, as small importable modules.
// nothing global
Every type is a named export, so nothing shows up in a project unless it's imported. That's the whole design.
// what's in it
Property helpers like StrictOmit, NullableKeys and PickByType; recursive ones like DeepPartial and DeepReadonly; negations like ExcludeKeys; and Nominal, for branded types that keep a UserId from passing as a plain number.
// a year after handyscript
In 2023, handyscript added methods to Array and Math. A year later, toothscript's first rule was no global pollution.
// stack
- typescript