일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- Conditional Types
- Array.prototype.push
- 노드 교과서 개정2판
- 와글와글
- TypeScript 타입챌린지
- Mappilogue
- Type Challenge
- 이펙티브 타입스크립트
- node.js
- type challenge omit
- 타입 챌린지 Deep Readonly
- npm
- 타입챌린지
- TypeScript
- 맵필로그
- 백엔드
- 월간cs
- 189-Awaited
- 타입 챌린지 IndexOf
- 타입스크립트
- HTTP
- network
- 해커톤
- 스터디 회고
- nestjs
- typeorm
- 코딩테스트
- 와글와글 해커톤
- 타입챌린지 Readonly2
- 타입 챌린지
- Today
- Total
목록2024/03 (8)
iamkanguk.dev
유튜브 코딩문TV님이 JavaScript 배열 메서드를 직접 구현해보라는 영상을 올려주셨다. 흥미가 생겨서 하나씩 직접 구현을 해보고 영상이랑 비교해보고 싶었다. 그러는 도중 Push 메서드에서 살짝 막혀서 그 과정과 내가 배운 내용에 대해서 한번 정리해보려고 한다. Push 메서드? JavaScript에서 Push 메서드는 배열의 끝에 하나 이상의 요소를 추가하고, 배열의 새로운 길이를 반환한다. 그리고 하나의 요소가 아닌 여러개의 요소를 Push 할 수 있다. (ex. .push(1,2,3,4)) 참고로 필자는 Push 메서드가 새로운 배열의 길이를 반환하는지 몰랐다....! MDN에서는 예제와 함께 설명하니 참고하면 좋을 것 같다! 필자가 구현한 Push 메서드 (형편없음) function push..
문제 https://github.com/type-challenges/type-challenges/blob/main/questions/00008-medium-readonly-2/README.md type-challenges/questions/00008-medium-readonly-2/README.md at main · type-challenges/type-challenges Collection of TypeScript type challenges with online judge - type-challenges/type-challenges github.com 정답 // 1번째 방법과 2번째 방법의 차이는 내장 메서드인 Omit을 사용했냐 안했냐의 차이! // 다양하게 구현할 수 있었던 문제였던 것 같음. 하..
문제 https://github.com/type-challenges/type-challenges/blob/main/questions/00003-medium-omit/README.md type-challenges/questions/00003-medium-omit/README.md at main · type-challenges/type-challenges Collection of TypeScript type challenges with online judge - type-challenges/type-challenges github.com 풀이 type MyOmit = { [U in keyof T as U extends K ? never : U]: T[U] } /* _____________ 테스트 케이스 __..
문제 https://github.com/iamkanguk97/type-challenges/blob/main/questions/00189-easy-awaited/README.md 풀이 type MyAwaited = T extends PromiseLike ? R extends PromiseLike ? MyAwaited : R : never; /* _____________ 테스트 케이스 _____________ */ import type { Equal, Expect } from '@type-challenges/utils' type X = Promise type Y = Promise type Z = Promise type Z1 = Promise type T = { then: (onfulfilled: (arg: ..
최근에 타입 챌린지를 풀면서 T extends A ? B : C와 같은 코드를 많이 작성했던 것 같다. 그런데 막상 개념은 모르고 그냥 이런 느낌이구나~ 라고만 알면서 문제를 풀었던 것 같아서 찝찝했는데 공부를 하던 중 좋은 글을 확인해서 공부한 내용을 블로그에 적어보려고 한다. 참고한 블로그 링크는 아래 참고자료에 첨부 할 예정이니 참고하시면 좋을 것 같다! 1. 타입은 가능한 값의 집합이다? 타입은 가능한 값의 집합이다라는 말이 있다. 이 포스팅을 쓰기 전에는 이해가 아예 안됐다. 느낌조차도 오지 않았다 ㅠ 예를 들어 never 타입은 어떤 값도 할당할 수 없는 타입이다. 그래서 공집합({})이라고 말할 수 있다. 그런데 number 타입은 정수, 소수를 할당할 수 있는 타입이다. 이 예시를 보면 충..
문제 https://github.com/type-challenges/type-challenges/blob/main/questions/00014-easy-first/README.md type arr1 = ['a', 'b', 'c'] type arr2 = [3, 2, 1] type head1 = First // expected to be 'a' type head2 = First // expected to be 3 Expect, Expect 123>>, Expect, Expect, 풀이 // S1 type First = T extends [] ? never : T[0]; // S2 type First = T["length"] extends 0 ? never : T[0]; // S3 type First = T ..
문제 https://github.com/type-challenges/type-challenges/blob/main/questions/00011-easy-tuple-to-object/README.ko.md const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const; type result = TupleToObject // expected { tesla: 'tesla', 'model 3': 'model 3', 'model X': 'model X', 'model Y': 'model Y'} 풀이 type TupleToObject = { [V in T[number]]: V } How to Solve? T extends readonly any[]: any 타..
지금 TS를 사용하면서 백엔드 프로젝트를 진행하고 있는데 TS에 대해 겉핥기 식으로만 알면서 프로젝트를 하다 보니까 잘 사용하지 못하는 것 같다고 판단이 되었다. NestJS 오픈카톡방 커뮤니티에서 공유받아서.. 오늘부터 Type Challenge 라는 GitHub Repository에 들어가서 하루 또는 2일에 2문제씩 문제를 조금이나마 풀어보려고 한다. 문제 - https://github.com/type-challenges/type-challenges/blob/main/questions/00004-easy-pick/README.md 풀이 /** * (1) K는 T의 Key-Properties 이다 ==> MyPick * (2) K를 순회한다 ==> [B in K] (B는 K를 순회하면서 저장하는 변수..