Length of String
提出詳細
type LengthOfString<S extends string, A extends unknown[] = []> = S extends `${infer _}${infer Tail}` ? LengthOfString<Tail, [...A, unknown]> : A['length'];
提出日時 | 2023-06-01 03:39:05 |
---|---|
問題 | Length of String |
ユーザー | mrsekut |
ステータス | 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>>, ]