Type Challenges Judge

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>>, ]