type-fest/test-d/if-unknown.ts
2024-04-02 12:00:45 +09:00

13 lines
382 B
TypeScript

import {expectType} from 'tsd';
import type {IfUnknown} from '../index';
// `IfUnknown` should return `true`/`false` if only `T` is specified
expectType<IfUnknown<unknown>>(true);
expectType<IfUnknown<string>>(false);
expectType<IfUnknown<unknown, 'T', 'F'>>('T');
expectType<IfUnknown<string, 'T', 'F'>>('F');
// Missing generic parameter
// @ts-expect-error
type A = IfUnknown;