Skip to content

Commit

Permalink
Replace: Fix the all option (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonghwanWon committed Jul 3, 2022
1 parent de5e7fc commit 1483de3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/replace.d.ts
Expand Up @@ -62,6 +62,6 @@ export type Replace<
Options extends ReplaceOptions = {},
> = Input extends `${infer Head}${Search}${infer Tail}`
? Options['all'] extends true
? Replace<`${Head}${Replacement}${Tail}`, Search, Replacement, Options>
? `${Head}${Replacement}${Replace<Tail, Search, Replacement, Options>}`
: `${Head}${Replacement}${Tail}`
: Input;
1 change: 1 addition & 0 deletions test-d/replace.ts
Expand Up @@ -26,3 +26,4 @@ expectType<'hello ❓?'>(replace('hello ??', '?', '❓'));
expectType<'10-42-00'>(replaceAll('10:42:00', ':', '-'));
expectType<'userName'>(replaceAll('__userName__', '__', ''));
expectType<'MyCoolTitle'>(replaceAll('My Cool Title', ' ', ''));
expectType<'fobarfobar'>(replaceAll('foobarfoobar', 'ob', 'b'));

0 comments on commit 1483de3

Please sign in to comment.