Skip to content

Commit 01a65bd

Browse files
committed
esnext
1 parent 7dc4916 commit 01a65bd

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

build/replacement.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ export const replacement = new Map([
4444
["lib.es2018.asyncgenerator.d.ts", new Set(["AsyncGenerator"])],
4545
["lib.es2018.asynciterable.d.ts", new Set(["AsyncIterator"])],
4646
["lib.es2019.object.d.ts", new Set(["ObjectConstructor"])],
47+
["lib.esnext.promise.d.ts", new Set(["AggregateError"])],
48+
["lib.esnext.string.d.ts", new Set(["String"])],
4749
]);

lib/lib.esnext.promise.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference no-default-lib="true"/>
2+
3+
interface AggregateError extends Error {
4+
errors: unknown[];
5+
}
6+
7+
declare var AggregateError: AggregateErrorConstructor;

lib/lib.esnext.string.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// <reference no-default-lib="true"/>
2+
3+
interface String {
4+
/**
5+
* Replace all instances of a substring in a string, using a regular expression or search string.
6+
* @param searchValue A string to search for.
7+
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
8+
*/
9+
replaceAll(searchValue: string | RegExp, replaceValue: string): string;
10+
11+
/**
12+
* Replace all instances of a substring in a string, using a regular expression or search string.
13+
* @param searchValue A string to search for.
14+
* @param replacer A function that returns the replacement text.
15+
*/
16+
replaceAll(
17+
searchValue: string | RegExp,
18+
// TODO: possible improvement in TS4.2
19+
replacer: (substring: string, ...args: (string | number)[]) => string
20+
): string;
21+
}

tests/esnext.promise.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path="../dist/lib/lib.esnext.d.ts" />
2+
3+
import { expectType } from "tsd";
4+
5+
// AggregateError
6+
{
7+
const e = new AggregateError([1, 2, 3]);
8+
expectType<unknown[]>(e.errors);
9+
}

tests/esnext.string.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path="../dist/lib/lib.esnext.d.ts" />
2+
3+
import { expectType } from "tsd";
4+
5+
// String
6+
"foobar".replaceAll(/foo/g, (substr, p1, p2) => {
7+
expectType<string>(substr);
8+
expectType<string | number>(p1);
9+
expectType<string | number>(p2);
10+
return "";
11+
});

0 commit comments

Comments
 (0)