Type Challenges Judge

Mutable Keys

提出詳細

type MutableKeys<T, K extends keyof T = keyof T> = K extends K ? Equal<Readonly<Pick<T, K>>, Pick<T, K>> extends true ? never : K : never
提出日時2024-09-12 15:14:54
問題Mutable Keys
ユーザーookkoouu
ステータスAccepted
テストケース
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>>, ]