is-kit

is-kit logo

TypeScript で isXXX ガードを安全に作るためのユーティリティ。軽量・依存ゼロ。

インストール

pnpm add is-kit

使い方

import { define } from 'is-kit';
const isString = define<string>((x) => typeof x === 'string');
if (isString('hello')) {
// narrowed to string
}

特徴

型安全な述語

型を正確に絞り込む述語を作成・合成できます。

API リファレンス