Skip to content

haejunejung/ts-typekit

Repository files navigation

ts-typekit

ts-typekit

🧰 Collection of TypeScript utility types

Version Downloads Type Coverage Software License

  • No Runtime Cost: ts-typekit operates exclusively at compile-time, meaning it introduces zero overhead to your runtime performance.

  • Battle-tested: All utility types within ts-typekit are rigorously tested using tsd, providing you with confidence and reliability in their usage.

  • Type Safety: By leveraging ts-typekit, you can enforce stricter type checks, reducing the likelihood of type-related errors and improving the overall robustness of your TypeScript applications.

Whether you're dealing with complex type transformations, conditional types, or need to enforce specific type constraints, ts-typekit has you covered with a growing collection of utility types that cater to a variety of common and advanced use cases.

Install

npm install ts-typekit
yarn add ts-typekit

Requires TypeScript >= 5.1

Usage

import type { StrictOmit } from 'ts-typekit';

type User = {
  id: number;
  name: string;
};

type UserWithoutId = StrictOmit<User, 'id'>; // { name: string }

Tip

Recommend working with the {strict: true} option in tsconfig.

If your team is using ESLint and wants to enforce the use of StrictOmit instead of the standard Omit, you can configure ESLint to help catch this. The @typescript-eslint/ban-types rule can be configured to display an error message when Omit is used, guiding developers to use StirctOmit instead. Here's how you can set up your ESLint configuration:

module.exports = {
  parser: '@typescript-eslint/parser',
  plugins: ['@typescript-eslint'],
  rules: {
    // Include other relevant rules here
    '@typescript-eslint/ban-types': [
      'error',
      {
        types: {
          Omit: 'Use StrictOmit instead', // write the error message.
        },
        extendsDefaults: true,
      },
    ],
  },
};

Contributing

Read below for detailed contribution guide.

CONTRIBUTING

Contributors

Thanks for considering contributing to ts-typekit.

haejunejung
haejunejung