TS Reset

TypeScript's Built-In
Typings, Improved

GitHub
TS Reset by Matt Pocock

without ts-reset

  • 🚨 .json (in fetch) and JSON.parse both return any
  • 🤦 .filter(Boolean) doesn't behave how you expect
  • 😡 array.includes often breaks on readonly arrays

with ts-reset

  • 👍 .json (in fetch) and JSON.parse return unknown
  • .filter(Boolean) behaves EXACTLY how you expect
  • 🥹 array.includes is widened to be more ergonomic
  • 🚀 And several more improvements!

Get Started

  • 01

    Install

    npm i -D @total-typescript/ts-reset
  • 02

    Create a reset.d.ts file in your project with these contents:

    // Do not add any other lines of code to this file!
    import "@total-typescript/ts-reset";
  • Enjoy improved typings across your entire project!

Become the
TypeScript Wizard
at Your Company

A collection of professional, exercise-driven, in-depth, self-paced TypeScript workshops for you to achieve TypeScript wizardry.

Embark on Your TypeScript Adventure
total typescript learning path

Example

// Import in a single file, then across your whole project...
import '@total-typescript/ts-reset'
// .filter just got smarter!
const filteredArray = [1, 2, undefined].filter(Boolean) // number[]
// Get rid of the any's in JSON.parse and fetch
const result = JSON.parse('{}') // unknown
fetch('/')
  .then((res) => res.json())
  .then((json) => {
    console.log(json) // unknown

DOM Example

// Import from /dom to get DOM rules too!
import '@total-typescript/ts-reset/dom'
// localStorage just got safer!
localStorage.abc // unknown
// sessionStorage just got safer!
sessionStorage.abc // unknown