- [ 프로그래밍언어/typescript ]4. First of Array2023-08-09 00:54:29type First = any /* _____________ 테스트 케이스 _____________ */ import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect, Expect 123>>, Expect, Expect, ] type errors = [ // @ts-expect-error First, // @ts-expect-error First, ] 키워드1. 첫 번째 요소의 값을 가져오면서, 빈 배열인 경우 never을 반환하는 타입 First에서 는 제네릭 타입 매개변수 T를 선언한다는 의미로, any[] 또는 그 하위 타입을 확장하도록 제합니다. 배열의 시작점의 값을 가져오는 동시에, 빈 배열인 경우 never를..
- [ 프로그래밍언어/typescript ]3. Tuple of Object2023-08-09 00:35:21type TupleToObject = any /* _____________ 테스트 케이스 _____________ */ import type { Equal, Expect } from '@type-challenges/utils' const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const const tupleNumber = [1, 2, 3, 4] as const const tupleMix = [1, '2', 3, '4'] as const type cases = [ Expect, Expect, Expect, ] // @ts-expect-error type error = TupleToObject 키워드1. 튜플 https://yamoo9.gitbook...
- [ 프로그래밍언어/typescript ]2. Readonly2023-08-02 02:09:40type MyReadonly = any /* _____________ 테스트 케이스 _____________ */ import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect, ] interface Todo1 { title: string description: string completed: boolean meta: { author: string } } 키워드1. Readonly 읽기전용 Readonly 타입 매핑을 이용하여 T 타입을 받고 그 타입의 모든 속성을 readonly로 지정하는 Readonly라는 타입이 있습니다. 여기에 실제로 이걸 사용하는 데모가 나와 있습니다: 따라서, any는 모든 속성을 readon..
- [ 프로그래밍언어/typescript ]1. Pick2023-07-22 19:17:1600004-easy-pick /* 4 - Pick ------- by Anthony Fu (@antfu) #쉬움 #union #built-in ### 질문 `T`에서 `K` 프로퍼티만 선택해 새로운 오브젝트 타입을 만드는 내장 제네릭 `Pick`을 이를 사용하지 않고 구현하세요. > GitHub에서 보기: https://tsch.js.org/4/ko */ /* _____________ 여기에 코드 입력 _____________ */ type MyPick = ; /* _____________ 테스트 케이스 _____________ */ import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect, Expect, // @t..