πŸ’™ Typescript/type-challenges

[TS] type-challenges : 13. Hello World

선달 2023. 6. 28. 23:02
λ°˜μ‘ν˜•

문제

Hello, World!

Type Challengesμ—μ„œλŠ” νƒ€μž… 단언(assertion)을 ν•˜κΈ° μœ„ν•΄ 자체적인 νƒ€μž… μ‹œμŠ€ν…œμ„ μ‚¬μš©ν•©λ‹ˆλ‹€.

이 κ³Όμ œμ—μ„œλŠ”, μ•„λž˜μ˜ μ½”λ“œλ₯Ό λ³€κ²½ν•΄μ„œ ν…ŒμŠ€νŠΈ μ½”λ“œλ₯Ό ν†΅κ³Όν•˜μ„Έμš”. (νƒ€μž… 체크 μ—λŸ¬ μ—†μŒ).

  // string이 λ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€.
  type HelloWorld = any
  // μ•„λž˜μ˜ ν…ŒμŠ€νŠΈκ°€ ν†΅κ³Όν•˜λ„λ‘ λ§Œλ“œμ„Έμš”.
  type test = Expect<Equal<HelloWorld, string>>

Take the Challenge λ²„νŠΌμ„ ν΄λ¦­ν•΄μ„œ 코딩을 μ‹œμž‘ν•˜μ„Έμš”! Happy Hacking!

 

 

풀이

/* _____________ 여기에 μ½”λ“œ μž…λ ₯ _____________ */

type HelloWorld = string // expected to be a string

/* _____________ ν…ŒμŠ€νŠΈ μΌ€μ΄μŠ€ _____________ */
import type { Equal, Expect, NotAny } from '@type-challenges/utils'

type cases = [
  Expect<NotAny<HelloWorld>>,
  Expect<Equal<HelloWorld, string>>,
]

 

 

 μΆœμ²˜

https://github.com/type-challenges/type-challenges/blob/main/questions/00013-warm-hello-world/README.ko.md

 

 

λ°˜μ‘ν˜•

'πŸ’™ Typescript > type-challenges' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

[TS] type-challenges: 18. Length of Tuple  (0) 2023.07.05
[TS] type-challenges: 14. First of Array  (0) 2023.07.04
[TS] type-challenges : 11. Tuple to Object  (0) 2023.07.03
[TS] type-challenges : 7. Readonly  (0) 2023.06.28
[TS] type-challenges : 4. Pick  (0) 2023.06.28