Skip to content

Commit 23f641c

Browse files
committed
First attempt
1 parent eb9252e commit 23f641c

22 files changed

+100
-56
lines changed

src/lib/es5.d.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ interface ObjectConstructor {
204204
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
205205
* @param o Object on which to lock the attributes.
206206
*/
207-
freeze<T extends {[idx: string]: U | null | undefined | object}, U extends string | bigint | number | boolean | symbol>(o: T): Readonly<T>;
207+
freeze<T extends { [idx: string]: U | null | undefined | object }, U extends string | bigint | number | boolean | symbol>(o: T): Readonly<T>;
208208

209209
/**
210210
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
@@ -1131,6 +1131,13 @@ interface JSON {
11311131
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
11321132
*/
11331133
stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
1134+
/**
1135+
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
1136+
* @param value A JavaScript value, usually an object or array, to be converted.
1137+
* @param replacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.
1138+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
1139+
*/
1140+
stringify(value: Function | Symbol | undefined, replacer?: (number | string)[] | null, space?: string | number): undefined;
11341141
}
11351142

11361143
/**
@@ -1525,11 +1532,11 @@ interface Promise<T> {
15251532
*/
15261533
type Awaited<T> =
15271534
T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode
1528-
T extends object & { then(onfulfilled: infer F, ...args: infer _): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
1529-
F extends ((value: infer V, ...args: infer _) => any) ? // if the argument to `then` is callable, extracts the first argument
1530-
Awaited<V> : // recursively unwrap the value
1531-
never : // the argument to `then` was not callable
1532-
T; // non-object or non-thenable
1535+
T extends object & { then(onfulfilled: infer F, ...args: infer _): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
1536+
F extends ((value: infer V, ...args: infer _) => any) ? // if the argument to `then` is callable, extracts the first argument
1537+
Awaited<V> : // recursively unwrap the value
1538+
never : // the argument to `then` was not callable
1539+
T; // non-object or non-thenable
15331540

15341541
interface ArrayLike<T> {
15351542
readonly length: number;

tests/baselines/reference/completionsStringMethods.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@
10781078
"target": {
10791079
"fileName": "lib.d.ts",
10801080
"textSpan": {
1081-
"start": 18451,
1081+
"start": 18453,
10821082
"length": 28
10831083
}
10841084
}
@@ -1101,7 +1101,7 @@
11011101
"target": {
11021102
"fileName": "lib.d.ts",
11031103
"textSpan": {
1104-
"start": 18451,
1104+
"start": 18453,
11051105
"length": 28
11061106
}
11071107
}

tests/baselines/reference/controlFlowPropertyDeclarations.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ export class HTMLtoJSX {
232232
>whitespace : Symbol(whitespace, Decl(controlFlowPropertyDeclarations.ts, 121, 50))
233233

234234
return '{' + JSON.stringify(whitespace) + '}';
235-
>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
235+
>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
236236
>JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
237-
>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
237+
>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
238238
>whitespace : Symbol(whitespace, Decl(controlFlowPropertyDeclarations.ts, 121, 50))
239239

240240
});

tests/baselines/reference/controlFlowPropertyDeclarations.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ export class HTMLtoJSX {
316316
>'{' + JSON.stringify(whitespace) : string
317317
>'{' : "{"
318318
>JSON.stringify(whitespace) : string
319-
>JSON.stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; }
319+
>JSON.stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; (value: Function | Symbol, replacer?: (string | number)[], space?: string | number): undefined; }
320320
>JSON : JSON
321-
>stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; }
321+
>stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; (value: Function | Symbol, replacer?: (string | number)[], space?: string | number): undefined; }
322322
>whitespace : string
323323
>'}' : "}"
324324

tests/baselines/reference/destructuringInitializerContextualTypeFromContext.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ const Child: SFC<Props> = ({
5151

5252
}) => `name: ${name} props: ${JSON.stringify(props)}`;
5353
>name : Symbol(name, Decl(destructuringInitializerContextualTypeFromContext.ts, 15, 13))
54-
>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
54+
>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
5555
>JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
56-
>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
56+
>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
5757
>props : Symbol(props, Decl(destructuringInitializerContextualTypeFromContext.ts, 16, 21))
5858

