type-fest/test-d/is-nullable.ts
Park, Jinyong 5067e25fd5
Add IsOptional and IsNullable types (#1180)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
2025-06-14 15:47:27 +02:00

19 lines
652 B
TypeScript

import {expectType} from 'tsd';
import type {IsNullable} from '../source/is-nullable.d.ts';
expectType<IsNullable<any>>(true);
expectType<IsNullable<null>>(true);
expectType<IsNullable<null | undefined>>(true);
expectType<IsNullable<string | null>>(true);
expectType<IsNullable<string | null | undefined>>(true);
expectType<IsNullable<string>>(false);
expectType<IsNullable<string | undefined>>(false);
expectType<IsNullable<void>>(false);
expectType<IsNullable<undefined>>(false);
expectType<IsNullable<never>>(false);
expectType<IsNullable<unknown>>(false);
expectType<IsNullable<() => void>>(false);
expectType<IsNullable<string & null>>(false);