mirror of
https://github.com/sindresorhus/type-fest.git
synced 2026-02-01 15:59:43 +00:00
25 lines
739 B
TypeScript
25 lines
739 B
TypeScript
import {expectError, expectAssignable} from 'tsd';
|
|
import type {RequireAllOrNone} from '../index';
|
|
|
|
type SystemMessages = {
|
|
default: string;
|
|
|
|
macos: string;
|
|
linux: string;
|
|
|
|
optional?: string;
|
|
};
|
|
|
|
type ValidMessages = RequireAllOrNone<SystemMessages, 'macos' | 'linux'>;
|
|
const test = (_: ValidMessages): void => {}; // eslint-disable-line @typescript-eslint/no-empty-function
|
|
|
|
test({default: 'hello'});
|
|
test({macos: 'yo', linux: 'sup', optional: 'howdy', default: 'hello'});
|
|
|
|
expectError(test({}));
|
|
expectError(test({macos: 'hey', default: 'hello'}));
|
|
expectError(test({linux: 'hey', default: 'hello'}));
|
|
|
|
declare const oneWithoutKeys: RequireAllOrNone<{a: number; b: number}>;
|
|
expectAssignable<{a: number; b: number}>(oneWithoutKeys);
|