type-fest/test-d/has-writable-keys.ts
Trevor Florence a8d6ad0f79
Add HasReadonlyKeys and HasWritableKeys types (#640)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
2023-07-09 13:41:10 +02:00

30 lines
602 B
TypeScript

import {expectType} from 'tsd';
import type {HasWritableKeys} from '../index';
type TestType1 = {
a: string;
readonly b: boolean;
};
type TestType2 = {
readonly a: string;
readonly b: boolean;
};
type TestType3 = {
a: string;
b: boolean;
};
type HasWritableKeys1 = HasWritableKeys<TestType1>;
type HasWritableKeys2 = HasWritableKeys<TestType2>;
type HasWritableKeys3 = HasWritableKeys<TestType3>;
declare const test1: HasWritableKeys1;
declare const test2: HasWritableKeys2;
declare const test3: HasWritableKeys3;
expectType<true>(test1);
expectType<false>(test2);
expectType<true>(test3);