Skip to content

tobloef/typescript-numeric-type-patch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript Numeric Type Patcher

Patches built-in TypeScript declarations to use stricter numeric types in DataView and TypedArray sub-classes.

Read more about it in this blog post: https://tobloef.com/blog/stricter-typescript-numerics.

To run it, simply enter the root folder of your project (the one containing the node_modules folder) and run:

npx typescript-numeric-type-patch

You can optionally specify the path of your project manually:

npx typescript-numeric-type-patch ./path/to/project

By default, the patcher will use "loosely" branded types (number is assignable to Int32). If you want to use "stricly" branded types (number has to be cast to Int32), you can use the --strict flag:

npx typescript-numeric-type-patch --strict

If you don't want to run this manually every time you install TypeScript in your project, you can generate patch files with patch-package for Node.js or bun patch for Bun.

About

Patches built-in TypeScript declarations to use stricter numeric types in `DataView` and `TypedArray` sub-classes.

Resources

Stars

Watchers

Forks