type-fest/test-d/if-any.ts
Tommy 4045737499
Add IsX/IfX types for any/never/unknown (#564)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
2023-04-06 00:07:21 +09:00

14 lines
375 B
TypeScript

import {expectError, expectType} from 'tsd';
import type {IfAny} from '../index';
declare const _any: any;
// `IfAny` should return `true`/`false` if only `T` is specified
expectType<IfAny<any>>(true);
expectType<IfAny<string>>(false);
expectType<IfAny<any, 'T', 'F'>>('T');
expectType<IfAny<string, 'T', 'F'>>('F');
// Missing generic parameter
expectError<IfAny>(_any);