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

29 lines
814 B
TypeScript

import {expectType} from 'tsd';
import type {ConditionalExcept, Primitive} from '../index';
class Awesome {
name!: string;
successes!: number;
failures!: bigint;
run(): void {
// Empty
}
}
type Example = {
a: string;
b?: string | number;
c?: string;
d: Record<string, unknown>;
};
declare const exampleConditionalExcept: ConditionalExcept<Example, string>;
expectType<{b?: string | number; c?: string; d: Record<string, unknown>}>(exampleConditionalExcept);
declare const awesomeConditionalExcept: ConditionalExcept<Awesome, Primitive>;
expectType<{run: () => void}>(awesomeConditionalExcept);
declare const exampleConditionalExceptWithUndefined: ConditionalExcept<Example, string | undefined>;
expectType<{b?: string | number; d: Record<string, unknown>}>(exampleConditionalExceptWithUndefined);