← Back to archive

Repo of the Day

mattpocock/ts-reset

Published: Apr 7, 2023

Open repository ↗

A 'CSS reset' for TypeScript, improving types for common JavaScript API's

Summary

ts-reset is a TypeScript package that refines the built-in type definitions for common JavaScript APIs. It works like a CSS reset, but applied to the type system — patching rough edges so standard library methods behave more predictably. The project is written in TypeScript and released under the MIT license.

What it is useful for

ts-reset addresses a few well-known frustrations with TypeScript's default typings. According to the README, the library changes three specific cases: fetch().json and JSON.parse return unknown instead of any, which requires callers to narrow the value before using it; .filter(Boolean) returns a properly typed array with falsy values removed, matching the runtime behavior; and Array.prototype.includes is widened so it works on readonly arrays. The README mentions "several more changes" beyond these three but does not enumerate them in the available text, so engineers should check the official docs for the complete list. The aim is to make standard library interactions safer and more ergonomic without writing per-project wrapper functions.

How engineers can use it

The README excerpt provided here does not include installation commands or configuration snippets, so the exact setup steps are not documented in this source. Engineers should refer to the project's README and the official Total TypeScript documentation page (referenced in the README) for instructions on adding ts-reset to a project, including any required tsconfig.json changes. Once configured, no source code edits are needed — the reset works by overriding TypeScript's lib types globally, and the runtime behavior of existing JavaScript is unchanged. A practical starting approach is to add it to one project, identify the places where typings have shifted (for example, code that previously treated JSON.parse output as any will now need a type guard or assertion), and decide whether the stricter defaults fit the codebase.