type-fest/test-d/conditional-keys.ts
2022-08-29 15:23:09 +07:00

16 lines
448 B
TypeScript

import {expectType} from 'tsd';
import type {ConditionalKeys} from '../index';
type Example = {
a: string;
b?: string | number;
c?: string;
d: Record<string, unknown>;
};
declare const exampleConditionalKeys: ConditionalKeys<Example, string>;
expectType<'a'>(exampleConditionalKeys);
declare const exampleConditionalKeysWithUndefined: ConditionalKeys<Example, string | undefined>;
expectType<'a' | 'c'>(exampleConditionalKeysWithUndefined);