# mattpocock/ts-reset

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/mattpocock-ts-reset).**

8,533 stars · 138 forks · TypeScript · MIT

## Links

- GitHub: https://github.com/mattpocock/ts-reset
- Homepage: https://www.totaltypescript.com/ts-reset
- awesome-repositories: https://awesome-repositories.com/repository/mattpocock-ts-reset.md

## Topics

`reset` `typescript`

## Description

ts-reset is a TypeScript type enhancement library that overrides and augments the built-in type definitions for standard JavaScript APIs. Its core purpose is to replace unsafe `any` return types with stricter alternatives like `unknown`, forcing developers to explicitly validate data before using it. The library achieves this through global type augmentation and declaration merging, applying changes across the entire project without requiring per-file imports.

The library differentiates itself by targeting specific pain points in everyday TypeScript usage. It relaxes type constraints on array methods like `includes` and `indexOf` for readonly arrays, allowing membership checks and index lookups with values that don't match the array's element type. Similarly, it widens `Map.has` and `Set.has` to accept broader value types during existence checks. For array filtering, it injects `Boolean` as a type predicate, narrowing filtered results to exclude falsy values. On the safety side, it hardens browser storage API return types and changes `JSON.parse` and `Response.json` to return `unknown` instead of `any`, preventing unsafe access patterns.

The broader capability surface includes conditional type narrowing for standard APIs, type predicate injection into filter callbacks, and stricter type guarding for `Array.isArray` checks. These changes collectively enforce a more rigorous type safety posture for common JavaScript operations without requiring manual type annotations or wrapper functions. The library is distributed as a single package that can be added to any TypeScript project, applying its type improvements globally through declaration merging.

## Tags

### Software Engineering & Architecture

