StartsWith
提出詳細
type StartsWith<T extends string, U extends string> = U extends `${infer U1}${infer U2}` ? T extends `${U1}${infer T2}` ? StartsWith<T2,U2> : false : true
| 提出日時 | 2023-09-15 13:13:36 | 
|---|---|
| 問題 | StartsWith | 
| ユーザー | sankantsu | 
| ステータス | 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>>, ]