Type Challenges Judge

String to Number

提出詳細

type ToNumber<S extends string, A extends readonly 0[] = []> = `${A["length"]}` extends S ? A["length"] :ToNumber<S, [...A, 0]>
提出日時2022-06-28 05:47:36
問題String to Number
ユーザーwaki285
ステータス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>>, ]