Mutable Keys
Implement the advanced util type MutableKeys
For example:
type Keys = MutableKeys<{ readonly foo: string; bar: number }>;
// expected to be “bar”
查看测试用例
import type { Equal, Expect } from '@type-challenges/utils'
type cases = [
Expect<Equal<MutableKeys<{ a: number, readonly b: string }>, 'a'>>,
Expect<Equal<MutableKeys<{ a: undefined, readonly b: undefined }>, 'a'>>,
Expect<Equal<MutableKeys<{ a: undefined, readonly b?: undefined, c: string, d: null }>, 'a' | 'c' | 'd'>>,
Expect<Equal<MutableKeys<{}>, never>>,
]