String to Number
提出詳細
type ToNumber<S extends string> = S extends `${infer N extends number}` ? N : never
提出日時 | 2023-09-19 04:22:15 |
---|---|
問題 | String to Number |
ユーザー | sankantsu |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<ToNumber<'0'>, 0>>, Expect<Equal<ToNumber<'5'>, 5>>, Expect<Equal<ToNumber<'12'>, 12>>, Expect<Equal<ToNumber<'27'>, 27>>, ]