Type Utils ❇️
Lightweight TypeScript types utilities
Table of Content
Getting started
Run the following command to start using type-utils in your projects:
npm i @alessiofrittoli/type-utils
or using pnpm
pnpm i @alessiofrittoli/type-utils
Utility types usage
Utility types are exported from the package entry point and can be imported where needed:
import type { DeepPartial, ValueOf } from '@alessiofrittoli/type-utils'
See the Utility types docs for the full list.
Global extenders setup
Extenders types augment built-in global interfaces (such as JSON and Body) and they are the only global types defined by this library. Global types are not loaded by your IDE by default.
After installation a postinstall script is executed to create (or update) the globals.d.ts file at the root of your project, adding the following globals types reference:
/// <reference types="@alessiofrittoli/type-utils/globals" />
If the file get ignored by the TypeScript program of your project, please, manually add globals.d.ts in the array of the "include" property in your tsconfig.json.
{
"compilerOptions": {
...
},
"include": [ ..., "globals.d.ts" ],
}
You can skip this process if *.ts is already in your "include" array.
⚠️ If the globals.d.ts file creation fails you can run the following command to manually execute the script:
node node_modules/@alessiofrittoli/type-utils/scripts/postinstall/index.cjs
💡 If you don't want to use the global extenders, simply remove the reference above from your globals.d.ts file. Utility types will keep working since they are imported explicitly.
Development
Run the following to start development
nvm use
pnpm i
Local development
Run the following
pnpm dev
This will generate unminified output code, sourcemaps and will enable source file watcher.
Production build
Run the following to create a local production build
pnpm build
This will lint and type-check the source code, then generate minified output code without sourcemaps.
Lint
Run warnings and errors checks with oxlint:
pnpm lint
Contributing
Contributions are truly welcome!
Please refer to the Contributing Doc for more information on how to start contributing to this project.
Help keep this project up to date with GitHub Sponsor.
Security
If you believe you have found a security vulnerability, we encourage you to responsibly disclose this and NOT open a public issue. We will investigate all legitimate reports. Email [email protected] to disclose any security vulnerabilities.
Made with ☕
|
|
|