Type Challenges Judge

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>>, ]