00007-easy-readonly

Back

type MyReadonly = { readonly [K in keyof T]: T[K]; };

Solution by asylbekduldiev #36162

type MyReadonly<T> = {
  readonly [i in keyof T]: T[i]
}

Solution by AleksandrShcherbackov #36139

// 你的答案

type MyReadonly<T> = {
  readonly [K in keyof T]: T[K];
}

Solution by louzhaoyan #36129

type MyReadonly<T> = {
  readonly [K in keyof T]: T[K]
}

Solution by EvgeniyKoch #36119

type MyReadonly<T> = { readonly [K in keyof T]: T[K]}

Solution by jhsung23 #36091

type MyReadonly<T> = {
  readonly [k in keyof T] : T[k]
}

Solution by tungulin #36047

type MyReadonly<T> = {readonly [P in keyof T]: T[P]}

Solution by karazyabko #36023

type MyReadonly<T> = {
  readonly[S in keyof T]: T[S]
}

Solution by KimKyuHoi #36011

// your answers
type MyReadonly<T> = {
  readonly [K in keyof T]: T[K];
};

Solution by krokerdile #35986

// your answers

/* _____________ Your Code Here _____________ */

type MyReadonly<T> = {
  readonly [key in keyof T]: T[key]
}

/* _____________ Test Cases _____________ */
import type { Equal, Expect } from '@type-challenges/utils'

type cases = [
  Expect<Equal<MyReadonly<Todo1>, Readonly<Todo1>>>,
]

interface Todo1 {
  title: string
  description: string
  completed: boolean
  meta: {
    author: string
  }
}

Solution by pytest5 #35897

{ readonly [P in keyof T]: T[P] }

Solution by dienphamvan #35881

type MyReadonly<T> = {
  readonly [K in keyof T]: T[K]
}

Solution by Yunjaejo #35865

// 你的答案
type MyReadonly<T> = {
  readonly [P in keyof T]: T[P]
}

Solution by reonce #35817

// 你的答案
type MyReadonly<T> = {
  readonly [key in keyof T]: T[key]
}

Solution by song4613107 #35783

//type cases = [
  Expect<Equal<MyReadonly<Todo1>, Readonly<Todo1>>>,
]

Solution by hatbann #35757

type MyReadonly<T> = {
  readonly [K in keyof T]: T[K]
}

Solution by XenoPOMP #35739

type MyReadonly<T> = {readonly[K in keyof T]: T[K]}

Solution by Sensuele #35735

type myReadonly<T> = {
  readonly [P in keyof T]: T[P];
}

readonly修饰对应的属性

Solution by Yangkro #35710

type MyReadonly<T extends object> = {
  readonly [P in keyof T]: T[P]
}

Solution by criszst #35704

type MyReadonly<T> = {
  readonly [P in keyof T]: T[P]
} 

Solution by thukyaw11 #35524

// your answers
type MyReadOnly<T> = { [Key in keyof T] : T[Key]};

Solution by Sathiyapramod #35502

// 여기 풀이를 입력하세요
type MyReadonly<T> = { readonly [key in keyof T]: T[key] }

Solution by Gwanghun-Im #35488

type MyReadonly<T> = { readonly [key in keyof T]: T[key] }

Solution by gangnamssal #35465

type MyReadonly<T> = {
  readonly [k in keyof T] : T[k]
}

Solution by RanungPark #35429

// 你的答案
type MyReadonly<T> = {
  readonly [key in keyof T] : T[key]
}

Solution by dixiaioping #35382

type MyReadonly<T> = {
 readonly [key in keyof T]: T[key]
} 

Solution by SB-SLIM #35375

type MyReadonly<T> = {
  readonly [key in keyof T]: T[key]
}

Solution by gyeounjeong #35350

type MyReadonly = {readonly [key in keyof T]: T[key]}

Solution by kvyy #35317

type MyReadonly<T extends Record<string, any>> = { readonly [K in keyof T]: T[K] }

Solution by vaclock #35269

type MyReadonly<T> = {
  readonly [Property in keyof T]: T[Property]
}

Solution by Muntazir-sd #35193