Type Challenges Judge

StartsWith

提出詳細

type StartsWith<T extends string, U extends string, A extends string = ""> = T extends `${infer Head}${infer Rest}` ? A extends U ? true : StartsWith<Rest, U, `${A}${Head}`> : false
提出日時2025-09-16 04:38:55
問題StartsWith
ユーザーbalckowl
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<StartsWith<'abc', 'ac'>, false>>, Expect<Equal<StartsWith<'abc', 'ab'>, true>>, Expect<Equal<StartsWith<'abc', 'abcd'>, false>>, Expect<Equal<StartsWith<'abc', ''>, true>>, Expect<Equal<StartsWith<'abc', ' '>, false>>, ]