๋ฐ์ํ
๋ฌธ์
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>>,
]
์ถ์ฒ
๋ฐ์ํ
'๐ 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 |