StartsWith
提出詳細
type StartsWith< T extends string, U extends string, > = T extends `${infer TF}${infer TT}` ? U extends `${infer UF}${infer UT}` ? Equal<TF, UF> extends true ? StartsWith<TT, UT> : false : true : U extends '' ? true : false;
| 提出日時 | 2023-05-22 14:27:50 | 
|---|---|
| 問題 | StartsWith | 
| ユーザー | mrsekut | 
| ステータス | 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>>, ]