Skip to content

Commit 78808a8

Browse files
committed
Updated ES6 declarations for Promise, updated baselines
1 parent cde3ed0 commit 78808a8

98 files changed

Lines changed: 478 additions & 444 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/lib/es6.d.ts

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,41 @@ interface SymbolConstructor {
5151
isConcatSpreadable: symbol;
5252

5353
/**
54-
* A method that returns the default iterator for an object.Called by the semantics of the
54+
* A method that returns the default iterator for an object. Called by the semantics of the
5555
* for-of statement.
5656
*/
5757
iterator: symbol;
5858

59+
/**
60+
* A regular expression method that matches the regular expression against a string. Called
61+
* by the String.prototype.match method.
62+
*/
63+
match: symbol;
64+
65+
/**
66+
* A regular expression method that replaces matched substrings of a string. Called by the
67+
* String.prototype.replace method.
68+
*/
69+
replace: symbol;
70+
71+
/**
72+
* A regular expression method that returns the index within a string that matches the
73+
* regular expression. Called by the String.prototype.search method.
74+
*/
75+
search: symbol;
76+
77+
/**
78+
* A function valued property that is the constructor function that is used to create
79+
* derived objects.
80+
*/
81+
species: symbol;
82+
83+
/**
84+
* A regular expression method that splits a string at the indices that match the regular
85+
* expression. Called by the String.prototype.split method.
86+
*/
87+
split: symbol;
88+
5989
/**
6090
* A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
6191
* abstract operation.
@@ -3542,6 +3572,16 @@ declare module Reflect {
35423572
function setPrototypeOf(target: any, proto: any): boolean;
35433573
}
35443574

3575+
interface IPromise<T> {
3576+
/**
3577+
* Attaches callbacks for the resolution and/or rejection of the Promise.
3578+
* @param onfulfilled The callback to execute when the Promise is resolved.
3579+
* @param onrejected The callback to execute when the Promise is rejected.
3580+
* @returns A Promise for the completion of which ever callback is executed.
3581+
*/
3582+
then<TResult>(onfulfilled?: (value: T) => TResult | IPromise<TResult>, onrejected?: (reason: any) => TResult | IPromise<TResult>): IPromise<TResult>;
3583+
}
3584+
35453585
/**
35463586
* Represents the completion of an asynchronous operation
35473587
*/
@@ -3552,14 +3592,16 @@ interface Promise<T> {
35523592
* @param onrejected The callback to execute when the Promise is rejected.
35533593
* @returns A Promise for the completion of which ever callback is executed.
35543594
*/
3555-
then<TResult>(onfulfilled?: (value: T) => TResult | Promise<TResult>, onrejected?: (reason: any) => TResult | Promise<TResult>): Promise<TResult>;
3595+
then<TResult>(onfulfilled?: (value: T) => TResult | IPromise<TResult>, onrejected?: (reason: any) => TResult | IPromise<TResult>): Promise<TResult>;
35563596

35573597
/**
35583598
* Attaches a callback for only the rejection of the Promise.
35593599
* @param onrejected The callback to execute when the Promise is rejected.
35603600
* @returns A Promise for the completion of the callback.
35613601
*/
3562-
catch(onrejected?: (reason: any) => T | Promise<T>): Promise<T>;
3602+
catch(onrejected?: (reason: any) => T | IPromise<T>): Promise<T>;
3603+
3604+
[Symbol.toStringTag]: string;
35633605
}
35643606

35653607
interface PromiseConstructor {
@@ -3570,37 +3612,27 @@ interface PromiseConstructor {
35703612

35713613
/**
35723614
* Creates a new Promise.
3573-
* @param init A callback used to initialize the promise. This callback is passed two arguments:
3615+
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
35743616
* a resolve callback used resolve the promise with a value or the result of another promise,
35753617
* and a reject callback used to reject the promise with a provided reason or error.
35763618
*/
3577-
new <T>(init: (resolve: (value?: T | Promise<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
3578-
3579-
<T>(init: (resolve: (value?: T | Promise<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
3619+
new <T>(executor: (resolve: (value?: T | IPromise<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
35803620

35813621
/**
35823622
* Creates a Promise that is resolved with an array of results when all of the provided Promises
35833623
* resolve, or rejected when any Promise is rejected.
35843624
* @param values An array of Promises.
35853625
* @returns A new Promise.
35863626
*/
3587-
all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
3588-
3589-
/**
3590-
* Creates a Promise that is resolved with an array of results when all of the provided Promises
3591-
* resolve, or rejected when any Promise is rejected.
3592-
* @param values An array of values.
3593-
* @returns A new Promise.
3594-
*/
3595-
all(values: Promise<void>[]): Promise<void>;
3627+
all<T>(values: Iterable<T | IPromise<T>>): Promise<T[]>;
35963628

35973629
/**
35983630
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
35993631
* or rejected.
36003632
* @param values An array of Promises.
36013633
* @returns A new Promise.
36023634
*/
3603-
race<T>(values: (T | Promise<T>)[]): Promise<T>;
3635+
race<T>(values: Iterable<T | IPromise<T>>): Promise<T>;
36043636

36053637
/**
36063638
* Creates a new rejected promise for the provided reason.
@@ -3621,13 +3653,15 @@ interface PromiseConstructor {
36213653
* @param value A promise.
36223654
* @returns A promise whose internal state matches the provided promise.
36233655
*/
3624-
resolve<T>(value: T | Promise<T>): Promise<T>;
3656+
resolve<T>(value: T | IPromise<T>): Promise<T>;
36253657

36263658
/**
36273659
* Creates a new resolved promise .
36283660
* @returns A resolved promise.
36293661
*/
36303662
resolve(): Promise<void>;
3663+
3664+
[Symbol.species]: Function;
36313665
}
36323666

36333667
declare var Promise: PromiseConstructor;

tests/baselines/reference/callWithSpreadES6.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc");
9494
>a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3))
9595

9696
(<Function>xa[1].foo)(...[1, 2, "abc"]);
97-
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1325, 1))
97+
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1355, 1))
9898
>xa[1].foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13))
9999
>xa : Symbol(xa, Decl(callWithSpreadES6.ts, 11, 3))
100100
>foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13))

tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function f() {
55

66
if (Math.random()) {
77
>Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
8-
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1664, 1))
8+
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1))
99
>random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
1010

1111
let arguments = 100;

tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function f() {
88

99
if (Math.random()) {
1010
>Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
11-
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1664, 1))
11+
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1))
1212
>random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
1313

1414
const arguments = 100;

tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function f() {
88

99
if (Math.random()) {
1010
>Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
11-
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1664, 1))
11+
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1))
1212
>random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
1313

1414
return () => arguments[0];

tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function f() {
99

1010
if (Math.random()) {
1111
>Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
12-
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1664, 1))
12+
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1))
1313
>random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
1414

1515
return () => arguments[0];

tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function f() {
99

1010
if (Math.random()) {
1111
>Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
12-
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1664, 1))
12+
>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1694, 1))
1313
>random : Symbol(Math.random, Decl(lib.d.ts, 608, 38))
1414

1515
return () => arguments;

tests/baselines/reference/for-of13.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ var v: string;
44

55
for (v of [""].values()) { }
66
>v : Symbol(v, Decl(for-of13.ts, 0, 3))
7-
>[""].values : Symbol(Array.values, Decl(lib.d.ts, 1423, 37))
8-
>values : Symbol(Array.values, Decl(lib.d.ts, 1423, 37))
7+
>[""].values : Symbol(Array.values, Decl(lib.d.ts, 1453, 37))
8+
>values : Symbol(Array.values, Decl(lib.d.ts, 1453, 37))
99

tests/baselines/reference/for-of18.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class StringIterator {
2323
}
2424
[Symbol.iterator]() {
2525
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
26-
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11))
26+
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11))
2727
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
2828

2929
return this;

tests/baselines/reference/for-of19.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FooIterator {
2828
}
2929
[Symbol.iterator]() {
3030
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
31-
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1262, 11))
31+
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11))
3232
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
3333

3434
return this;

0 commit comments

Comments
 (0)