A lightweight zero dependency Typescript type checking library that coerces unknown value types. More concise and accurate than typeof
checks or similar type checking methods.
npm i taap
import { isArray } from 'taap';
const maybeArray: unknown = [];
if (typeof maybeArray === 'array') {
🚫 typeof [] === 'object'
} else if (isArray(maybeArray)) {
// `maybeArray` is now of type: `any[]`
✅ maybeArray.push(1);
}
import { isArray } from 'taap';
const maybeArray: unknown = [1, 2, 3];
if (isArray<number>(maybeArray)) {
// `maybeArray` is now of type: `number[]`
maybeArray.filter((x) => x > 1);
}
Supports optional generic return type:
Fixed return type:
Other: