EndsWith
提出詳細
type Reverse<T extends string, O extends string = ""> = T extends `${infer L}${infer R}` ? Reverse<R, `${L}${O}`> : T extends string ? `${T}${O}` : O type EndsWith<T extends string, U extends string> = Reverse<T> extends `${Reverse<U>}${infer Rest}` ? true : false
| 提出日時 | 2024-09-10 16:34:01 | 
|---|---|
| 問題 | EndsWith | 
| ユーザー | ookkoouu | 
| ステータス | Accepted | 
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<EndsWith<'abc', 'bc'>, true>>, Expect<Equal<EndsWith<'abc', 'abc'>, true>>, Expect<Equal<EndsWith<'abc', 'd'>, false>>, ]