Type Challenges Judge

Length of String

提出詳細

type Split<S extends string, Res extends string[] = []> = S extends `${infer L}${infer R}` ? Split<R, [...Res, L]> : Res type LengthOfString<S extends string> = Split<S>["length"]
提出日時2023-08-08 17:45:04
問題Length of String
ユーザーookkoouu
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<LengthOfString<''>, 0>>, Expect<Equal<LengthOfString<'kumiko'>, 6>>, Expect<Equal<LengthOfString<'reina'>, 5>>, Expect<Equal<LengthOfString<'Sound! Euphonium'>, 16>>, ]