String to Number
提出詳細
type ToNumber<S extends string> = S extends `${infer N extends number}` ? N : never
提出日時 | 2023-08-10 14:40:29 |
---|---|
問題 | String to Number |
ユーザー | ookkoouu |
ステータス | 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>>, ]