5959
// Repro from #29189

tests/baselines/reference/destructuringInitializerContextualTypeFromContext.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ const Child: SFC<Props> = ({
5050
>`name: ${name} props: ${JSON.stringify(props)}` : string
5151
>name : "Apollo" | "Artemis" | "Dionysus" | "Persephone"
5252
>JSON.stringify(props) : string
53-
>JSON.stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; }
53+
>JSON.stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; }
5454
>JSON : JSON
55-
>stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; }
55+
>stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; }
5656
>props : {}
5757

5858
// Repro from #29189

tests/baselines/reference/destructuringParameterDeclaration4.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
4141
a1(...array2); // Error parameter type is (number|string)[]
4242
~~~~~~
4343
!!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'?
44-
!!! related TS2728 /.ts/lib.es5.d.ts:1495:13: 'Array' is declared here.
44+
!!! related TS2728 /.ts/lib.es5.d.ts:1502:13: 'Array' is declared here.
4545
a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]]
4646
~~~~~~~~
4747
!!! error TS2322: Type 'string' is not assignable to type '[[any]]'.

tests/baselines/reference/destructuringTuple.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ tests/cases/compiler/destructuringTuple.ts(11,60): error TS2769: No overload mat
3333
!!! error TS2769: Overload 2 of 3, '(callbackfn: (previousValue: [], currentValue: number, currentIndex: number, array: number[]) => [], initialValue: []): []', gave the following error.
3434
!!! error TS2769: Type 'never[]' is not assignable to type '[]'.
3535
!!! error TS2769: Target allows only 0 element(s) but source may have more.
36-
!!! related TS6502 /.ts/lib.es5.d.ts:1460:24: The expected type comes from the return type of this signature.
37-
!!! related TS6502 /.ts/lib.es5.d.ts:1466:27: The expected type comes from the return type of this signature.
36+
!!! related TS6502 /.ts/lib.es5.d.ts:1467:24: The expected type comes from the return type of this signature.
37+
!!! related TS6502 /.ts/lib.es5.d.ts:1473:27: The expected type comes from the return type of this signature.
3838
~~
3939
!!! error TS2769: No overload matches this call.
4040
!!! error TS2769: Overload 1 of 2, '(...items: ConcatArray<never>[]): never[]', gave the following error.

tests/baselines/reference/duplicateNumericIndexers.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tests/cases/conformance/types/members/duplicateNumericIndexers.ts(25,5): error T
1111
tests/cases/conformance/types/members/duplicateNumericIndexers.ts(29,5): error TS2374: Duplicate index signature for type 'number'.
1212
tests/cases/conformance/types/members/duplicateNumericIndexers.ts(30,5): error TS2374: Duplicate index signature for type 'number'.
1313
lib.es5.d.ts(517,5): error TS2374: Duplicate index signature for type 'number'.
14-
lib.es5.d.ts(1481,5): error TS2374: Duplicate index signature for type 'number'.
14+
lib.es5.d.ts(1488,5): error TS2374: Duplicate index signature for type 'number'.
1515

1616

1717
==== tests/cases/conformance/types/members/duplicateNumericIndexers.ts (12 errors) ====

tests/baselines/reference/json.stringify.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ JSON.stringify(value, undefined, 2);
44
JSON.stringify(value, null, 2);
55
JSON.stringify(value, ["a", 1], 2);
66
JSON.stringify(value, (k) => undefined, 2);
7-
JSON.stringify(value, undefined, 2);
7+
JSON.stringify(value, undefined, 2);
8+
JSON.stringify(() => { }, undefined, 2);
9+
JSON.stringify(undefined, undefined, 2);
810

911
//// [json.stringify.js]
1012
var value = null;
@@ -13,3 +15,5 @@ JSON.stringify(value, null, 2);
1315
JSON.stringify(value, ["a", 1], 2);
1416
JSON.stringify(value, function (k) { return undefined; }, 2);
1517
JSON.stringify(value, undefined, 2);
18+
JSON.stringify(function () { }, undefined, 2);
19+
JSON.stringify(undefined, undefined, 2);

0 commit comments

Comments
 (0)