mirror of
https://github.com/sindresorhus/type-fest.git
synced 2025-12-08 19:25:05 +00:00
29 lines
814 B
TypeScript
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);
|