Readonly 2
提出詳細
type MyReadonly2<T, K extends keyof T = keyof T> = { readonly [P in K]: T[P] } & Omit<T, K>
提出日時 | 2022-06-29 11:13:38 |
---|---|
問題 | Readonly 2 |
ユーザー | tekihei2317 |
ステータス | Accepted |
import type { Alike, Expect } from '@type-challenges/utils' type cases = [ Expect<Alike<MyReadonly2<Todo1>, Readonly<Todo1>>>, Expect<Alike<MyReadonly2<Todo1, 'title' | 'description'>, Expected>>, Expect<Alike<MyReadonly2<Todo2, 'title' | 'description'>, Expected>>, ] interface Todo1 { title: string description?: string completed: boolean } interface Todo2 { readonly title: string description?: string completed: boolean } interface Expected { readonly title: string readonly description?: string completed: boolean }