- [Type Safety Resets](https://awesome-repositories.com/f/software-engineering-architecture/typescript-type-definitions/static-type-checking/typescript-type-synthesis/type-safety-resets.md) — Improves default TypeScript types for common JavaScript APIs to catch more errors and require explicit validation.
- [Map Key Validation](https://awesome-repositories.com/f/software-engineering-architecture/map-key-validation.md) — Relaxes Map.has type constraints to accept broader value types during key existence checks. ([source](https://www.totaltypescript.com/ts-reset))
- [Widened Key Existence Checks](https://awesome-repositories.com/f/software-engineering-architecture/map-key-validation/widened-key-existence-checks.md) — Widens Map.has type constraints to accept broader value types during key existence checks. ([source](https://cdn.jsdelivr.net/gh/mattpocock/ts-reset@main/README.md))
- [Rigorous Type Set Operations](https://awesome-repositories.com/f/software-engineering-architecture/pattern-matching-libraries/type-aware-matching/rigorous-type-set-operations.md) — Widens Set.has type constraints to accept broader value types during membership checks. ([source](https://www.totaltypescript.com/ts-reset))
- [Type Enhancement Libraries](https://awesome-repositories.com/f/software-engineering-architecture/typescript-type-definitions/static-type-checking/typescript-type-synthesis/type-enhancement-libraries.md) — A library that improves built-in TypeScript types for common JavaScript APIs, replacing unsafe any types with stricter alternatives.
- [Type Predicate Injections](https://awesome-repositories.com/f/software-engineering-architecture/boolean-predicates/type-predicate-injections.md) — Injects Boolean as a type predicate into filter callbacks to narrow array results to truthy values.
- [Array Type Guards](https://awesome-repositories.com/f/software-engineering-architecture/runtime-type-guards/json-type-guards/array-type-guards.md) — Verifies whether a value is an array and narrows its type to unknown instead of any for safer handling. ([source](https://cdn.jsdelivr.net/gh/mattpocock/ts-reset@main/README.md))

### Data & Databases

- [Type-Safe Local Storage](https://awesome-repositories.com/f/data-databases/type-safe-data-abstractions/type-safe-local-storage.md) — Hardens browser storage API return types to prevent unsafe data access patterns. ([source](https://www.totaltypescript.com/ts-reset))
- [Boolean Type Predicate Filters](https://awesome-repositories.com/f/data-databases/array-element-modifiers/predicate-based-filtering/boolean-type-predicate-filters.md) — Removes falsy values from an array type by using Boolean as a type predicate in the filter method. ([source](https://cdn.jsdelivr.net/gh/mattpocock/ts-reset@main/README.md))
- [Widened Includes on Const Arrays](https://awesome-repositories.com/f/data-databases/array-searching/widened-includes-on-const-arrays.md) — Checks membership in readonly arrays without requiring the search value to match the array's element type. ([source](https://www.totaltypescript.com/ts-reset))
- [Truthy Array Filters](https://awesome-repositories.com/f/data-databases/data-processing-pipelines/data-transformation/array-tensor-manipulation/array-filtering/truthy-array-filters.md) — Removes falsy values from an array by passing Boolean as the filter callback and narrowing the result type. ([source](https://www.totaltypescript.com/ts-reset))
- [Strict Response.json Return Types](https://awesome-repositories.com/f/data-databases/data-structures/structured-return-objects/json-response-serializers/strict-response-json-return-types.md) — Narrows Response.json return type to unknown instead of any so you must validate the data before use. ([source](https://www.totaltypescript.com/ts-reset))

### Programming Languages & Runtimes

- [Global Type Augmentations](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/programming-languages/type-systems/typescript-declaration-tooling/global-type-augmentations.md) — Overrides built-in TypeScript type definitions globally using declaration merging to change default behavior.
- [Conditional Types](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-execution-environments/runtime-environments/runtimes/type-definition-systems/conditional-types.md) — Uses conditional types to widen or tighten type constraints on standard JavaScript APIs like Array and Map.
- [Unknown-First Return Types](https://awesome-repositories.com/f/programming-languages-runtimes/unknown-type-handling/unknown-first-return-types.md) — Replaces any return types with unknown in methods like JSON.parse and Response.json to enforce type safety.
- [Readonly Array Method Wideners](https://awesome-repositories.com/f/programming-languages-runtimes/automatic-type-inferences/literal-type-inferences/widening-controls/widening-mechanisms/readonly-array-method-wideners.md) — Relaxes type checking on readonly array methods like includes and indexOf to accept broader value types.
- [Strict JSON.parse Return Types](https://awesome-repositories.com/f/programming-languages-runtimes/json-parsing/strict-json-parse-return-types.md) — Narrows JSON.parse return type to unknown instead of any so you must verify the result before using it. ([source](https://www.totaltypescript.com/ts-reset))
- [Array.isArray](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/type-system-tools/type-definitions/variable-type-declarations/type-narrowing/array-isarray.md) — Checks whether a value is an array and narrows its type to unknown instead of any for precise type guarding. ([source](https://www.totaltypescript.com/ts-reset))
- [Loosened Array Index Finders](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/data-structure-type-helpers/data-type-utilities/array-element-finding/loosened-array-index-finders.md) — Locates a value's position in a readonly array without requiring the value to match the array's element type. ([source](https://cdn.jsdelivr.net/gh/mattpocock/ts-reset@main/README.md))
- [Widened IndexOf on Const Arrays](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/data-structure-type-helpers/data-type-utilities/array-element-finding/widened-indexof-on-const-arrays.md) — Finds positions in readonly arrays without requiring the search value to match the array's element type. ([source](https://www.totaltypescript.com/ts-reset))

### Scientific & Mathematical Computing

- [Widened Set Membership Checks](https://awesome-repositories.com/f/scientific-mathematical-computing/element-membership-checks/widened-set-membership-checks.md) — Widens Set.has type constraints to accept broader value types during membership checks. ([source](https://cdn.jsdelivr.net/gh/mattpocock/ts-reset@main/README.md))
- [Loosened Array Membership Checks](https://awesome-repositories.com/f/scientific-mathematical-computing/element-membership-checks/loosened-array-membership-checks.md) — Checks if a value exists in a readonly array without requiring the value to match the array's element type. ([source](https://cdn.jsdelivr.net/gh/mattpocock/ts-reset@main/README.md))

### Development Tools & Productivity

- [Safe JSON Parsing](https://awesome-repositories.com/f/development-tools-productivity/code-generators/boilerplate-generators/android/json-data-parsing/type-safe-parsing/safe-json-parsing.md) — Converts JSON strings into unknown instead of any so you must check the type before accessing properties. ([source](https://cdn.jsdelivr.net/gh/mattpocock/ts-reset@main/README.md))

### Web Development

- [Safe Fetch Response Parsing](https://awesome-repositories.com/f/web-development/type-safe-api-clients/type-safe-response-parsers/safe-fetch-response-parsing.md) — Converts fetch response bodies to unknown instead of any to encourage explicit result validation. ([source](https://cdn.jsdelivr.net/gh/mattpocock/ts-reset@main/README.md))
- [Storage API Type Hardening](https://awesome-repositories.com/f/web-development/web-storage-apis/storage-api-interception/storage-api-type-hardening.md) — Strictens the return types of browser storage APIs to prevent unsafe access patterns.
