-
-
Notifications
You must be signed in to change notification settings - Fork 502
/
replace.ts
28 lines (25 loc) · 799 Bytes
/
replace.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import {expectType} from 'tsd';
import type {Replace} from '../index';
declare function replace<
Input extends string,
Search extends string,
Replacement extends string,
>(
input: Input,
search: Search,
replacement: Replacement
): Replace<Input, Search, Replacement>;
declare function replaceAll<
Input extends string,
Search extends string,
Replacement extends string,
>(
input: Input,
search: Search,
replacement: Replacement
): Replace<Input, Search, Replacement, {all: true}>;
expectType<'hello 🦄'>(replace('hello ?', '?', '🦄'));
expectType<'hello ❓?'>(replace('hello ??', '?', '❓'));
expectType<'10-42-00'>(replaceAll('10:42:00', ':', '-'));
expectType<'userName'>(replaceAll('__userName__', '__', ''));
expectType<'MyCoolTitle'>(replaceAll('My Cool Title', ' ', ''));