type-fest/test-d/non-empty-object.ts
kkmuffme 98bb74d3cb
Add NonEmptyObject type (#623)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
2023-08-25 13:19:25 +02:00

30 lines
602 B
TypeScript

import {expectNever, expectType} from 'tsd';
import type {NonEmptyObject, RequireAtLeastOne} from '../index';
type TestType1 = {
a: string;
b: boolean;
};
type TestType2 = {
a?: string;
b?: boolean;
};
type TestType3 = {
a: string;
b?: boolean;
};
type TestType4 = {};
declare const test1: NonEmptyObject<TestType1>;
declare const test2: NonEmptyObject<TestType2>;
declare const test3: NonEmptyObject<TestType3>;
declare const test4: NonEmptyObject<TestType4>;
expectType<TestType1>(test1);
expectType<RequireAtLeastOne<TestType2>>(test2);
expectType<TestType3>(test3);
expectNever(test4);