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