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