Type Challenges Judge

Get Readonly Keys

提出詳細

type GetReadonlyKeys<T> = keyof { [P in keyof T as Equal<Pick<T, P>, Readonly<Pick<T, P>>> extends true ? P : never]: never }
提出日時2024-09-13 15:51:40
問題Get Readonly Keys
ユーザーookkoouu
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<'title', GetReadonlyKeys<Todo1>>>, Expect<Equal<'title' | 'description', GetReadonlyKeys<Todo2>>>, ] interface Todo1 { readonly title: string description: string completed: boolean } interface Todo2 { readonly title: string readonly description: string completed?: boolean }