Type Challenges Judge

Replace

提出詳細

type Replace<T extends string, U extends string, V extends string> = T extends `${infer Head}${U}${infer Rest}` ? `${Head}${V}${Rest}` : T
提出日時2023-05-04 22:33:45
問題Replace
ユーザーDowanna
ステータスWrong Answer
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Replace<'foobar', 'bar', 'foo'>, 'foofoo'>>, Expect<Equal<Replace<'foobarbar', 'bar', 'foo'>, 'foofoobar'>>, Expect<Equal<Replace<'foobarbar', '', 'foo'>, 'foobarbar'>>, Expect<Equal<Replace<'foobarbar', 'bar', ''>, 'foobar'>>, Expect<Equal<Replace<'foobarbar', 'bra', 'foo'>, 'foobarbar'>>, Expect<Equal<Replace<'', '', ''>, ''>>, ]