holdanddeepdive / typescript-study

4 stars 0 forks source link

[2주차] Easy 풀이 #3

Open sbyeol3 opened 1 year ago

sbyeol3 commented 1 year ago
title solved
4-pick
7-read only
11-tuple 🏷
14-first of array 🏷
18-length of tuple 🏷
43-exclude
189-awaited 🏷
268-if
533-concat
898-includes 💡- myEqual
3057-push
3060-unshift
3312-parameters 🏷

풀이 link

✅: 해결 🏷: 해답 열람 후 다시 풀었음 💡: 다시 볼 필요 있음

humonnom commented 1 year ago

💡type-level equality check

1. 쌍방향 extends 체크

type Equal<T, U> = T extends U ? (U extends T ? true : false) : false;

2.

type-level equality operator

export type Equals<X, Y> =
    (<T>() => T extends X ? 1 : 2) extends
    (<T>() => T extends Y ? 1 : 2) ? true : false;