mirror of
https://github.com/sindresorhus/type-fest.git
synced 2026-01-25 14:57:30 +00:00
18 lines
549 B
TypeScript
18 lines
549 B
TypeScript
import {expectNever, expectAssignable} from 'tsd';
|
|
import type {SingleKeyObject} from '../index.d.ts';
|
|
|
|
const test = <T>(_: SingleKeyObject<T>): void => {}; // eslint-disable-line @typescript-eslint/no-empty-function
|
|
|
|
test({key: 'value'});
|
|
|
|
// @ts-expect-error
|
|
test({});
|
|
// @ts-expect-error
|
|
test({key: 'value', otherKey: 'other value'});
|
|
|
|
declare const validObject: SingleKeyObject<{key: string}>;
|
|
expectAssignable<{key: string}>(validObject);
|
|
|
|
declare const invalidObject: SingleKeyObject<{key1: string; key2: number}>;
|
|
expectNever(invalidObject);
|