From 268dbfe093ed0e3c0008709f900868a3e1b2897e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Fri, 24 Aug 2018 11:00:59 +0800 Subject: [PATCH 001/101] parse less than token rather than left shift in context of type arguments --- src/compiler/parser.ts | 6 +++++- src/compiler/scanner.ts | 10 ++++++++++ tests/baselines/reference/api/tsserverlibrary.d.ts | 1 + tests/baselines/reference/api/typescript.d.ts | 1 + .../parseGenericArrowRatherThanLeftShift.js | 7 +++++++ .../parseGenericArrowRatherThanLeftShift.symbols | 12 ++++++++++++ .../parseGenericArrowRatherThanLeftShift.types | 8 ++++++++ .../compiler/parseGenericArrowRatherThanLeftShift.ts | 3 +++ 8 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/parseGenericArrowRatherThanLeftShift.js create mode 100644 tests/baselines/reference/parseGenericArrowRatherThanLeftShift.symbols create mode 100644 tests/baselines/reference/parseGenericArrowRatherThanLeftShift.types create mode 100644 tests/cases/compiler/parseGenericArrowRatherThanLeftShift.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 096c3f16354..a76f9eb59b4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1093,6 +1093,10 @@ namespace ts { return currentToken = scanner.reScanTemplateToken(); } + function reScanLessThanToken(): SyntaxKind { + return currentToken = scanner.reScanLessThanToken(); + } + function scanJsxIdentifier(): SyntaxKind { return currentToken = scanner.scanJsxIdentifier(); } @@ -2263,7 +2267,7 @@ namespace ts { function parseTypeReference(): TypeReferenceNode { const node = createNode(SyntaxKind.TypeReference); node.typeName = parseEntityName(/*allowReservedWords*/ true, Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && token() === SyntaxKind.LessThanToken) { + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === SyntaxKind.LessThanToken) { node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken); } return finishNode(node); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 61ce8330bff..9359fe9b30b 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -31,6 +31,7 @@ namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; + reScanLessThanToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJSDocToken(): JsDocSyntaxKind; scan(): SyntaxKind; @@ -845,6 +846,7 @@ namespace ts { scanJsxIdentifier, scanJsxAttributeValue, reScanJsxToken, + reScanLessThanToken, scanJsxToken, scanJSDocToken, scan, @@ -1840,6 +1842,14 @@ namespace ts { return token = scanJsxToken(); } + function reScanLessThanToken(): SyntaxKind { + if (token === SyntaxKind.LessThanLessThanToken) { + pos = tokenPos + 1; + return token = SyntaxKind.LessThanToken; + } + return token; + } + function scanJsxToken(): JsxTokenSyntaxKind { startPos = tokenPos = pos; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5e992f3847a..25f71327d3a 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3071,6 +3071,7 @@ declare namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; + reScanLessThanToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJSDocToken(): JsDocSyntaxKind; scan(): SyntaxKind; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 32761156558..6a01e6bb58f 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3071,6 +3071,7 @@ declare namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; + reScanLessThanToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJSDocToken(): JsDocSyntaxKind; scan(): SyntaxKind; diff --git a/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.js b/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.js new file mode 100644 index 00000000000..3416e5ad0f8 --- /dev/null +++ b/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.js @@ -0,0 +1,7 @@ +//// [parseGenericArrowRatherThanLeftShift.ts] +type Bar = ReturnType<(x: T) => number>; + +declare const a: Bar; + + +//// [parseGenericArrowRatherThanLeftShift.js] diff --git a/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.symbols b/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.symbols new file mode 100644 index 00000000000..8610080455a --- /dev/null +++ b/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/parseGenericArrowRatherThanLeftShift.ts === +type Bar = ReturnType<(x: T) => number>; +>Bar : Symbol(Bar, Decl(parseGenericArrowRatherThanLeftShift.ts, 0, 0)) +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(parseGenericArrowRatherThanLeftShift.ts, 0, 23)) +>x : Symbol(x, Decl(parseGenericArrowRatherThanLeftShift.ts, 0, 26)) +>T : Symbol(T, Decl(parseGenericArrowRatherThanLeftShift.ts, 0, 23)) + +declare const a: Bar; +>a : Symbol(a, Decl(parseGenericArrowRatherThanLeftShift.ts, 2, 13)) +>Bar : Symbol(Bar, Decl(parseGenericArrowRatherThanLeftShift.ts, 0, 0)) + diff --git a/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.types b/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.types new file mode 100644 index 00000000000..8c959cbed16 --- /dev/null +++ b/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/parseGenericArrowRatherThanLeftShift.ts === +type Bar = ReturnType<(x: T) => number>; +>Bar : number +>x : T + +declare const a: Bar; +>a : number + diff --git a/tests/cases/compiler/parseGenericArrowRatherThanLeftShift.ts b/tests/cases/compiler/parseGenericArrowRatherThanLeftShift.ts new file mode 100644 index 00000000000..cf4f06a5900 --- /dev/null +++ b/tests/cases/compiler/parseGenericArrowRatherThanLeftShift.ts @@ -0,0 +1,3 @@ +type Bar = ReturnType<(x: T) => number>; + +declare const a: Bar; From 78444bb724cdf5ed3fdf413a2a1bb62cab0dd855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Mon, 27 Aug 2018 11:47:10 +0800 Subject: [PATCH 002/101] improve test case --- src/compiler/parser.ts | 12 +++++++----- src/compiler/scanner.ts | 6 +++--- .../baselines/reference/api/tsserverlibrary.d.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 2 +- .../parseGenericArrowRatherThanLeftShift.js | 6 +++++- .../parseGenericArrowRatherThanLeftShift.symbols | 15 ++++++++++++++- .../parseGenericArrowRatherThanLeftShift.types | 12 ++++++++++++ .../parseGenericArrowRatherThanLeftShift.ts | 4 +++- 8 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a76f9eb59b4..4b0c0010de0 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1093,8 +1093,8 @@ namespace ts { return currentToken = scanner.reScanTemplateToken(); } - function reScanLessThanToken(): SyntaxKind { - return currentToken = scanner.reScanLessThanToken(); + function reScanLesserToken(): SyntaxKind { + return currentToken = scanner.reScanLesserToken(); } function scanJsxIdentifier(): SyntaxKind { @@ -2267,7 +2267,7 @@ namespace ts { function parseTypeReference(): TypeReferenceNode { const node = createNode(SyntaxKind.TypeReference); node.typeName = parseEntityName(/*allowReservedWords*/ true, Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === SyntaxKind.LessThanToken) { + if (!scanner.hasPrecedingLineBreak() && reScanLesserToken() === SyntaxKind.LessThanToken) { node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken); } return finishNode(node); @@ -4506,7 +4506,8 @@ namespace ts { function parseCallExpressionRest(expression: LeftHandSideExpression): LeftHandSideExpression { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === SyntaxKind.LessThanToken) { + // handle 'foo<()' + if (token() === SyntaxKind.LessThanToken || token() === SyntaxKind.LessThanLessThanToken) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -4548,9 +4549,10 @@ namespace ts { } function parseTypeArgumentsInExpression() { - if (!parseOptional(SyntaxKind.LessThanToken)) { + if (reScanLesserToken() !== SyntaxKind.LessThanToken) { return undefined; } + nextToken(); const typeArguments = parseDelimitedList(ParsingContext.TypeArguments, parseType); if (!parseExpected(SyntaxKind.GreaterThanToken)) { diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 9359fe9b30b..0411fa6635f 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -31,7 +31,7 @@ namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; - reScanLessThanToken(): SyntaxKind; + reScanLesserToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJSDocToken(): JsDocSyntaxKind; scan(): SyntaxKind; @@ -846,7 +846,7 @@ namespace ts { scanJsxIdentifier, scanJsxAttributeValue, reScanJsxToken, - reScanLessThanToken, + reScanLesserToken, scanJsxToken, scanJSDocToken, scan, @@ -1842,7 +1842,7 @@ namespace ts { return token = scanJsxToken(); } - function reScanLessThanToken(): SyntaxKind { + function reScanLesserToken(): SyntaxKind { if (token === SyntaxKind.LessThanLessThanToken) { pos = tokenPos + 1; return token = SyntaxKind.LessThanToken; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 25f71327d3a..a28cb6ab6ee 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3071,7 +3071,7 @@ declare namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; - reScanLessThanToken(): SyntaxKind; + reScanLesserToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJSDocToken(): JsDocSyntaxKind; scan(): SyntaxKind; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 6a01e6bb58f..87bd074c943 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3071,7 +3071,7 @@ declare namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; - reScanLessThanToken(): SyntaxKind; + reScanLesserToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJSDocToken(): JsDocSyntaxKind; scan(): SyntaxKind; diff --git a/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.js b/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.js index 3416e5ad0f8..f1efc8023b5 100644 --- a/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.js +++ b/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.js @@ -1,7 +1,11 @@ //// [parseGenericArrowRatherThanLeftShift.ts] type Bar = ReturnType<(x: T) => number>; - declare const a: Bar; + +function foo(_x: T) {} +const b = foo<(x: T) => number>(() => 1); //// [parseGenericArrowRatherThanLeftShift.js] +function foo(_x) { } +var b = foo(function () { return 1; }); diff --git a/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.symbols b/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.symbols index 8610080455a..335ffd451e4 100644 --- a/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.symbols +++ b/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.symbols @@ -7,6 +7,19 @@ type Bar = ReturnType<(x: T) => number>; >T : Symbol(T, Decl(parseGenericArrowRatherThanLeftShift.ts, 0, 23)) declare const a: Bar; ->a : Symbol(a, Decl(parseGenericArrowRatherThanLeftShift.ts, 2, 13)) +>a : Symbol(a, Decl(parseGenericArrowRatherThanLeftShift.ts, 1, 13)) >Bar : Symbol(Bar, Decl(parseGenericArrowRatherThanLeftShift.ts, 0, 0)) +function foo(_x: T) {} +>foo : Symbol(foo, Decl(parseGenericArrowRatherThanLeftShift.ts, 1, 21)) +>T : Symbol(T, Decl(parseGenericArrowRatherThanLeftShift.ts, 3, 13)) +>_x : Symbol(_x, Decl(parseGenericArrowRatherThanLeftShift.ts, 3, 16)) +>T : Symbol(T, Decl(parseGenericArrowRatherThanLeftShift.ts, 3, 13)) + +const b = foo<(x: T) => number>(() => 1); +>b : Symbol(b, Decl(parseGenericArrowRatherThanLeftShift.ts, 4, 5)) +>foo : Symbol(foo, Decl(parseGenericArrowRatherThanLeftShift.ts, 1, 21)) +>T : Symbol(T, Decl(parseGenericArrowRatherThanLeftShift.ts, 4, 15)) +>x : Symbol(x, Decl(parseGenericArrowRatherThanLeftShift.ts, 4, 18)) +>T : Symbol(T, Decl(parseGenericArrowRatherThanLeftShift.ts, 4, 15)) + diff --git a/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.types b/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.types index 8c959cbed16..3f256ffdcaa 100644 --- a/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.types +++ b/tests/baselines/reference/parseGenericArrowRatherThanLeftShift.types @@ -6,3 +6,15 @@ type Bar = ReturnType<(x: T) => number>; declare const a: Bar; >a : number +function foo(_x: T) {} +>foo : (_x: T) => void +>_x : T + +const b = foo<(x: T) => number>(() => 1); +>b : void +>foo<(x: T) => number>(() => 1) : void +>foo : (_x: T) => void +>x : T +>() => 1 : () => number +>1 : 1 + diff --git a/tests/cases/compiler/parseGenericArrowRatherThanLeftShift.ts b/tests/cases/compiler/parseGenericArrowRatherThanLeftShift.ts index cf4f06a5900..e61f13a8515 100644 --- a/tests/cases/compiler/parseGenericArrowRatherThanLeftShift.ts +++ b/tests/cases/compiler/parseGenericArrowRatherThanLeftShift.ts @@ -1,3 +1,5 @@ type Bar = ReturnType<(x: T) => number>; - declare const a: Bar; + +function foo(_x: T) {} +const b = foo<(x: T) => number>(() => 1); From f396a2c7a8621788bdfe8438a64607cba09afbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Fri, 7 Sep 2018 11:39:50 +0800 Subject: [PATCH 003/101] rename rescan function --- src/compiler/parser.ts | 8 ++++---- src/compiler/scanner.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 70bbfc8430a..1405428458f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1099,8 +1099,8 @@ namespace ts { return currentToken = scanner.reScanTemplateToken(); } - function reScanLesserToken(): SyntaxKind { - return currentToken = scanner.reScanLesserToken(); + function reScanLessThanToken(): SyntaxKind { + return currentToken = scanner.reScanLessThanToken(); } function scanJsxIdentifier(): SyntaxKind { @@ -2273,7 +2273,7 @@ namespace ts { function parseTypeReference(): TypeReferenceNode { const node = createNode(SyntaxKind.TypeReference); node.typeName = parseEntityName(/*allowReservedWords*/ true, Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLesserToken() === SyntaxKind.LessThanToken) { + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === SyntaxKind.LessThanToken) { node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken); } return finishNode(node); @@ -4557,7 +4557,7 @@ namespace ts { } function parseTypeArgumentsInExpression() { - if (reScanLesserToken() !== SyntaxKind.LessThanToken) { + if (reScanLessThanToken() !== SyntaxKind.LessThanToken) { return undefined; } nextToken(); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index fba45bcf4dc..90e0c9f7681 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -31,7 +31,7 @@ namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; - reScanLesserToken(): SyntaxKind; + reScanLessThanToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJSDocToken(): JsDocSyntaxKind; scan(): SyntaxKind; @@ -850,7 +850,7 @@ namespace ts { scanJsxIdentifier, scanJsxAttributeValue, reScanJsxToken, - reScanLesserToken, + reScanLessThanToken, scanJsxToken, scanJSDocToken, scan, @@ -1871,7 +1871,7 @@ namespace ts { return token = scanJsxToken(); } - function reScanLesserToken(): SyntaxKind { + function reScanLessThanToken(): SyntaxKind { if (token === SyntaxKind.LessThanLessThanToken) { pos = tokenPos + 1; return token = SyntaxKind.LessThanToken; From 9819b6b7aa1f4779eac84b6d056937b8f4800fcd Mon Sep 17 00:00:00 2001 From: xl1 Date: Sat, 15 Sep 2018 23:00:01 +0900 Subject: [PATCH 004/101] Allow non-number array for source of TypedArray.from --- src/lib/es5.d.ts | 74 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 10 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 015eec5c3e0..f549bea6160 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -517,7 +517,7 @@ interface TemplateStringsArray extends ReadonlyArray { /** * The type of `import.meta`. - * + * * If you need to declare that a given property exists on `import.meta`, * this type may be augmented via interface merging. */ @@ -1843,13 +1843,19 @@ interface Int8ArrayConstructor { */ of(...items: number[]): Int8Array; + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ + from(arrayLike: ArrayLike): Int8Array; + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; } @@ -2113,13 +2119,19 @@ interface Uint8ArrayConstructor { */ of(...items: number[]): Uint8Array; + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ + from(arrayLike: ArrayLike): Uint8Array; + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; } declare const Uint8Array: Uint8ArrayConstructor; @@ -2382,13 +2394,19 @@ interface Uint8ClampedArrayConstructor { */ of(...items: number[]): Uint8ClampedArray; + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ + from(arrayLike: ArrayLike): Uint8ClampedArray; + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; } declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; @@ -2649,13 +2667,19 @@ interface Int16ArrayConstructor { */ of(...items: number[]): Int16Array; + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ + from(arrayLike: ArrayLike): Int16Array; + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; } @@ -2919,13 +2943,19 @@ interface Uint16ArrayConstructor { */ of(...items: number[]): Uint16Array; + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ + from(arrayLike: ArrayLike): Uint16Array; + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; } @@ -3188,13 +3218,19 @@ interface Int32ArrayConstructor { */ of(...items: number[]): Int32Array; + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ + from(arrayLike: ArrayLike): Int32Array; + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; } declare const Int32Array: Int32ArrayConstructor; @@ -3456,13 +3492,19 @@ interface Uint32ArrayConstructor { */ of(...items: number[]): Uint32Array; + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ + from(arrayLike: ArrayLike): Uint32Array; + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; } declare const Uint32Array: Uint32ArrayConstructor; @@ -3725,13 +3767,19 @@ interface Float32ArrayConstructor { */ of(...items: number[]): Float32Array; + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ + from(arrayLike: ArrayLike): Float32Array; + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; } @@ -3995,13 +4043,19 @@ interface Float64ArrayConstructor { */ of(...items: number[]): Float64Array; + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ + from(arrayLike: ArrayLike): Float64Array; + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; } declare const Float64Array: Float64ArrayConstructor; From 89e7d51df404a4adc2a940c8a308ec83e2955ac8 Mon Sep 17 00:00:00 2001 From: xl1 Date: Sat, 15 Sep 2018 23:02:36 +0900 Subject: [PATCH 005/101] Add tests --- tests/cases/compiler/typedArrays.ts | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/cases/compiler/typedArrays.ts b/tests/cases/compiler/typedArrays.ts index 602e15dc2d7..591b00aadc6 100644 --- a/tests/cases/compiler/typedArrays.ts +++ b/tests/cases/compiler/typedArrays.ts @@ -105,6 +105,21 @@ function CreateTypedArraysOf2() { return typedArrays; } +function CreateTypedArraysFromMapFn2(obj:ArrayLike, mapFn: (n:T, v:number)=> number) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj, mapFn); + typedArrays[1] = Uint8Array.from(obj, mapFn); + typedArrays[2] = Int16Array.from(obj, mapFn); + typedArrays[3] = Uint16Array.from(obj, mapFn); + typedArrays[4] = Int32Array.from(obj, mapFn); + typedArrays[5] = Uint32Array.from(obj, mapFn); + typedArrays[6] = Float32Array.from(obj, mapFn); + typedArrays[7] = Float64Array.from(obj, mapFn); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); + + return typedArrays; +} + function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { var typedArrays = []; typedArrays[0] = Int8Array.from(obj, mapFn); @@ -132,5 +147,20 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); + return typedArrays; +} + +function CreateTypedArraysFromThisObj2(obj:ArrayLike, mapFn: (n:T, v:number)=> number, thisArg: {}) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); + typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); + typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); + typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); + typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); + typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); + typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); + typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); + return typedArrays; } \ No newline at end of file From ecc2ba71216832226ea4ee76e08d3dd8008df5bc Mon Sep 17 00:00:00 2001 From: xl1 Date: Sat, 15 Sep 2018 23:02:50 +0900 Subject: [PATCH 006/101] Update baselines --- tests/baselines/reference/typedArrays.js | 56 +++ tests/baselines/reference/typedArrays.symbols | 468 ++++++++++++------ tests/baselines/reference/typedArrays.types | 400 ++++++++++++--- 3 files changed, 713 insertions(+), 211 deletions(-) diff --git a/tests/baselines/reference/typedArrays.js b/tests/baselines/reference/typedArrays.js index b914a803185..1e322b5eac5 100644 --- a/tests/baselines/reference/typedArrays.js +++ b/tests/baselines/reference/typedArrays.js @@ -104,6 +104,21 @@ function CreateTypedArraysOf2() { return typedArrays; } +function CreateTypedArraysFromMapFn2(obj:ArrayLike, mapFn: (n:T, v:number)=> number) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj, mapFn); + typedArrays[1] = Uint8Array.from(obj, mapFn); + typedArrays[2] = Int16Array.from(obj, mapFn); + typedArrays[3] = Uint16Array.from(obj, mapFn); + typedArrays[4] = Int32Array.from(obj, mapFn); + typedArrays[5] = Uint32Array.from(obj, mapFn); + typedArrays[6] = Float32Array.from(obj, mapFn); + typedArrays[7] = Float64Array.from(obj, mapFn); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); + + return typedArrays; +} + function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { var typedArrays = []; typedArrays[0] = Int8Array.from(obj, mapFn); @@ -131,6 +146,21 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); + return typedArrays; +} + +function CreateTypedArraysFromThisObj2(obj:ArrayLike, mapFn: (n:T, v:number)=> number, thisArg: {}) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); + typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); + typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); + typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); + typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); + typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); + typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); + typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); + return typedArrays; } @@ -226,6 +256,19 @@ function CreateTypedArraysOf2() { typedArrays[8] = Uint8ClampedArray.of(1, 2, 3, 4); return typedArrays; } +function CreateTypedArraysFromMapFn2(obj, mapFn) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj, mapFn); + typedArrays[1] = Uint8Array.from(obj, mapFn); + typedArrays[2] = Int16Array.from(obj, mapFn); + typedArrays[3] = Uint16Array.from(obj, mapFn); + typedArrays[4] = Int32Array.from(obj, mapFn); + typedArrays[5] = Uint32Array.from(obj, mapFn); + typedArrays[6] = Float32Array.from(obj, mapFn); + typedArrays[7] = Float64Array.from(obj, mapFn); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); + return typedArrays; +} function CreateTypedArraysFromMapFn(obj, mapFn) { var typedArrays = []; typedArrays[0] = Int8Array.from(obj, mapFn); @@ -252,3 +295,16 @@ function CreateTypedArraysFromThisObj(obj, mapFn, thisArg) { typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); return typedArrays; } +function CreateTypedArraysFromThisObj2(obj, mapFn, thisArg) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); + typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); + typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); + typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); + typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); + typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); + typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); + typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); + return typedArrays; +} diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index 656609a0499..fb6457929e4 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -166,65 +166,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) return typedArrays; @@ -241,65 +241,65 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) return typedArrays; @@ -444,186 +444,376 @@ function CreateTypedArraysOf2() { >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 91, 7)) } -function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { ->CreateTypedArraysFromMapFn : Symbol(CreateTypedArraysFromMapFn, Decl(typedArrays.ts, 103, 1)) ->obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) +function CreateTypedArraysFromMapFn2(obj:ArrayLike, mapFn: (n:T, v:number)=> number) { +>CreateTypedArraysFromMapFn2 : Symbol(CreateTypedArraysFromMapFn2, Decl(typedArrays.ts, 103, 1)) +>T : Symbol(T, Decl(typedArrays.ts, 105, 37)) +>obj : Symbol(obj, Decl(typedArrays.ts, 105, 40)) >ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) ->n : Symbol(n, Decl(typedArrays.ts, 105, 67)) ->v : Symbol(v, Decl(typedArrays.ts, 105, 76)) +>T : Symbol(T, Decl(typedArrays.ts, 105, 37)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 57)) +>n : Symbol(n, Decl(typedArrays.ts, 105, 66)) +>T : Symbol(T, Decl(typedArrays.ts, 105, 37)) +>v : Symbol(v, Decl(typedArrays.ts, 105, 70)) var typedArrays = []; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 105, 40)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 57)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 105, 40)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 57)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 105, 40)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 57)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 105, 40)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 57)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 105, 40)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 57)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 105, 40)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 57)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 105, 40)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 57)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 105, 40)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 57)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 105, 40)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 57)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) } -function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { ->CreateTypedArraysFromThisObj : Symbol(CreateTypedArraysFromThisObj, Decl(typedArrays.ts, 118, 1)) ->obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) +function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { +>CreateTypedArraysFromMapFn : Symbol(CreateTypedArraysFromMapFn, Decl(typedArrays.ts, 118, 1)) +>obj : Symbol(obj, Decl(typedArrays.ts, 120, 36)) >ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) ->n : Symbol(n, Decl(typedArrays.ts, 120, 69)) ->v : Symbol(v, Decl(typedArrays.ts, 120, 78)) ->thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 58)) +>n : Symbol(n, Decl(typedArrays.ts, 120, 67)) +>v : Symbol(v, Decl(typedArrays.ts, 120, 76)) var typedArrays = []; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) - typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); + typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) ->thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 120, 36)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 58)) - typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); + typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) ->thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 120, 36)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 58)) - typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); + typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) ->thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 120, 36)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 58)) - typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); + typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) ->thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 120, 36)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 58)) - typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); + typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) ->thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 120, 36)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 58)) - typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); + typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) ->thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 120, 36)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 58)) - typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); + typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) ->thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 120, 36)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 58)) - typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); + typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) ->thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 120, 36)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 58)) - typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) ->mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) ->thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 120, 36)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 58)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) } + +function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { +>CreateTypedArraysFromThisObj : Symbol(CreateTypedArraysFromThisObj, Decl(typedArrays.ts, 133, 1)) +>obj : Symbol(obj, Decl(typedArrays.ts, 135, 38)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 135, 60)) +>n : Symbol(n, Decl(typedArrays.ts, 135, 69)) +>v : Symbol(v, Decl(typedArrays.ts, 135, 78)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 135, 98)) + + var typedArrays = []; +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 136, 7)) + + typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 136, 7)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 135, 38)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 135, 60)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 135, 98)) + + typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 136, 7)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 135, 38)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 135, 60)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 135, 98)) + + typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 136, 7)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 135, 38)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 135, 60)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 135, 98)) + + typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 136, 7)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 135, 38)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 135, 60)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 135, 98)) + + typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 136, 7)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 135, 38)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 135, 60)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 135, 98)) + + typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 136, 7)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 135, 38)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 135, 60)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 135, 98)) + + typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 136, 7)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 135, 38)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 135, 60)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 135, 98)) + + typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 136, 7)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 135, 38)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 135, 60)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 135, 98)) + + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 136, 7)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 135, 38)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 135, 60)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 135, 98)) + + return typedArrays; +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 136, 7)) +} + +function CreateTypedArraysFromThisObj2(obj:ArrayLike, mapFn: (n:T, v:number)=> number, thisArg: {}) { +>CreateTypedArraysFromThisObj2 : Symbol(CreateTypedArraysFromThisObj2, Decl(typedArrays.ts, 148, 1)) +>T : Symbol(T, Decl(typedArrays.ts, 150, 39)) +>obj : Symbol(obj, Decl(typedArrays.ts, 150, 42)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(typedArrays.ts, 150, 39)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 150, 59)) +>n : Symbol(n, Decl(typedArrays.ts, 150, 68)) +>T : Symbol(T, Decl(typedArrays.ts, 150, 39)) +>v : Symbol(v, Decl(typedArrays.ts, 150, 72)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 150, 92)) + + var typedArrays = []; +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 151, 7)) + + typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 151, 7)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 150, 42)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 150, 59)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 150, 92)) + + typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 151, 7)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 150, 42)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 150, 59)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 150, 92)) + + typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 151, 7)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 150, 42)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 150, 59)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 150, 92)) + + typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 151, 7)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 150, 42)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 150, 59)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 150, 92)) + + typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 151, 7)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 150, 42)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 150, 59)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 150, 92)) + + typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 151, 7)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 150, 42)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 150, 59)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 150, 92)) + + typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 151, 7)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 150, 42)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 150, 59)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 150, 92)) + + typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 151, 7)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 150, 42)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 150, 59)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 150, 92)) + + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 151, 7)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>obj : Symbol(obj, Decl(typedArrays.ts, 150, 42)) +>mapFn : Symbol(mapFn, Decl(typedArrays.ts, 150, 59)) +>thisArg : Symbol(thisArg, Decl(typedArrays.ts, 150, 92)) + + return typedArrays; +>typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 151, 7)) +} diff --git a/tests/baselines/reference/typedArrays.types b/tests/baselines/reference/typedArrays.types index af74b8ba709..5cd4879be7e 100644 --- a/tests/baselines/reference/typedArrays.types +++ b/tests/baselines/reference/typedArrays.types @@ -273,9 +273,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >0 : 0 >Int8Array.from(obj) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike): Int8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>from : { (arrayLike: ArrayLike): Int8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : number[] typedArrays[1] = Uint8Array.from(obj); @@ -284,9 +284,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >1 : 1 >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike): Uint8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>from : { (arrayLike: ArrayLike): Uint8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : number[] typedArrays[2] = Int16Array.from(obj); @@ -295,9 +295,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >2 : 2 >Int16Array.from(obj) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike): Int16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>from : { (arrayLike: ArrayLike): Int16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : number[] typedArrays[3] = Uint16Array.from(obj); @@ -306,9 +306,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >3 : 3 >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike): Uint16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>from : { (arrayLike: ArrayLike): Uint16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : number[] typedArrays[4] = Int32Array.from(obj); @@ -317,9 +317,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >4 : 4 >Int32Array.from(obj) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike): Int32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>from : { (arrayLike: ArrayLike): Int32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : number[] typedArrays[5] = Uint32Array.from(obj); @@ -328,9 +328,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >5 : 5 >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike): Uint32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>from : { (arrayLike: ArrayLike): Uint32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : number[] typedArrays[6] = Float32Array.from(obj); @@ -339,9 +339,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >6 : 6 >Float32Array.from(obj) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike): Float32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>from : { (arrayLike: ArrayLike): Float32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : number[] typedArrays[7] = Float64Array.from(obj); @@ -350,9 +350,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >7 : 7 >Float64Array.from(obj) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike): Float64Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>from : { (arrayLike: ArrayLike): Float64Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : number[] typedArrays[8] = Uint8ClampedArray.from(obj); @@ -361,9 +361,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : number[] return typedArrays; @@ -384,9 +384,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >0 : 0 >Int8Array.from(obj) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike): Int8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>from : { (arrayLike: ArrayLike): Int8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike typedArrays[1] = Uint8Array.from(obj); @@ -395,9 +395,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >1 : 1 >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike): Uint8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>from : { (arrayLike: ArrayLike): Uint8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike typedArrays[2] = Int16Array.from(obj); @@ -406,9 +406,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >2 : 2 >Int16Array.from(obj) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike): Int16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>from : { (arrayLike: ArrayLike): Int16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike typedArrays[3] = Uint16Array.from(obj); @@ -417,9 +417,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >3 : 3 >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike): Uint16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>from : { (arrayLike: ArrayLike): Uint16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike typedArrays[4] = Int32Array.from(obj); @@ -428,9 +428,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >4 : 4 >Int32Array.from(obj) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike): Int32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>from : { (arrayLike: ArrayLike): Int32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike typedArrays[5] = Uint32Array.from(obj); @@ -439,9 +439,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >5 : 5 >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike): Uint32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>from : { (arrayLike: ArrayLike): Uint32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike typedArrays[6] = Float32Array.from(obj); @@ -450,9 +450,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >6 : 6 >Float32Array.from(obj) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike): Float32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>from : { (arrayLike: ArrayLike): Float32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike typedArrays[7] = Float64Array.from(obj); @@ -461,9 +461,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >7 : 7 >Float64Array.from(obj) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike): Float64Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>from : { (arrayLike: ArrayLike): Float64Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike typedArrays[8] = Uint8ClampedArray.from(obj); @@ -472,9 +472,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike return typedArrays; @@ -738,6 +738,129 @@ function CreateTypedArraysOf2() { >typedArrays : any[] } +function CreateTypedArraysFromMapFn2(obj:ArrayLike, mapFn: (n:T, v:number)=> number) { +>CreateTypedArraysFromMapFn2 : (obj: ArrayLike, mapFn: (n: T, v: number) => number) => any[] +>obj : ArrayLike +>mapFn : (n: T, v: number) => number +>n : T +>v : number + + var typedArrays = []; +>typedArrays : any[] +>[] : undefined[] + + typedArrays[0] = Int8Array.from(obj, mapFn); +>typedArrays[0] = Int8Array.from(obj, mapFn) : Int8Array +>typedArrays[0] : any +>typedArrays : any[] +>0 : 0 +>Int8Array.from(obj, mapFn) : Int8Array +>Int8Array.from : { (arrayLike: ArrayLike): Int8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array : Int8ArrayConstructor +>from : { (arrayLike: ArrayLike): Int8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number + + typedArrays[1] = Uint8Array.from(obj, mapFn); +>typedArrays[1] = Uint8Array.from(obj, mapFn) : Uint8Array +>typedArrays[1] : any +>typedArrays : any[] +>1 : 1 +>Uint8Array.from(obj, mapFn) : Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike): Uint8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array : Uint8ArrayConstructor +>from : { (arrayLike: ArrayLike): Uint8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number + + typedArrays[2] = Int16Array.from(obj, mapFn); +>typedArrays[2] = Int16Array.from(obj, mapFn) : Int16Array +>typedArrays[2] : any +>typedArrays : any[] +>2 : 2 +>Int16Array.from(obj, mapFn) : Int16Array +>Int16Array.from : { (arrayLike: ArrayLike): Int16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array : Int16ArrayConstructor +>from : { (arrayLike: ArrayLike): Int16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number + + typedArrays[3] = Uint16Array.from(obj, mapFn); +>typedArrays[3] = Uint16Array.from(obj, mapFn) : Uint16Array +>typedArrays[3] : any +>typedArrays : any[] +>3 : 3 +>Uint16Array.from(obj, mapFn) : Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike): Uint16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array : Uint16ArrayConstructor +>from : { (arrayLike: ArrayLike): Uint16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number + + typedArrays[4] = Int32Array.from(obj, mapFn); +>typedArrays[4] = Int32Array.from(obj, mapFn) : Int32Array +>typedArrays[4] : any +>typedArrays : any[] +>4 : 4 +>Int32Array.from(obj, mapFn) : Int32Array +>Int32Array.from : { (arrayLike: ArrayLike): Int32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array : Int32ArrayConstructor +>from : { (arrayLike: ArrayLike): Int32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number + + typedArrays[5] = Uint32Array.from(obj, mapFn); +>typedArrays[5] = Uint32Array.from(obj, mapFn) : Uint32Array +>typedArrays[5] : any +>typedArrays : any[] +>5 : 5 +>Uint32Array.from(obj, mapFn) : Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike): Uint32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array : Uint32ArrayConstructor +>from : { (arrayLike: ArrayLike): Uint32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number + + typedArrays[6] = Float32Array.from(obj, mapFn); +>typedArrays[6] = Float32Array.from(obj, mapFn) : Float32Array +>typedArrays[6] : any +>typedArrays : any[] +>6 : 6 +>Float32Array.from(obj, mapFn) : Float32Array +>Float32Array.from : { (arrayLike: ArrayLike): Float32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array : Float32ArrayConstructor +>from : { (arrayLike: ArrayLike): Float32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number + + typedArrays[7] = Float64Array.from(obj, mapFn); +>typedArrays[7] = Float64Array.from(obj, mapFn) : Float64Array +>typedArrays[7] : any +>typedArrays : any[] +>7 : 7 +>Float64Array.from(obj, mapFn) : Float64Array +>Float64Array.from : { (arrayLike: ArrayLike): Float64Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array : Float64ArrayConstructor +>from : { (arrayLike: ArrayLike): Float64Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number + + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); +>typedArrays[8] = Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray +>typedArrays[8] : any +>typedArrays : any[] +>8 : 8 +>Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray : Uint8ClampedArrayConstructor +>from : { (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number + + return typedArrays; +>typedArrays : any[] +} + function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { >CreateTypedArraysFromMapFn : (obj: ArrayLike, mapFn: (n: number, v: number) => number) => any[] >obj : ArrayLike @@ -755,9 +878,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >0 : 0 >Int8Array.from(obj, mapFn) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike): Int8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>from : { (arrayLike: ArrayLike): Int8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -767,9 +890,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >1 : 1 >Uint8Array.from(obj, mapFn) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike): Uint8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>from : { (arrayLike: ArrayLike): Uint8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -779,9 +902,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >2 : 2 >Int16Array.from(obj, mapFn) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike): Int16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>from : { (arrayLike: ArrayLike): Int16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -791,9 +914,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >3 : 3 >Uint16Array.from(obj, mapFn) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike): Uint16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>from : { (arrayLike: ArrayLike): Uint16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -803,9 +926,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >4 : 4 >Int32Array.from(obj, mapFn) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike): Int32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>from : { (arrayLike: ArrayLike): Int32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -815,9 +938,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >5 : 5 >Uint32Array.from(obj, mapFn) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike): Uint32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>from : { (arrayLike: ArrayLike): Uint32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -827,9 +950,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >6 : 6 >Float32Array.from(obj, mapFn) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike): Float32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>from : { (arrayLike: ArrayLike): Float32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -839,9 +962,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >7 : 7 >Float64Array.from(obj, mapFn) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike): Float64Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>from : { (arrayLike: ArrayLike): Float64Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -851,9 +974,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -879,9 +1002,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >0 : 0 >Int8Array.from(obj, mapFn, thisArg) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike): Int8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>from : { (arrayLike: ArrayLike): Int8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -892,9 +1015,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >1 : 1 >Uint8Array.from(obj, mapFn, thisArg) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike): Uint8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>from : { (arrayLike: ArrayLike): Uint8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -905,9 +1028,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >2 : 2 >Int16Array.from(obj, mapFn, thisArg) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike): Int16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>from : { (arrayLike: ArrayLike): Int16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -918,9 +1041,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >3 : 3 >Uint16Array.from(obj, mapFn, thisArg) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike): Uint16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>from : { (arrayLike: ArrayLike): Uint16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -931,9 +1054,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >4 : 4 >Int32Array.from(obj, mapFn, thisArg) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike): Int32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>from : { (arrayLike: ArrayLike): Int32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -944,9 +1067,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >5 : 5 >Uint32Array.from(obj, mapFn, thisArg) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike): Uint32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>from : { (arrayLike: ArrayLike): Uint32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -957,9 +1080,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >6 : 6 >Float32Array.from(obj, mapFn, thisArg) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike): Float32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>from : { (arrayLike: ArrayLike): Float32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -970,9 +1093,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >7 : 7 >Float64Array.from(obj, mapFn, thisArg) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike): Float64Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>from : { (arrayLike: ArrayLike): Float64Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -983,9 +1106,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -993,3 +1116,136 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v return typedArrays; >typedArrays : any[] } + +function CreateTypedArraysFromThisObj2(obj:ArrayLike, mapFn: (n:T, v:number)=> number, thisArg: {}) { +>CreateTypedArraysFromThisObj2 : (obj: ArrayLike, mapFn: (n: T, v: number) => number, thisArg: {}) => any[] +>obj : ArrayLike +>mapFn : (n: T, v: number) => number +>n : T +>v : number +>thisArg : {} + + var typedArrays = []; +>typedArrays : any[] +>[] : undefined[] + + typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); +>typedArrays[0] = Int8Array.from(obj, mapFn, thisArg) : Int8Array +>typedArrays[0] : any +>typedArrays : any[] +>0 : 0 +>Int8Array.from(obj, mapFn, thisArg) : Int8Array +>Int8Array.from : { (arrayLike: ArrayLike): Int8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array : Int8ArrayConstructor +>from : { (arrayLike: ArrayLike): Int8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number +>thisArg : {} + + typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); +>typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg) : Uint8Array +>typedArrays[1] : any +>typedArrays : any[] +>1 : 1 +>Uint8Array.from(obj, mapFn, thisArg) : Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike): Uint8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array : Uint8ArrayConstructor +>from : { (arrayLike: ArrayLike): Uint8Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number +>thisArg : {} + + typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); +>typedArrays[2] = Int16Array.from(obj, mapFn, thisArg) : Int16Array +>typedArrays[2] : any +>typedArrays : any[] +>2 : 2 +>Int16Array.from(obj, mapFn, thisArg) : Int16Array +>Int16Array.from : { (arrayLike: ArrayLike): Int16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array : Int16ArrayConstructor +>from : { (arrayLike: ArrayLike): Int16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number +>thisArg : {} + + typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); +>typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg) : Uint16Array +>typedArrays[3] : any +>typedArrays : any[] +>3 : 3 +>Uint16Array.from(obj, mapFn, thisArg) : Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike): Uint16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array : Uint16ArrayConstructor +>from : { (arrayLike: ArrayLike): Uint16Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number +>thisArg : {} + + typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); +>typedArrays[4] = Int32Array.from(obj, mapFn, thisArg) : Int32Array +>typedArrays[4] : any +>typedArrays : any[] +>4 : 4 +>Int32Array.from(obj, mapFn, thisArg) : Int32Array +>Int32Array.from : { (arrayLike: ArrayLike): Int32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array : Int32ArrayConstructor +>from : { (arrayLike: ArrayLike): Int32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number +>thisArg : {} + + typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); +>typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg) : Uint32Array +>typedArrays[5] : any +>typedArrays : any[] +>5 : 5 +>Uint32Array.from(obj, mapFn, thisArg) : Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike): Uint32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array : Uint32ArrayConstructor +>from : { (arrayLike: ArrayLike): Uint32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number +>thisArg : {} + + typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); +>typedArrays[6] = Float32Array.from(obj, mapFn, thisArg) : Float32Array +>typedArrays[6] : any +>typedArrays : any[] +>6 : 6 +>Float32Array.from(obj, mapFn, thisArg) : Float32Array +>Float32Array.from : { (arrayLike: ArrayLike): Float32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array : Float32ArrayConstructor +>from : { (arrayLike: ArrayLike): Float32Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number +>thisArg : {} + + typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); +>typedArrays[7] = Float64Array.from(obj, mapFn, thisArg) : Float64Array +>typedArrays[7] : any +>typedArrays : any[] +>7 : 7 +>Float64Array.from(obj, mapFn, thisArg) : Float64Array +>Float64Array.from : { (arrayLike: ArrayLike): Float64Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array : Float64ArrayConstructor +>from : { (arrayLike: ArrayLike): Float64Array; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number +>thisArg : {} + + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); +>typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray +>typedArrays[8] : any +>typedArrays : any[] +>8 : 8 +>Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray : Uint8ClampedArrayConstructor +>from : { (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>obj : ArrayLike +>mapFn : (n: T, v: number) => number +>thisArg : {} + + return typedArrays; +>typedArrays : any[] +} From f666295c8fecda5b91293afb5f30231b14e68b66 Mon Sep 17 00:00:00 2001 From: Ajay Poshak Date: Mon, 1 Oct 2018 22:53:16 +0530 Subject: [PATCH 007/101] Add docs for better support of local testing and faster clones --- CONTRIBUTING.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 81ffe06e8e2..a8e3fa31f29 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,6 +47,13 @@ In general, things we find useful when reviewing suggestions are: # Instructions for Contributing Code +## Some things in general + +As Typescript is a big codebase, so some might run into issues while cloning this repo. Hence, it is advisable to use +`git clone --depth=1 ` to clone it faster. + +Run `jake build` after every change. If you want to test it locally in some another project then use `node /built/local/tsc.js` in place of `tsc` in your project. For example, to run `tsc --watch`, use `node /TypeScript/built/local/tsc.js --watch`. + ## Contributing bug fixes TypeScript is currently accepting contributions in the form of bug fixes. A bug must have an issue tracking it in the issue tracker that has been approved ("Milestone == Community") by the TypeScript team. Your pull request should include a link to the bug that you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort. From c22e7cade99bd6d238ddddd9c4b294ee3c8c9384 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 1 Oct 2018 13:25:43 -0700 Subject: [PATCH 008/101] Update CONTRIBUTING.md --- CONTRIBUTING.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a8e3fa31f29..a25ed0ad4cd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,12 +47,16 @@ In general, things we find useful when reviewing suggestions are: # Instructions for Contributing Code -## Some things in general +## Tips -As Typescript is a big codebase, so some might run into issues while cloning this repo. Hence, it is advisable to use -`git clone --depth=1 ` to clone it faster. +### Faster clones -Run `jake build` after every change. If you want to test it locally in some another project then use `node /built/local/tsc.js` in place of `tsc` in your project. For example, to run `tsc --watch`, use `node /TypeScript/built/local/tsc.js --watch`. +The TypeScript repository is relatively large. To save some time, you might want to clone it without the repo's full history using +`git clone --depth=1` to save time. + +### Using local builds + +Run `jake build` to build a version of the compiler/language service that reflects changes you've made. You can then run `node /built/local/tsc.js` in place of `tsc` in your project. For example, to run `tsc --watch` from within the root of the repository on a file called `test.ts`, you can run `node ./built/local/tsc.js --watch test.ts`. ## Contributing bug fixes From 15b4af63dd9985d23ebfa55dcbb70562708c73a7 Mon Sep 17 00:00:00 2001 From: Andrey Roenko Date: Fri, 12 Oct 2018 17:16:54 +0300 Subject: [PATCH 009/101] #27716: fix protected methods for intersection fo generic classes --- src/compiler/checker.ts | 14 +++- tests/baselines/reference/arraySlice.symbols | 4 +- .../reference/bivariantInferences.symbols | 4 +- .../reference/controlFlowArrayErrors.symbols | 4 +- .../reference/mixinAccessModifiers.errors.txt | 45 ++++++++++- .../reference/mixinAccessModifiers.js | 72 +++++++++++++++++ .../reference/mixinAccessModifiers.symbols | 79 +++++++++++++++++++ .../reference/mixinAccessModifiers.types | 77 ++++++++++++++++++ .../typeParameterExtendingUnion1.symbols | 4 +- .../typeParameterExtendingUnion2.symbols | 8 +- .../classes/mixinAccessModifiers.ts | 25 ++++++ tests/cases/fourslash/commentsUnion.ts | 2 +- .../completionEntryForUnionMethod.ts | 4 +- 13 files changed, 323 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 62756388dc4..536b762c021 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7354,13 +7354,13 @@ namespace ts { const propTypes: Type[] = []; let first = true; let commonValueDeclaration: Declaration | undefined; - let hasNonUniformValueDeclaration = false; + let hasUniformValueDeclaration = true; for (const prop of props) { if (!commonValueDeclaration) { commonValueDeclaration = prop.valueDeclaration; } else if (prop.valueDeclaration !== commonValueDeclaration) { - hasNonUniformValueDeclaration = true; + hasUniformValueDeclaration = false; } declarations = addRange(declarations, prop.declarations); const type = getTypeOfSymbol(prop); @@ -7379,9 +7379,17 @@ namespace ts { addRange(propTypes, indexTypes); const result = createSymbol(SymbolFlags.Property | commonFlags, name, syntheticFlag | checkFlags); result.containingType = containingType; - if (!hasNonUniformValueDeclaration && commonValueDeclaration) { + + // All intersections lead to the same value declaration. + if (hasUniformValueDeclaration && commonValueDeclaration) { result.valueDeclaration = commonValueDeclaration; + + // Inherit information about parent type. + if (commonValueDeclaration.symbol.parent) { + result.parent = commonValueDeclaration.symbol.parent; + } } + result.declarations = declarations!; result.nameType = nameType; result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); diff --git a/tests/baselines/reference/arraySlice.symbols b/tests/baselines/reference/arraySlice.symbols index a603a39c254..2ba96cbb582 100644 --- a/tests/baselines/reference/arraySlice.symbols +++ b/tests/baselines/reference/arraySlice.symbols @@ -3,7 +3,7 @@ var arr: string[] | number[]; >arr : Symbol(arr, Decl(arraySlice.ts, 0, 3)) arr.splice(1, 1); ->arr.splice : Symbol(splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arr.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arr : Symbol(arr, Decl(arraySlice.ts, 0, 3)) ->splice : Symbol(splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) diff --git a/tests/baselines/reference/bivariantInferences.symbols b/tests/baselines/reference/bivariantInferences.symbols index 63cc239f040..0697c171c54 100644 --- a/tests/baselines/reference/bivariantInferences.symbols +++ b/tests/baselines/reference/bivariantInferences.symbols @@ -24,8 +24,8 @@ declare const b: (string | number)[] | null[] | undefined[] | {}[]; let x = a.equalsShallow(b); >x : Symbol(x, Decl(bivariantInferences.ts, 9, 3)) ->a.equalsShallow : Symbol(equalsShallow, Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20)) +>a.equalsShallow : Symbol(Array.equalsShallow, Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20)) >a : Symbol(a, Decl(bivariantInferences.ts, 6, 13)) ->equalsShallow : Symbol(equalsShallow, Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20)) +>equalsShallow : Symbol(Array.equalsShallow, Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20)) >b : Symbol(b, Decl(bivariantInferences.ts, 7, 13)) diff --git a/tests/baselines/reference/controlFlowArrayErrors.symbols b/tests/baselines/reference/controlFlowArrayErrors.symbols index 46a61f13e43..99766693e0c 100644 --- a/tests/baselines/reference/controlFlowArrayErrors.symbols +++ b/tests/baselines/reference/controlFlowArrayErrors.symbols @@ -121,9 +121,9 @@ function f6() { >x : Symbol(x, Decl(controlFlowArrayErrors.ts, 37, 7)) x.push(99); // Error ->x.push : Symbol(push, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>x.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >x : Symbol(x, Decl(controlFlowArrayErrors.ts, 37, 7)) ->push : Symbol(push, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } function f7() { diff --git a/tests/baselines/reference/mixinAccessModifiers.errors.txt b/tests/baselines/reference/mixinAccessModifiers.errors.txt index fa2fc4ac99a..05cd72cbb6b 100644 --- a/tests/baselines/reference/mixinAccessModifiers.errors.txt +++ b/tests/baselines/reference/mixinAccessModifiers.errors.txt @@ -15,9 +15,15 @@ tests/cases/conformance/classes/mixinAccessModifiers.ts(84,6): error TS2445: Pro tests/cases/conformance/classes/mixinAccessModifiers.ts(89,6): error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses. tests/cases/conformance/classes/mixinAccessModifiers.ts(97,6): error TS2445: Property 'p' is protected and only accessible within class 'C4' and its subclasses. tests/cases/conformance/classes/mixinAccessModifiers.ts(102,6): error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses. +tests/cases/conformance/classes/mixinAccessModifiers.ts(119,4): error TS2341: Property 'privateMethod' is private and only accessible within class 'ProtectedGeneric'. +tests/cases/conformance/classes/mixinAccessModifiers.ts(120,4): error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric' and its subclasses. +tests/cases/conformance/classes/mixinAccessModifiers.ts(124,4): error TS2546: Property 'privateMethod' has conflicting declarations and is inaccessible in type 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>'. +tests/cases/conformance/classes/mixinAccessModifiers.ts(125,4): error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' and its subclasses. +tests/cases/conformance/classes/mixinAccessModifiers.ts(129,4): error TS2546: Property 'privateMethod' has conflicting declarations and is inaccessible in type 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }>'. +tests/cases/conformance/classes/mixinAccessModifiers.ts(130,4): error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric' and its subclasses. -==== tests/cases/conformance/classes/mixinAccessModifiers.ts (11 errors) ==== +==== tests/cases/conformance/classes/mixinAccessModifiers.ts (17 errors) ==== type Constructable = new (...args: any[]) => object; class Private { @@ -152,4 +158,41 @@ tests/cases/conformance/classes/mixinAccessModifiers.ts(102,6): error TS2445: Pr C6.s } } + + class ProtectedGeneric { + private privateMethod() {} + protected protectedMethod() {} + } + + class ProtectedGeneric2 { + private privateMethod() {} + protected protectedMethod() {} + } + + function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>) { + x.privateMethod(); // Error, private constituent makes method inaccessible + ~~~~~~~~~~~~~ +!!! error TS2341: Property 'privateMethod' is private and only accessible within class 'ProtectedGeneric'. + x.protectedMethod(); // Error, protected when all constituents are protected + ~~~~~~~~~~~~~~~ +!!! error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric' and its subclasses. + } + + function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}>) { + x.privateMethod(); // Error, private constituent makes method inaccessible + ~~~~~~~~~~~~~ +!!! error TS2546: Property 'privateMethod' has conflicting declarations and is inaccessible in type 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>'. + x.protectedMethod(); // Error, protected when all constituents are protected + ~~~~~~~~~~~~~~~ +!!! error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' and its subclasses. + } + + function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) { + x.privateMethod(); // Error, private constituent makes method inaccessible + ~~~~~~~~~~~~~ +!!! error TS2546: Property 'privateMethod' has conflicting declarations and is inaccessible in type 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }>'. + x.protectedMethod(); // Error, protected when all constituents are protected + ~~~~~~~~~~~~~~~ +!!! error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric' and its subclasses. + } \ No newline at end of file diff --git a/tests/baselines/reference/mixinAccessModifiers.js b/tests/baselines/reference/mixinAccessModifiers.js index ef2cc258dd7..2d158f6841e 100644 --- a/tests/baselines/reference/mixinAccessModifiers.js +++ b/tests/baselines/reference/mixinAccessModifiers.js @@ -105,6 +105,31 @@ class C6 extends Mix(Public, Public2) { C6.s } } + +class ProtectedGeneric { + private privateMethod() {} + protected protectedMethod() {} +} + +class ProtectedGeneric2 { + private privateMethod() {} + protected protectedMethod() {} +} + +function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>) { + x.privateMethod(); // Error, private constituent makes method inaccessible + x.protectedMethod(); // Error, protected when all constituents are protected +} + +function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}>) { + x.privateMethod(); // Error, private constituent makes method inaccessible + x.protectedMethod(); // Error, protected when all constituents are protected +} + +function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) { + x.privateMethod(); // Error, private constituent makes method inaccessible + x.protectedMethod(); // Error, protected when all constituents are protected +} //// [mixinAccessModifiers.js] @@ -266,6 +291,32 @@ var C6 = /** @class */ (function (_super) { }; return C6; }(Mix(Public, Public2))); +var ProtectedGeneric = /** @class */ (function () { + function ProtectedGeneric() { + } + ProtectedGeneric.prototype.privateMethod = function () { }; + ProtectedGeneric.prototype.protectedMethod = function () { }; + return ProtectedGeneric; +}()); +var ProtectedGeneric2 = /** @class */ (function () { + function ProtectedGeneric2() { + } + ProtectedGeneric2.prototype.privateMethod = function () { }; + ProtectedGeneric2.prototype.protectedMethod = function () { }; + return ProtectedGeneric2; +}()); +function f7(x) { + x.privateMethod(); // Error, private constituent makes method inaccessible + x.protectedMethod(); // Error, protected when all constituents are protected +} +function f8(x) { + x.privateMethod(); // Error, private constituent makes method inaccessible + x.protectedMethod(); // Error, protected when all constituents are protected +} +function f9(x) { + x.privateMethod(); // Error, private constituent makes method inaccessible + x.protectedMethod(); // Error, protected when all constituents are protected +} //// [mixinAccessModifiers.d.ts] @@ -329,3 +380,24 @@ declare class C6 extends C6_base { f(c4: C4, c5: C5, c6: C6): void; static g(): void; } +declare class ProtectedGeneric { + private privateMethod; + protected protectedMethod(): void; +} +declare class ProtectedGeneric2 { + private privateMethod; + protected protectedMethod(): void; +} +declare function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>): void; +declare function f8(x: ProtectedGeneric<{ + a: void; +}> & ProtectedGeneric2<{ + a: void; + b: void; +}>): void; +declare function f9(x: ProtectedGeneric<{ + a: void; +}> & ProtectedGeneric<{ + a: void; + b: void; +}>): void; diff --git a/tests/baselines/reference/mixinAccessModifiers.symbols b/tests/baselines/reference/mixinAccessModifiers.symbols index f9dd12cdd64..e0186264f93 100644 --- a/tests/baselines/reference/mixinAccessModifiers.symbols +++ b/tests/baselines/reference/mixinAccessModifiers.symbols @@ -328,3 +328,82 @@ class C6 extends Mix(Public, Public2) { } } +class ProtectedGeneric { +>ProtectedGeneric : Symbol(ProtectedGeneric, Decl(mixinAccessModifiers.ts, 105, 1)) +>T : Symbol(T, Decl(mixinAccessModifiers.ts, 107, 23)) + + private privateMethod() {} +>privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27)) + + protected protectedMethod() {} +>protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27)) +} + +class ProtectedGeneric2 { +>ProtectedGeneric2 : Symbol(ProtectedGeneric2, Decl(mixinAccessModifiers.ts, 110, 1)) +>T : Symbol(T, Decl(mixinAccessModifiers.ts, 112, 24)) + + private privateMethod() {} +>privateMethod : Symbol(ProtectedGeneric2.privateMethod, Decl(mixinAccessModifiers.ts, 112, 28)) + + protected protectedMethod() {} +>protectedMethod : Symbol(ProtectedGeneric2.protectedMethod, Decl(mixinAccessModifiers.ts, 113, 27)) +} + +function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>) { +>f7 : Symbol(f7, Decl(mixinAccessModifiers.ts, 115, 1)) +>x : Symbol(x, Decl(mixinAccessModifiers.ts, 117, 12)) +>ProtectedGeneric : Symbol(ProtectedGeneric, Decl(mixinAccessModifiers.ts, 105, 1)) +>ProtectedGeneric : Symbol(ProtectedGeneric, Decl(mixinAccessModifiers.ts, 105, 1)) + + x.privateMethod(); // Error, private constituent makes method inaccessible +>x.privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27)) +>x : Symbol(x, Decl(mixinAccessModifiers.ts, 117, 12)) +>privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27)) + + x.protectedMethod(); // Error, protected when all constituents are protected +>x.protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27)) +>x : Symbol(x, Decl(mixinAccessModifiers.ts, 117, 12)) +>protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27)) +} + +function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}>) { +>f8 : Symbol(f8, Decl(mixinAccessModifiers.ts, 120, 1)) +>x : Symbol(x, Decl(mixinAccessModifiers.ts, 122, 12)) +>ProtectedGeneric : Symbol(ProtectedGeneric, Decl(mixinAccessModifiers.ts, 105, 1)) +>a : Symbol(a, Decl(mixinAccessModifiers.ts, 122, 33)) +>ProtectedGeneric2 : Symbol(ProtectedGeneric2, Decl(mixinAccessModifiers.ts, 110, 1)) +>a : Symbol(a, Decl(mixinAccessModifiers.ts, 122, 65)) +>b : Symbol(b, Decl(mixinAccessModifiers.ts, 122, 72)) + + x.privateMethod(); // Error, private constituent makes method inaccessible +>x.privateMethod : Symbol(privateMethod, Decl(mixinAccessModifiers.ts, 107, 27), Decl(mixinAccessModifiers.ts, 112, 28)) +>x : Symbol(x, Decl(mixinAccessModifiers.ts, 122, 12)) +>privateMethod : Symbol(privateMethod, Decl(mixinAccessModifiers.ts, 107, 27), Decl(mixinAccessModifiers.ts, 112, 28)) + + x.protectedMethod(); // Error, protected when all constituents are protected +>x.protectedMethod : Symbol(protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27), Decl(mixinAccessModifiers.ts, 113, 27)) +>x : Symbol(x, Decl(mixinAccessModifiers.ts, 122, 12)) +>protectedMethod : Symbol(protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27), Decl(mixinAccessModifiers.ts, 113, 27)) +} + +function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) { +>f9 : Symbol(f9, Decl(mixinAccessModifiers.ts, 125, 1)) +>x : Symbol(x, Decl(mixinAccessModifiers.ts, 127, 12)) +>ProtectedGeneric : Symbol(ProtectedGeneric, Decl(mixinAccessModifiers.ts, 105, 1)) +>a : Symbol(a, Decl(mixinAccessModifiers.ts, 127, 33)) +>ProtectedGeneric : Symbol(ProtectedGeneric, Decl(mixinAccessModifiers.ts, 105, 1)) +>a : Symbol(a, Decl(mixinAccessModifiers.ts, 127, 64)) +>b : Symbol(b, Decl(mixinAccessModifiers.ts, 127, 71)) + + x.privateMethod(); // Error, private constituent makes method inaccessible +>x.privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27), Decl(mixinAccessModifiers.ts, 107, 27)) +>x : Symbol(x, Decl(mixinAccessModifiers.ts, 127, 12)) +>privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27), Decl(mixinAccessModifiers.ts, 107, 27)) + + x.protectedMethod(); // Error, protected when all constituents are protected +>x.protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27), Decl(mixinAccessModifiers.ts, 108, 27)) +>x : Symbol(x, Decl(mixinAccessModifiers.ts, 127, 12)) +>protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27), Decl(mixinAccessModifiers.ts, 108, 27)) +} + diff --git a/tests/baselines/reference/mixinAccessModifiers.types b/tests/baselines/reference/mixinAccessModifiers.types index 98b930f820c..ffa7b2b1e71 100644 --- a/tests/baselines/reference/mixinAccessModifiers.types +++ b/tests/baselines/reference/mixinAccessModifiers.types @@ -307,3 +307,80 @@ class C6 extends Mix(Public, Public2) { } } +class ProtectedGeneric { +>ProtectedGeneric : ProtectedGeneric + + private privateMethod() {} +>privateMethod : () => void + + protected protectedMethod() {} +>protectedMethod : () => void +} + +class ProtectedGeneric2 { +>ProtectedGeneric2 : ProtectedGeneric2 + + private privateMethod() {} +>privateMethod : () => void + + protected protectedMethod() {} +>protectedMethod : () => void +} + +function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>) { +>f7 : (x: ProtectedGeneric<{}>) => void +>x : ProtectedGeneric<{}> + + x.privateMethod(); // Error, private constituent makes method inaccessible +>x.privateMethod() : void +>x.privateMethod : () => void +>x : ProtectedGeneric<{}> +>privateMethod : () => void + + x.protectedMethod(); // Error, protected when all constituents are protected +>x.protectedMethod() : void +>x.protectedMethod : () => void +>x : ProtectedGeneric<{}> +>protectedMethod : () => void +} + +function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}>) { +>f8 : (x: ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>) => void +>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }> +>a : void +>a : void +>b : void + + x.privateMethod(); // Error, private constituent makes method inaccessible +>x.privateMethod() : void +>x.privateMethod : (() => void) & (() => void) +>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }> +>privateMethod : (() => void) & (() => void) + + x.protectedMethod(); // Error, protected when all constituents are protected +>x.protectedMethod() : void +>x.protectedMethod : (() => void) & (() => void) +>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }> +>protectedMethod : (() => void) & (() => void) +} + +function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) { +>f9 : (x: ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }>) => void +>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }> +>a : void +>a : void +>b : void + + x.privateMethod(); // Error, private constituent makes method inaccessible +>x.privateMethod() : void +>x.privateMethod : (() => void) & (() => void) +>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }> +>privateMethod : (() => void) & (() => void) + + x.protectedMethod(); // Error, protected when all constituents are protected +>x.protectedMethod() : void +>x.protectedMethod : (() => void) & (() => void) +>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }> +>protectedMethod : (() => void) & (() => void) +} + diff --git a/tests/baselines/reference/typeParameterExtendingUnion1.symbols b/tests/baselines/reference/typeParameterExtendingUnion1.symbols index 0538dcf91e0..cb36861feba 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion1.symbols +++ b/tests/baselines/reference/typeParameterExtendingUnion1.symbols @@ -33,9 +33,9 @@ function f(a: T) { >T : Symbol(T, Decl(typeParameterExtendingUnion1.ts, 8, 11)) a.run(); ->a.run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion1.ts, 8, 32)) ->run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) run(a); >run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 2, 33)) diff --git a/tests/baselines/reference/typeParameterExtendingUnion2.symbols b/tests/baselines/reference/typeParameterExtendingUnion2.symbols index f29f12f6f09..b9c2eed4034 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion2.symbols +++ b/tests/baselines/reference/typeParameterExtendingUnion2.symbols @@ -20,9 +20,9 @@ function run(a: Cat | Dog) { >Dog : Symbol(Dog, Decl(typeParameterExtendingUnion2.ts, 1, 33)) a.run(); ->a.run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion2.ts, 4, 13)) ->run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) } function f(a: T) { @@ -34,9 +34,9 @@ function f(a: T) { >T : Symbol(T, Decl(typeParameterExtendingUnion2.ts, 8, 11)) a.run(); ->a.run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion2.ts, 8, 32)) ->run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) run(a); >run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 2, 33)) diff --git a/tests/cases/conformance/classes/mixinAccessModifiers.ts b/tests/cases/conformance/classes/mixinAccessModifiers.ts index a628371eec6..554d8b6a312 100644 --- a/tests/cases/conformance/classes/mixinAccessModifiers.ts +++ b/tests/cases/conformance/classes/mixinAccessModifiers.ts @@ -106,3 +106,28 @@ class C6 extends Mix(Public, Public2) { C6.s } } + +class ProtectedGeneric { + private privateMethod() {} + protected protectedMethod() {} +} + +class ProtectedGeneric2 { + private privateMethod() {} + protected protectedMethod() {} +} + +function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>) { + x.privateMethod(); // Error, private constituent makes method inaccessible + x.protectedMethod(); // Error, protected when all constituents are protected +} + +function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}>) { + x.privateMethod(); // Error, private constituent makes method inaccessible + x.protectedMethod(); // Error, protected when all constituents are protected +} + +function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) { + x.privateMethod(); // Error, private constituent makes method inaccessible + x.protectedMethod(); // Error, protected when all constituents are protected +} diff --git a/tests/cases/fourslash/commentsUnion.ts b/tests/cases/fourslash/commentsUnion.ts index a54eaf076d7..616da3ea9d2 100644 --- a/tests/cases/fourslash/commentsUnion.ts +++ b/tests/cases/fourslash/commentsUnion.ts @@ -3,4 +3,4 @@ ////var a: Array | Array; ////a./*1*/length -verify.quickInfoAt("1", "(property) length: number", "Gets or sets the length of the array. This is a number one higher than the highest element defined in an array."); \ No newline at end of file +verify.quickInfoAt("1", "(property) Array.length: number", "Gets or sets the length of the array. This is a number one higher than the highest element defined in an array."); \ No newline at end of file diff --git a/tests/cases/fourslash/completionEntryForUnionMethod.ts b/tests/cases/fourslash/completionEntryForUnionMethod.ts index f8fd9ad9dc9..4daf989d314 100644 --- a/tests/cases/fourslash/completionEntryForUnionMethod.ts +++ b/tests/cases/fourslash/completionEntryForUnionMethod.ts @@ -5,7 +5,7 @@ goTo.marker(); verify.quickInfoIs( - "(property) map: ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | ((callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[])", + "(property) Array.map: ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | ((callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[])", "Calls a defined callback function on each element of an array, and returns an array that contains the results."); -verify.completionListContains('map', "(property) map: ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | ((callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[])"); \ No newline at end of file +verify.completionListContains('map', "(property) Array.map: ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | ((callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[])"); \ No newline at end of file From 2e993230e64297da493d2d5b4908fc22161c0561 Mon Sep 17 00:00:00 2001 From: Collins Abitekaniza Date: Tue, 16 Oct 2018 05:09:46 +0300 Subject: [PATCH 010/101] use decl key value if any --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9a443e6c444..a94f0c2cf9b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6288,7 +6288,7 @@ namespace ts { // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - const name = declarationNameToString(decl.name); + const name = (type).value || declarationNameToString(decl.name) forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_declaration_0, name)); error(decl.name || decl, Diagnostics.Duplicate_declaration_0, name); lateSymbol = createSymbol(SymbolFlags.None, memberName, CheckFlags.Late); From 66b299dc6ecdb3e54af946d0fc4a349cf0e9249d Mon Sep 17 00:00:00 2001 From: Collins Abitekaniza Date: Tue, 16 Oct 2018 05:17:14 +0300 Subject: [PATCH 011/101] refactor diagnostics --- src/compiler/checker.ts | 6 +++--- src/compiler/diagnosticMessages.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a94f0c2cf9b..c9065c96be1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6288,9 +6288,9 @@ namespace ts { // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - const name = (type).value || declarationNameToString(decl.name) - forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_declaration_0, name)); - error(decl.name || decl, Diagnostics.Duplicate_declaration_0, name); + const name = (type).value || declarationNameToString(decl.name); + forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_property_0, name)); + error(decl.name || decl, Diagnostics.Duplicate_property_0, name); lateSymbol = createSymbol(SymbolFlags.None, memberName, CheckFlags.Late); } lateSymbol.nameType = type; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 65a9e4bafb2..92ae359e1d2 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2425,7 +2425,7 @@ "category": "Error", "code": 2717 }, - "Duplicate declaration '{0}'.": { + "Duplicate property '{0}'.": { "category": "Error", "code": 2718 }, From f70f8eb70d00bc60cf1f6817962fa8ab4e176b9d Mon Sep 17 00:00:00 2001 From: Collins Abitekaniza Date: Tue, 16 Oct 2018 07:57:02 +0300 Subject: [PATCH 012/101] refactor baseline --- tests/baselines/reference/dynamicNamesErrors.errors.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/dynamicNamesErrors.errors.txt b/tests/baselines/reference/dynamicNamesErrors.errors.txt index 0d4f44a59f5..cdc5cef7f8d 100644 --- a/tests/baselines/reference/dynamicNamesErrors.errors.txt +++ b/tests/baselines/reference/dynamicNamesErrors.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2718: Duplicate declaration '[c0]'. -tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2718: Duplicate declaration '[c0]'. +tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2718: Duplicate property '1'. +tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2718: Duplicate property '1'. tests/cases/compiler/dynamicNamesErrors.ts(19,5): error TS2717: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'. tests/cases/compiler/dynamicNamesErrors.ts(24,1): error TS2322: Type 'T2' is not assignable to type 'T1'. Types of property '[c0]' are incompatible. @@ -16,10 +16,10 @@ tests/cases/compiler/dynamicNamesErrors.ts(25,1): error TS2322: Type 'T1' is not interface T0 { [c0]: number; ~~~~ -!!! error TS2718: Duplicate declaration '[c0]'. +!!! error TS2718: Duplicate property '1'. 1: number; ~ -!!! error TS2718: Duplicate declaration '[c0]'. +!!! error TS2718: Duplicate property '1'. } interface T1 { From d396830386f7adc1c2bb606f0dccb44884fe193c Mon Sep 17 00:00:00 2001 From: Collins Abitekaniza Date: Tue, 16 Oct 2018 21:48:47 +0300 Subject: [PATCH 013/101] add error showing where prop was also declared if is a dup --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 4 ++++ tests/baselines/reference/dynamicNamesErrors.errors.txt | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c9065c96be1..6c276eb8638 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6289,7 +6289,7 @@ namespace ts { // report an error at each declaration. const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; const name = (type).value || declarationNameToString(decl.name); - forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_property_0, name)); + forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name)); error(decl.name || decl, Diagnostics.Duplicate_property_0, name); lateSymbol = createSymbol(SymbolFlags.None, memberName, CheckFlags.Late); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 92ae359e1d2..941d3f6053c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2485,6 +2485,10 @@ "category": "Error", "code": 2732 }, + "Property '{0}' was also declared here.": { + "category": "Error", + "code": 2733 + }, "It is highly likely that you are missing a semicolon.": { "category": "Error", "code": 2734 diff --git a/tests/baselines/reference/dynamicNamesErrors.errors.txt b/tests/baselines/reference/dynamicNamesErrors.errors.txt index cdc5cef7f8d..c39140dbd52 100644 --- a/tests/baselines/reference/dynamicNamesErrors.errors.txt +++ b/tests/baselines/reference/dynamicNamesErrors.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2718: Duplicate property '1'. -tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2718: Duplicate property '1'. +tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2733: Property '1' was also declared here. tests/cases/compiler/dynamicNamesErrors.ts(19,5): error TS2717: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'. tests/cases/compiler/dynamicNamesErrors.ts(24,1): error TS2322: Type 'T2' is not assignable to type 'T1'. Types of property '[c0]' are incompatible. @@ -19,7 +19,7 @@ tests/cases/compiler/dynamicNamesErrors.ts(25,1): error TS2322: Type 'T1' is not !!! error TS2718: Duplicate property '1'. 1: number; ~ -!!! error TS2718: Duplicate property '1'. +!!! error TS2733: Property '1' was also declared here. } interface T1 { From 41908052d76a7bdf4312cfcdc390293b139dede5 Mon Sep 17 00:00:00 2001 From: Manish Bansal Date: Fri, 19 Oct 2018 23:12:23 +0530 Subject: [PATCH 014/101] Corrected the order of passing arguments to word2mdJs --- Gulpfile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gulpfile.js b/Gulpfile.js index 704fbba4447..7a009ea196e 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -26,7 +26,7 @@ const exec = require("./scripts/build/exec"); const browserify = require("./scripts/build/browserify"); const prepend = require("./scripts/build/prepend"); const { removeSourceMaps } = require("./scripts/build/sourcemaps"); -const { CancellationTokenSource, CancelError, delay, Semaphore } = require("prex"); +const { CancellationTokenSource, CancelError, delay, Semaphore } = require("prex"); const { libraryTargets, generateLibs } = require("./scripts/build/lib"); const { runConsoleTests, cleanTestDirs, writeTestConfigFile, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require("./scripts/build/tests"); @@ -273,7 +273,7 @@ gulp.task( // Generate Markdown spec const specMd = "doc/spec.md"; gulp.task(specMd, /*help*/ false, [word2mdJs], () => - exec("cscript", ["//nologo", word2mdJs, path.resolve(specMd), path.resolve("doc/TypeScript Language Specification.docx")])); + exec("cscript", ["//nologo", word2mdJs, path.resolve("doc/TypeScript Language Specification.docx"), path.resolve(specMd)])); gulp.task( "generate-spec", @@ -585,7 +585,7 @@ gulp.task( project.waitForWorkToStart().then(() => { source.cancel(); }); - + if (cmdLineOptions.tests || cmdLineOptions.failed) { await runConsoleTests(runJs, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true, source.token); } From 39e533a97ef4bbb2e6320264d463cf8c9f5ab829 Mon Sep 17 00:00:00 2001 From: Siddharth Singh Date: Mon, 22 Oct 2018 03:33:11 +0530 Subject: [PATCH 015/101] Typo fix Changed "mean" to "meant" --- src/lib/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/README.md b/src/lib/README.md index 93c62e317bf..1b51e2cfc64 100644 --- a/src/lib/README.md +++ b/src/lib/README.md @@ -4,5 +4,5 @@ The files within this directory are used to generate `lib.d.ts` and `lib.es6.d.t ## Generated files -Any files ending in `.generated.d.ts` aren't mean to be edited by hand. +Any files ending in `.generated.d.ts` aren't meant to be edited by hand. If you need to make changes to such files, make a change to the input files for [**our library generator**](https://github.com/Microsoft/TSJS-lib-generator). From f58d1737035b78e10bc5224e8b1e6e897901098d Mon Sep 17 00:00:00 2001 From: Sanket Mishra Date: Thu, 25 Oct 2018 10:00:51 +0530 Subject: [PATCH 016/101] Fixed typos in spec.md Changed 're-factoring' to 'refactoring'. Changed 'screen shot' to 'screenshot'. --- doc/spec.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/spec.md b/doc/spec.md index c6dd8cb4d06..edf8455ac54 100644 --- a/doc/spec.md +++ b/doc/spec.md @@ -239,7 +239,7 @@ TypeScript is a trademark of Microsoft Corporation. # 1 Introduction -JavaScript applications such as web e-mail, maps, document editing, and collaboration tools are becoming an increasingly important part of the everyday computing. We designed TypeScript to meet the needs of the JavaScript programming teams that build and maintain large JavaScript programs. TypeScript helps programming teams to define interfaces between software components and to gain insight into the behavior of existing JavaScript libraries. TypeScript also enables teams to reduce naming conflicts by organizing their code into dynamically-loadable modules. TypeScript's optional type system enables JavaScript programmers to use highly-productive development tools and practices: static checking, symbol-based navigation, statement completion, and code re-factoring. +JavaScript applications such as web e-mail, maps, document editing, and collaboration tools are becoming an increasingly important part of the everyday computing. We designed TypeScript to meet the needs of the JavaScript programming teams that build and maintain large JavaScript programs. TypeScript helps programming teams to define interfaces between software components and to gain insight into the behavior of existing JavaScript libraries. TypeScript also enables teams to reduce naming conflicts by organizing their code into dynamically-loadable modules. TypeScript's optional type system enables JavaScript programmers to use highly-productive development tools and practices: static checking, symbol-based navigation, statement completion, and code refactoring. TypeScript is a syntactic sugar for JavaScript. TypeScript syntax is a superset of ECMAScript 2015 (ES2015) syntax. Every JavaScript program is also a TypeScript program. The TypeScript compiler performs only file-local transformations on TypeScript programs and does not re-order variables declared in TypeScript. This leads to JavaScript output that closely matches the TypeScript input. TypeScript does not transform variable names, making tractable the direct debugging of emitted JavaScript. TypeScript optionally provides source maps, enabling source-level debugging. TypeScript tools typically emit JavaScript upon file save, preserving the test, edit, refresh cycle commonly used in JavaScript development. @@ -263,7 +263,7 @@ function f() { } ``` -To benefit from this inference, a programmer can use the TypeScript language service. For example, a code editor can incorporate the TypeScript language service and use the service to find the members of a string object as in the following screen shot. +To benefit from this inference, a programmer can use the TypeScript language service. For example, a code editor can incorporate the TypeScript language service and use the service to find the members of a string object as in the following screenshot.   ![](images/image1.png) @@ -411,7 +411,7 @@ We mentioned above that the '$' function behaves differently depending on the ty This signature denotes that a function may be passed as the parameter of the '$' function. When a function is passed to '$', the jQuery library will invoke that function when a DOM document is ready. Because TypeScript supports overloading, tools can use TypeScript to show all available function signatures with their documentation tips and to give the correct documentation once a function has been called with a particular signature. -A typical client would not need to add any additional typing but could just use a community-supplied typing to discover (through statement completion with documentation tips) and verify (through static checking) correct use of the library, as in the following screen shot. +A typical client would not need to add any additional typing but could just use a community-supplied typing to discover (through statement completion with documentation tips) and verify (through static checking) correct use of the library, as in the following screenshot.   ![](images/image2.png) @@ -628,7 +628,7 @@ JavaScript implementations can use these explicit constants to generate efficien An important goal of TypeScript is to provide accurate and straightforward types for existing JavaScript programming patterns. To that end, TypeScript includes generic types, discussed in the next section, and *overloading on string parameters*, the topic of this section. -JavaScript programming interfaces often include functions whose behavior is discriminated by a string constant passed to the function. The Document Object Model makes heavy use of this pattern. For example, the following screen shot shows that the 'createElement' method of the 'document' object has multiple signatures, some of which identify the types returned when specific strings are passed into the method. +JavaScript programming interfaces often include functions whose behavior is discriminated by a string constant passed to the function. The Document Object Model makes heavy use of this pattern. For example, the following screenshot shows that the 'createElement' method of the 'document' object has multiple signatures, some of which identify the types returned when specific strings are passed into the method.   ![](images/image3.png) @@ -639,7 +639,7 @@ var span = document.createElement("span"); span.isMultiLine = false; // OK: HTMLSpanElement has isMultiline property ``` -In the following screen shot, a programming tool combines information from overloading on string parameters with contextual typing to infer that the type of the variable 'e' is 'MouseEvent' and that therefore 'e' has a 'clientX' property. +In the following screenshot, a programming tool combines information from overloading on string parameters with contextual typing to infer that the type of the variable 'e' is 'MouseEvent' and that therefore 'e' has a 'clientX' property.   ![](images/image4.png) From 1ec54f3b7fa58f4114a014147176e8a08baeacf3 Mon Sep 17 00:00:00 2001 From: superkd37 <42697593+superkd37@users.noreply.github.com> Date: Sat, 27 Oct 2018 20:39:23 +0530 Subject: [PATCH 017/101] Update .mailmap --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index 5b591eb4615..cb3334a9404 100644 --- a/.mailmap +++ b/.mailmap @@ -121,6 +121,7 @@ Ken Howard Kevin Lang kimamula # Kenji Imamula Kitson Kelly +Krishnadas Babu Klaus Meinhardt Kyle Kelley Lorant Pinter From fb5127f62d8a6fdeb586e83d3c94504a000b3b76 Mon Sep 17 00:00:00 2001 From: Andrey Roenko Date: Tue, 20 Nov 2018 20:58:14 +0300 Subject: [PATCH 018/101] Accept version change 3.2 => 3.3 in baselines --- tests/baselines/reference/api/tsserverlibrary.d.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index e67f6d36447..2b78178587e 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.2"; + const versionMajorMinor = "3.3"; /** The version of the TypeScript compiler release */ const version: string; } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index eb1e1760dfd..0e693f698f2 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.2"; + const versionMajorMinor = "3.3"; /** The version of the TypeScript compiler release */ const version: string; } From c70cd38e98f98756186a640332c9bdcd8b91825a Mon Sep 17 00:00:00 2001 From: Alexander T Date: Thu, 25 Oct 2018 18:38:13 +0300 Subject: [PATCH 019/101] --downlevelIteration errors should mention using later targets --- src/compiler/checker.ts | 2 +- tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4305227dab7..78726896a95 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25209,7 +25209,7 @@ namespace ts { ? downlevelIteration ? Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator : isIterable - ? Diagnostics.Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators + ? Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators : Diagnostics.Type_0_is_not_an_array_type : downlevelIteration ? Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator diff --git a/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt index 3a03491f110..316a7a63a3b 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts(2,17): error TS2568: Type 'Set' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts(2,17): error TS2568: Type 'Set' is not an array type. Either use the '--downlevelIteration' compiler option to allow iterating on iterators, or set the '--target' option to 'es2015' or above. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts (1 errors) ==== var union: string | Set for (const e of union) { } ~~~~~ -!!! error TS2568: Type 'Set' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators. \ No newline at end of file +!!! error TS2568: Type 'Set' is not an array type. Either use the '--downlevelIteration' compiler option to allow iterating on iterators, or set the '--target' option to 'es2015' or above. \ No newline at end of file From 7eff4b2eb0c66197e97e1e9b961d8335d4e7e317 Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 18 Dec 2018 08:52:21 +0200 Subject: [PATCH 020/101] update baseline --- tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt index 316a7a63a3b..1fde67722db 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts(2,17): error TS2568: Type 'Set' is not an array type. Either use the '--downlevelIteration' compiler option to allow iterating on iterators, or set the '--target' option to 'es2015' or above. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts(2,17): error TS2569: Type 'Set' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts (1 errors) ==== var union: string | Set for (const e of union) { } ~~~~~ -!!! error TS2568: Type 'Set' is not an array type. Either use the '--downlevelIteration' compiler option to allow iterating on iterators, or set the '--target' option to 'es2015' or above. \ No newline at end of file +!!! error TS2569: Type 'Set' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. \ No newline at end of file From 0cabb00b343f4acfee112eaaa4ea737383b494c2 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 14 Dec 2018 15:13:19 -0800 Subject: [PATCH 021/101] Use watch factory instead of direct host functions in tsbuild to provide detailed information on watch invokations --- src/compiler/tsbuild.ts | 55 +++++++++++++++++++++++----------- src/compiler/watch.ts | 49 ++++++++++++++++++++---------- src/compiler/watchUtilities.ts | 8 ++--- src/server/editorServices.ts | 19 ++---------- src/server/project.ts | 4 +-- src/server/utilities.ts | 11 +++++++ 6 files changed, 92 insertions(+), 54 deletions(-) diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index f1e194e307d..8b06070a925 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -443,6 +443,7 @@ namespace ts { let nextProjectToBuild = 0; let timerToBuildInvalidatedProject: any; let reportFileChangeDetected = false; + const { watchFile, watchFilePath, watchDirectory } = createWatchFactory(host, options); // Watches for the solution const allWatchedWildcardDirectories = createFileMap>(toPath); @@ -542,9 +543,16 @@ namespace ts { function watchConfigFile(resolved: ResolvedConfigFileName) { if (options.watch && !allWatchedConfigFiles.hasKey(resolved)) { - allWatchedConfigFiles.setValue(resolved, hostWithWatch.watchFile(resolved, () => { + allWatchedConfigFiles.setValue(resolved, watchFile( + hostWithWatch, + resolved, + () => { invalidateProjectAndScheduleBuilds(resolved, ConfigFileProgramReloadLevel.Full); - })); + }, + PollingInterval.High, + WatchType.ConfigFile, + resolved + )); } } @@ -554,20 +562,27 @@ namespace ts { getOrCreateValueMapFromConfigFileMap(allWatchedWildcardDirectories, resolved), createMapFromTemplate(parsed.configFileSpecs!.wildcardDirectories), (dir, flags) => { - return hostWithWatch.watchDirectory(dir, fileOrDirectory => { - const fileOrDirectoryPath = toPath(fileOrDirectory); - if (fileOrDirectoryPath !== toPath(dir) && hasExtension(fileOrDirectoryPath) && !isSupportedSourceFileName(fileOrDirectory, parsed.options)) { - // writeLog(`Project: ${configFileName} Detected file add/remove of non supported extension: ${fileOrDirectory}`); - return; - } + return watchDirectory( + hostWithWatch, + dir, + fileOrDirectory => { + const fileOrDirectoryPath = toPath(fileOrDirectory); + if (fileOrDirectoryPath !== toPath(dir) && hasExtension(fileOrDirectoryPath) && !isSupportedSourceFileName(fileOrDirectory, parsed.options)) { + // writeLog(`Project: ${configFileName} Detected file add/remove of non supported extension: ${fileOrDirectory}`); + return; + } - if (isOutputFile(fileOrDirectory, parsed)) { - // writeLog(`${fileOrDirectory} is output file`); - return; - } + if (isOutputFile(fileOrDirectory, parsed)) { + // writeLog(`${fileOrDirectory} is output file`); + return; + } - invalidateProjectAndScheduleBuilds(resolved, ConfigFileProgramReloadLevel.Partial); - }, !!(flags & WatchDirectoryFlags.Recursive)); + invalidateProjectAndScheduleBuilds(resolved, ConfigFileProgramReloadLevel.Partial); + }, + flags, + WatchType.WildcardDirectory, + resolved + ); } ); } @@ -578,9 +593,15 @@ namespace ts { getOrCreateValueMapFromConfigFileMap(allWatchedInputFiles, resolved), arrayToMap(parsed.fileNames, toPath), { - createNewValue: (_key, input) => hostWithWatch.watchFile(input, () => { - invalidateProjectAndScheduleBuilds(resolved, ConfigFileProgramReloadLevel.None); - }), + createNewValue: (path, input) => watchFilePath( + hostWithWatch, + input, + () => invalidateProjectAndScheduleBuilds(resolved, ConfigFileProgramReloadLevel.None), + PollingInterval.Low, + path as Path, + WatchType.SourceFile, + resolved + ), onDeleteValue: closeFileWatcher, } ); diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 7a5c12cae4e..4112271307c 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -194,6 +194,30 @@ namespace ts { }; } + export const enum WatchType { + ConfigFile = "Config file", + SourceFile = "Source file", + MissingFile = "Missing file", + WildcardDirectory = "Wild card directory", + FailedLookupLocations = "Failed Lookup Locations", + TypeRoots = "Type roots" + } + + interface WatchFactory extends ts.WatchFactory { + watchLogLevel: WatchLogLevel; + writeLog: (s: string) => void; + } + + export function createWatchFactory(host: { trace?(s: string): void; }, options: { extendedDiagnostics?: boolean; diagnostics?: boolean; }) { + const watchLogLevel = host.trace ? options.extendedDiagnostics ? WatchLogLevel.Verbose : + options.diagnostics ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None; + const writeLog: (s: string) => void = watchLogLevel !== WatchLogLevel.None ? (s => host.trace!(s)) : noop; + const result = getWatchFactory(watchLogLevel, writeLog) as WatchFactory; + result.watchLogLevel = watchLogLevel; + result.writeLog = writeLog; + return result; + } + /** * Creates the watch compiler host that can be extended with config file or root file names and options host */ @@ -224,7 +248,7 @@ namespace ts { watchDirectory, setTimeout, clearTimeout, - trace: s => system.write(s), + trace: s => system.write(s + system.newLine), onWatchStatusChange, createDirectory: path => system.createDirectory(path), writeFile: (path, data, writeByteOrderMark) => system.writeFile(path, data, writeByteOrderMark), @@ -517,17 +541,12 @@ namespace ts { newLine = updateNewLine(); } - const trace = host.trace && ((s: string) => { host.trace!(s + newLine); }); - const watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? WatchLogLevel.Verbose : - compilerOptions.diagnostics ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None; - const writeLog: (s: string) => void = watchLogLevel !== WatchLogLevel.None ? trace! : noop; // TODO: GH#18217 - const { watchFile, watchFilePath, watchDirectory } = getWatchFactory(watchLogLevel, writeLog); - + const { watchFile, watchFilePath, watchDirectory, watchLogLevel, writeLog } = createWatchFactory(host, compilerOptions); const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); writeLog(`Current directory: ${currentDirectory} CaseSensitiveFileNames: ${useCaseSensitiveFileNames}`); if (configFileName) { - watchFile(host, configFileName, scheduleProgramReload, PollingInterval.High, "Config file"); + watchFile(host, configFileName, scheduleProgramReload, PollingInterval.High, WatchType.ConfigFile); } const compilerHost: CompilerHost & ResolutionCacheHost = { @@ -543,7 +562,7 @@ namespace ts { getNewLine: () => newLine, fileExists, readFile, - trace, + trace: host.trace && (s => host.trace!(s)), directoryExists: directoryStructureHost.directoryExists && (path => directoryStructureHost.directoryExists!(path)), getDirectories: (directoryStructureHost.getDirectories && ((path: string) => directoryStructureHost.getDirectories!(path)))!, // TODO: GH#18217 realpath: host.realpath && (s => host.realpath!(s)), @@ -553,8 +572,8 @@ namespace ts { // Members for ResolutionCacheHost toPath, getCompilationSettings: () => compilerOptions, - watchDirectoryOfFailedLookupLocation: (dir, cb, flags) => watchDirectory(host, dir, cb, flags, "Failed Lookup Locations"), - watchTypeRootsDirectory: (dir, cb, flags) => watchDirectory(host, dir, cb, flags, "Type roots"), + watchDirectoryOfFailedLookupLocation: (dir, cb, flags) => watchDirectory(host, dir, cb, flags, WatchType.FailedLookupLocations), + watchTypeRootsDirectory: (dir, cb, flags) => watchDirectory(host, dir, cb, flags, WatchType.TypeRoots), getCachedDirectoryStructureHost: () => cachedDirectoryStructureHost, onInvalidatedResolution: scheduleProgramUpdate, onChangedAutomaticTypeDirectiveNames: () => { @@ -719,7 +738,7 @@ namespace ts { (hostSourceFile as FilePresentOnHost).sourceFile = sourceFile; sourceFile.version = hostSourceFile.version.toString(); if (!(hostSourceFile as FilePresentOnHost).fileWatcher) { - (hostSourceFile as FilePresentOnHost).fileWatcher = watchFilePath(host, fileName, onSourceFileChange, PollingInterval.Low, path, "Source file"); + (hostSourceFile as FilePresentOnHost).fileWatcher = watchFilePath(host, fileName, onSourceFileChange, PollingInterval.Low, path, WatchType.SourceFile); } } else { @@ -733,7 +752,7 @@ namespace ts { else { if (sourceFile) { sourceFile.version = initialVersion.toString(); - const fileWatcher = watchFilePath(host, fileName, onSourceFileChange, PollingInterval.Low, path, "Source file"); + const fileWatcher = watchFilePath(host, fileName, onSourceFileChange, PollingInterval.Low, path, WatchType.SourceFile); sourceFilesCache.set(path, { sourceFile, version: initialVersion, fileWatcher }); } else { @@ -907,7 +926,7 @@ namespace ts { } function watchMissingFilePath(missingFilePath: Path) { - return watchFilePath(host, missingFilePath, onMissingFileChange, PollingInterval.Medium, missingFilePath, "Missing file"); + return watchFilePath(host, missingFilePath, onMissingFileChange, PollingInterval.Medium, missingFilePath, WatchType.MissingFile); } function onMissingFileChange(fileName: string, eventKind: FileWatcherEventKind, missingFilePath: Path) { @@ -971,7 +990,7 @@ namespace ts { } }, flags, - "Wild card directories" + WatchType.WildcardDirectory ); } diff --git a/src/compiler/watchUtilities.ts b/src/compiler/watchUtilities.ts index 8fa04e52da3..9bf242e07e8 100644 --- a/src/compiler/watchUtilities.ts +++ b/src/compiler/watchUtilities.ts @@ -343,10 +343,10 @@ namespace ts { export interface WatchDirectoryHost { watchDirectory(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher; } - export type WatchFile = (host: WatchFileHost, file: string, callback: FileWatcherCallback, pollingInterval: PollingInterval, detailInfo1?: X, detailInfo2?: Y) => FileWatcher; + export type WatchFile = (host: WatchFileHost, file: string, callback: FileWatcherCallback, pollingInterval: PollingInterval, detailInfo1: X, detailInfo2?: Y) => FileWatcher; export type FilePathWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind, filePath: Path) => void; - export type WatchFilePath = (host: WatchFileHost, file: string, callback: FilePathWatcherCallback, pollingInterval: PollingInterval, path: Path, detailInfo1?: X, detailInfo2?: Y) => FileWatcher; - export type WatchDirectory = (host: WatchDirectoryHost, directory: string, callback: DirectoryWatcherCallback, flags: WatchDirectoryFlags, detailInfo1?: X, detailInfo2?: Y) => FileWatcher; + export type WatchFilePath = (host: WatchFileHost, file: string, callback: FilePathWatcherCallback, pollingInterval: PollingInterval, path: Path, detailInfo1: X, detailInfo2?: Y) => FileWatcher; + export type WatchDirectory = (host: WatchDirectoryHost, directory: string, callback: DirectoryWatcherCallback, flags: WatchDirectoryFlags, detailInfo1: X, detailInfo2?: Y) => FileWatcher; export interface WatchFactory { watchFile: WatchFile; @@ -444,7 +444,7 @@ namespace ts { } function getWatchInfo(file: string, flags: T, detailInfo1: X, detailInfo2: Y | undefined, getDetailWatchInfo: GetDetailWatchInfo | undefined) { - return `WatchInfo: ${file} ${flags} ${getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo1}`; + return `WatchInfo: ${file} ${flags} ${getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : `${detailInfo1} ${detailInfo2}`}`; } export function closeFileWatcherOf(objWithWatcher: T) { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 3050c976231..7256e46d577 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -332,19 +332,6 @@ namespace ts.server { } } - /* @internal */ - export const enum WatchType { - ConfigFilePath = "Config file for the program", - MissingFilePath = "Missing file from program", - WildcardDirectories = "Wild card directory", - ClosedScriptInfo = "Closed Script info", - ConfigFileForInferredRoot = "Config file for the inferred project root", - FailedLookupLocation = "Directory of Failed lookup locations in module resolution", - TypeRoots = "Type root directory", - NodeModulesForClosedScriptInfo = "node_modules for closed script infos in them", - MissingSourceMapFile = "Missing source map file" - } - const enum ConfigFileWatcherStatus { ReloadingFiles = "Reloading configured projects for files", ReloadingInferredRootFiles = "Reloading configured projects for only inferred root files", @@ -1035,7 +1022,7 @@ namespace ts.server { } }, flags, - WatchType.WildcardDirectories, + WatchType.WildcardDirectory, project ); } @@ -1338,7 +1325,7 @@ namespace ts.server { watches.push(WatchType.ConfigFileForInferredRoot); } if (this.configuredProjects.has(canonicalConfigFilePath)) { - watches.push(WatchType.ConfigFilePath); + watches.push(WatchType.ConfigFile); } this.logger.info(`ConfigFilePresence:: Current Watches: ${watches}:: File: ${configFileName} Currently impacted open files: RootsOfInferredProjects: ${inferredRoots} OtherOpenFiles: ${otherFiles} Status: ${status}`); } @@ -1705,7 +1692,7 @@ namespace ts.server { configFileName, (_fileName, eventKind) => this.onConfigChangedForConfiguredProject(project, eventKind), PollingInterval.High, - WatchType.ConfigFilePath, + WatchType.ConfigFile, project ); this.configuredProjects.set(project.canonicalConfigFilePath, project); diff --git a/src/server/project.ts b/src/server/project.ts index e3069e1d183..b296668e6ae 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -428,7 +428,7 @@ namespace ts.server { directory, cb, flags, - WatchType.FailedLookupLocation, + WatchType.FailedLookupLocations, this ); } @@ -989,7 +989,7 @@ namespace ts.server { } }, PollingInterval.Medium, - WatchType.MissingFilePath, + WatchType.MissingFile, this ); return fileWatcher; diff --git a/src/server/utilities.ts b/src/server/utilities.ts index 15b217822c0..04ce9f4e420 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -217,3 +217,14 @@ namespace ts.server { return indentStr + JSON.stringify(json); } } + +/* @internal */ +namespace ts { + // Additional tsserver specific watch information + export const enum WatchType { + ClosedScriptInfo = "Closed Script info", + ConfigFileForInferredRoot = "Config file for the inferred project root", + NodeModulesForClosedScriptInfo = "node_modules for closed script infos in them", + MissingSourceMapFile = "Missing source map file", + } +} From 9e05abcfd3f8bb3d6775144ede807daceab2e321 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 14 Dec 2018 16:51:18 -0800 Subject: [PATCH 022/101] Make BuilderProgram as Program --- src/compiler/builder.ts | 85 +++++-------------- src/compiler/core.ts | 4 + src/compiler/program.ts | 2 +- src/compiler/tsbuild.ts | 3 +- src/compiler/watch.ts | 17 +--- .../reference/api/tsserverlibrary.d.ts | 34 +------- tests/baselines/reference/api/typescript.d.ts | 34 +------- 7 files changed, 30 insertions(+), 149 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 637e77c545f..ce12373960a 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -411,21 +411,13 @@ namespace ts { oldProgram = undefined; oldState = undefined; - const result: BuilderProgram = { - getState: () => state, - getProgram: () => state.program, - getCompilerOptions: () => state.program.getCompilerOptions(), - getSourceFile: fileName => state.program.getSourceFile(fileName), - getSourceFiles: () => state.program.getSourceFiles(), - getOptionsDiagnostics: cancellationToken => state.program.getOptionsDiagnostics(cancellationToken), - getGlobalDiagnostics: cancellationToken => state.program.getGlobalDiagnostics(cancellationToken), - getConfigFileParsingDiagnostics: () => configFileParsingDiagnostics || state.program.getConfigFileParsingDiagnostics(), - getSyntacticDiagnostics: (sourceFile, cancellationToken) => state.program.getSyntacticDiagnostics(sourceFile, cancellationToken), - getSemanticDiagnostics, - emit, - getAllDependencies: sourceFile => BuilderState.getAllDependencies(state, state.program, sourceFile), - getCurrentDirectory: () => state.program.getCurrentDirectory() - }; + const result = createRedirectObject(state.program) as BuilderProgram; + result.getState = () => state; + result.getProgram = () => state.program; + result.getAllDependencies = sourceFile => BuilderState.getAllDependencies(state, state.program, sourceFile); + result.getConfigFileParsingDiagnostics = () => configFileParsingDiagnostics; + result.getSemanticDiagnostics = getSemanticDiagnostics; + result.emit = emit; if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) { (result as SemanticDiagnosticsBuilderProgram).getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile; @@ -595,45 +587,20 @@ namespace ts { /** * Builder to manage the program state changes */ - export interface BuilderProgram { + export interface BuilderProgram extends Program { /*@internal*/ getState(): BuilderProgramState; /** * Returns current program */ getProgram(): Program; - /** - * Get compiler options of the program - */ - getCompilerOptions(): CompilerOptions; - /** - * Get the source file in the program with file name - */ - getSourceFile(fileName: string): SourceFile | undefined; - /** - * Get a list of files in the program - */ - getSourceFiles(): ReadonlyArray; - /** - * Get the diagnostics for compiler options - */ - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - /** - * Get the diagnostics that dont belong to any file - */ - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - /** - * Get the diagnostics from config file parsing - */ - getConfigFileParsingDiagnostics(): ReadonlyArray; - /** - * Get the syntax diagnostics, for all source files if source file is not supplied - */ - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; /** * Get all the dependencies of the file */ getAllDependencies(sourceFile: SourceFile): ReadonlyArray; + + // These two are same signatures but because the doc comments are useful they are retained + /** * Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program * The semantic diagnostics are cached and managed here @@ -655,10 +622,6 @@ namespace ts { * in that order would be used to write the files */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - /** - * Get the current directory of the program - */ - getCurrentDirectory(): string; } /** @@ -710,22 +673,14 @@ namespace ts { export function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; export function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram; export function createAbstractBuilder(newProgramOrRootNames: Program | ReadonlyArray | undefined, hostOrOptions: BuilderProgramHost | CompilerOptions | undefined, oldProgramOrHost?: CompilerHost | BuilderProgram, configFileParsingDiagnosticsOrOldProgram?: ReadonlyArray | BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram { - const { newProgram: program } = getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences); - return { - // Only return program, all other methods are not implemented - getProgram: () => program, - getState: notImplemented, - getCompilerOptions: notImplemented, - getSourceFile: notImplemented, - getSourceFiles: notImplemented, - getOptionsDiagnostics: notImplemented, - getGlobalDiagnostics: notImplemented, - getConfigFileParsingDiagnostics: notImplemented, - getSyntacticDiagnostics: notImplemented, - getSemanticDiagnostics: notImplemented, - emit: notImplemented, - getAllDependencies: notImplemented, - getCurrentDirectory: notImplemented - }; + const { newProgram, configFileParsingDiagnostics: newConfigFileParsingDiagnostics } = getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences); + const builderProgram = createRedirectObject(newProgram) as BuilderProgram; + builderProgram.getState = notImplemented; + builderProgram.getProgram = () => newProgram; + builderProgram.getAllDependencies = notImplemented; + + // Always return latest config file diagnostics + builderProgram.getConfigFileParsingDiagnostics = () => newConfigFileParsingDiagnostics; + return builderProgram; } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index cb9e385b366..76bf4a314b6 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1370,6 +1370,10 @@ namespace ts { return result; } + export function createRedirectObject(redirectTarget: T): T { + return Object.create(redirectTarget); + } + export function extend(first: T1, second: T2): T1 & T2 { const result: T1 & T2 = {}; for (const id in second) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 080b17b8cbe..b388e70353e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2180,7 +2180,7 @@ namespace ts { } function createRedirectSourceFile(redirectTarget: SourceFile, unredirected: SourceFile, fileName: string, path: Path, resolvedPath: Path, originalFileName: string): SourceFile { - const redirect: SourceFile = Object.create(redirectTarget); + const redirect = createRedirectObject(redirectTarget); redirect.fileName = fileName; redirect.path = path; redirect.resolvedPath = resolvedPath; diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 8b06070a925..47d8106a457 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -1065,8 +1065,9 @@ namespace ts { // Don't emit anything in the presence of syntactic errors or options diagnostics const syntaxDiagnostics = [ - ...program.getOptionsDiagnostics(), ...program.getConfigFileParsingDiagnostics(), + ...program.getOptionsDiagnostics(), + ...program.getGlobalDiagnostics(), ...program.getSyntacticDiagnostics()]; if (syntaxDiagnostics.length) { return buildErrors(syntaxDiagnostics, BuildResultFlags.SyntaxErrors, "Syntactic"); diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 4112271307c..2fbda3fde8a 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -88,21 +88,6 @@ namespace ts { return result; } - /** - * Program structure needed to emit the files and report diagnostics - */ - export interface ProgramToEmitFilesAndReportErrors { - getCurrentDirectory(): string; - getCompilerOptions(): CompilerOptions; - getSourceFiles(): ReadonlyArray; - getSyntacticDiagnostics(): ReadonlyArray; - getOptionsDiagnostics(): ReadonlyArray; - getGlobalDiagnostics(): ReadonlyArray; - getSemanticDiagnostics(): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; - } - export type ReportEmitErrorSummary = (errorCount: number) => void; export function getErrorCountForSummary(diagnostics: ReadonlyArray) { @@ -124,7 +109,7 @@ namespace ts { /** * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ - export function emitFilesAndReportErrors(program: ProgramToEmitFilesAndReportErrors, reportDiagnostic: DiagnosticReporter, writeFileName?: (s: string) => void, reportSummary?: ReportEmitErrorSummary, writeFile?: WriteFileCallback) { + export function emitFilesAndReportErrors(program: Program, reportDiagnostic: DiagnosticReporter, writeFileName?: (s: string) => void, reportSummary?: ReportEmitErrorSummary, writeFile?: WriteFileCallback) { // First get and report any syntactic errors. const diagnostics = program.getConfigFileParsingDiagnostics().slice(); const configFileParsingDiagnosticsLength = diagnostics.length; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 91f492ddd1d..d5b2c020e74 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4245,39 +4245,11 @@ declare namespace ts { /** * Builder to manage the program state changes */ - interface BuilderProgram { + interface BuilderProgram extends Program { /** * Returns current program */ getProgram(): Program; - /** - * Get compiler options of the program - */ - getCompilerOptions(): CompilerOptions; - /** - * Get the source file in the program with file name - */ - getSourceFile(fileName: string): SourceFile | undefined; - /** - * Get a list of files in the program - */ - getSourceFiles(): ReadonlyArray; - /** - * Get the diagnostics for compiler options - */ - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - /** - * Get the diagnostics that dont belong to any file - */ - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - /** - * Get the diagnostics from config file parsing - */ - getConfigFileParsingDiagnostics(): ReadonlyArray; - /** - * Get the syntax diagnostics, for all source files if source file is not supplied - */ - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; /** * Get all the dependencies of the file */ @@ -4303,10 +4275,6 @@ declare namespace ts { * in that order would be used to write the files */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - /** - * Get the current directory of the program - */ - getCurrentDirectory(): string; } /** * The builder that caches the semantic diagnostics for the program and handles the changed files and affected files diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 0e693f698f2..3d6e4feb106 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -4245,39 +4245,11 @@ declare namespace ts { /** * Builder to manage the program state changes */ - interface BuilderProgram { + interface BuilderProgram extends Program { /** * Returns current program */ getProgram(): Program; - /** - * Get compiler options of the program - */ - getCompilerOptions(): CompilerOptions; - /** - * Get the source file in the program with file name - */ - getSourceFile(fileName: string): SourceFile | undefined; - /** - * Get a list of files in the program - */ - getSourceFiles(): ReadonlyArray; - /** - * Get the diagnostics for compiler options - */ - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - /** - * Get the diagnostics that dont belong to any file - */ - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - /** - * Get the diagnostics from config file parsing - */ - getConfigFileParsingDiagnostics(): ReadonlyArray; - /** - * Get the syntax diagnostics, for all source files if source file is not supplied - */ - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; /** * Get all the dependencies of the file */ @@ -4303,10 +4275,6 @@ declare namespace ts { * in that order would be used to write the files */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - /** - * Get the current directory of the program - */ - getCurrentDirectory(): string; } /** * The builder that caches the semantic diagnostics for the program and handles the changed files and affected files From 48baa42d655aa1fdea1ab3dcb9ee3a7e15b7de91 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 18 Dec 2018 16:12:37 -0800 Subject: [PATCH 023/101] Make SolutionBuilder handle BuilderProgram in preparation to handle incremental builds --- src/compiler/core.ts | 8 + src/compiler/program.ts | 91 ++++--- src/compiler/tsbuild.ts | 83 +++--- src/compiler/types.ts | 2 +- src/compiler/watch.ts | 242 +++++++++--------- src/harness/fakes.ts | 4 +- .../unittests/config/projectReferences.ts | 2 +- src/testRunner/unittests/tsbuild.ts | 2 +- src/tsc/tsc.ts | 18 +- .../reference/api/tsserverlibrary.d.ts | 10 +- tests/baselines/reference/api/typescript.d.ts | 10 +- 11 files changed, 252 insertions(+), 220 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 76bf4a314b6..17f6c6f4fc3 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1391,6 +1391,14 @@ namespace ts { return result; } + export function copyProperities(first: T1, second: T2) { + for (const id in second) { + if (hasOwnProperty.call(second, id)) { + (first as any)[id] = second[id]; + } + } + } + export interface MultiMap extends Map { /** * Adds the value to an array of values associated with the key, and returns the array. diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b388e70353e..6c132ad417d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -69,6 +69,7 @@ namespace ts { export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost { return createCompilerHostWorker(options, setParentNodes); } + /*@internal*/ // TODO(shkamat): update this after reworking ts build API export function createCompilerHostWorker(options: CompilerOptions, setParentNodes?: boolean, system = sys): CompilerHost { @@ -93,7 +94,6 @@ namespace ts { } text = ""; } - return text !== undefined ? createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; } @@ -203,18 +203,25 @@ namespace ts { return compilerHost; } + interface ComplierHostLikeForCache { + fileExists(fileName: string): boolean; + readFile(fileName: string, encoding?: string): string | undefined; + directoryExists?(directory: string): boolean; + createDirectory?(directory: string): void; + writeFile?: WriteFileCallback; + } + /*@internal*/ - export function changeCompilerHostToUseCache( - host: CompilerHost, + export function changeCompilerHostLikeToUseCache( + host: ComplierHostLikeForCache, toPath: (fileName: string) => Path, - useCacheForSourceFile: boolean + getSourceFile?: CompilerHost["getSourceFile"] ) { const originalReadFile = host.readFile; const originalFileExists = host.fileExists; const originalDirectoryExists = host.directoryExists; const originalCreateDirectory = host.createDirectory; const originalWriteFile = host.writeFile; - const originalGetSourceFile = host.getSourceFile; const readFileCache = createMap(); const fileExistsCache = createMap(); const directoryExistsCache = createMap(); @@ -242,19 +249,17 @@ namespace ts { return setReadFileCache(key, fileName); }; - if (useCacheForSourceFile) { - host.getSourceFile = (fileName, languageVersion, onError, shouldCreateNewSourceFile) => { - const key = toPath(fileName); - const value = sourceFileCache.get(key); - if (value) return value; + const getSourceFileWithCache: CompilerHost["getSourceFile"] | undefined = getSourceFile ? (fileName, languageVersion, onError, shouldCreateNewSourceFile) => { + const key = toPath(fileName); + const value = sourceFileCache.get(key); + if (value) return value; - const sourceFile = originalGetSourceFile.call(host, fileName, languageVersion, onError, shouldCreateNewSourceFile); - if (sourceFile && (isDeclarationFileName(fileName) || fileExtensionIs(fileName, Extension.Json))) { - sourceFileCache.set(key, sourceFile); - } - return sourceFile; - }; - } + const sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile); + if (sourceFile && (isDeclarationFileName(fileName) || fileExtensionIs(fileName, Extension.Json))) { + sourceFileCache.set(key, sourceFile); + } + return sourceFile; + } : undefined; // fileExists for any kind of extension host.fileExists = fileName => { @@ -265,23 +270,25 @@ namespace ts { fileExistsCache.set(key, !!newValue); return newValue; }; - host.writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => { - const key = toPath(fileName); - fileExistsCache.delete(key); + if (originalWriteFile) { + host.writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => { + const key = toPath(fileName); + fileExistsCache.delete(key); - const value = readFileCache.get(key); - if (value && value !== data) { - readFileCache.delete(key); - sourceFileCache.delete(key); - } - else if (useCacheForSourceFile) { - const sourceFile = sourceFileCache.get(key); - if (sourceFile && sourceFile.text !== data) { + const value = readFileCache.get(key); + if (value && value !== data) { + readFileCache.delete(key); sourceFileCache.delete(key); } - } - originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles); - }; + else if (getSourceFileWithCache) { + const sourceFile = sourceFileCache.get(key); + if (sourceFile && sourceFile.text !== data) { + sourceFileCache.delete(key); + } + } + originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles); + }; + } // directoryExists if (originalDirectoryExists && originalCreateDirectory) { @@ -306,7 +313,7 @@ namespace ts { originalDirectoryExists, originalCreateDirectory, originalWriteFile, - originalGetSourceFile, + getSourceFileWithCache, readFileWithCache }; } @@ -735,7 +742,7 @@ namespace ts { performance.mark("beforeProgram"); const host = createProgramOptions.host || createCompilerHost(options); - const configParsingHost = parseConfigHostFromCompilerHost(host); + const configParsingHost = parseConfigHostFromCompilerHostLike(host); let skipDefaultLib = options.noLib; const getDefaultLibraryFileName = memoize(() => host.getDefaultLibFileName(options)); @@ -3101,18 +3108,28 @@ namespace ts { } } + interface CompilerHostLike { + useCaseSensitiveFileNames(): boolean; + getCurrentDirectory(): string; + fileExists(fileName: string): boolean; + readFile(fileName: string): string | undefined; + readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; + trace?(s: string): void; + onUnRecoverableConfigFileDiagnostic?: DiagnosticReporter; + } + /* @internal */ - export function parseConfigHostFromCompilerHost(host: CompilerHost): ParseConfigFileHost { + export function parseConfigHostFromCompilerHostLike(host: CompilerHostLike, directoryStructureHost: DirectoryStructureHost = host): ParseConfigFileHost { return { fileExists: f => host.fileExists(f), readDirectory(root, extensions, excludes, includes, depth) { - Debug.assertDefined(host.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'"); - return host.readDirectory!(root, extensions, excludes, includes, depth); + Debug.assertDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'"); + return directoryStructureHost.readDirectory!(root, extensions, excludes, includes, depth); }, readFile: f => host.readFile(f), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: () => host.getCurrentDirectory(), - onUnRecoverableConfigFileDiagnostic: () => undefined, + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || (() => undefined), trace: host.trace ? (s) => host.trace!(s) : undefined }; } diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 47d8106a457..bc0a2f87680 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -321,7 +321,7 @@ namespace ts { return fileExtensionIs(fileName, Extension.Dts); } - export interface SolutionBuilderHostBase extends CompilerHost { + export interface SolutionBuilderHostBase extends ProgramHost { getModifiedTime(fileName: string): Date | undefined; setModifiedTime(fileName: string, date: Date): void; deleteFile(fileName: string): void; @@ -331,15 +331,14 @@ namespace ts { // TODO: To do better with watch mode and normal build mode api that creates program and emits files // This currently helps enable --diagnostics and --extendedDiagnostics - beforeCreateProgram?(options: CompilerOptions): void; afterProgramEmitAndDiagnostics?(program: Program): void; } - export interface SolutionBuilderHost extends SolutionBuilderHostBase { + export interface SolutionBuilderHost extends SolutionBuilderHostBase { reportErrorSummary?: ReportEmitErrorSummary; } - export interface SolutionBuilderWithWatchHost extends SolutionBuilderHostBase, WatchHost { + export interface SolutionBuilderWithWatchHost extends SolutionBuilderHostBase, WatchHost { } export interface SolutionBuilder { @@ -372,30 +371,29 @@ namespace ts { }; } - function createSolutionBuilderHostBase(system = sys, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter) { - const host = createCompilerHostWorker({}, /*setParentNodes*/ undefined, system) as SolutionBuilderHostBase; + function createSolutionBuilderHostBase(system: System, createProgram: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter) { + const host = createProgramHost(system, createProgram) as SolutionBuilderHostBase; host.getModifiedTime = system.getModifiedTime ? path => system.getModifiedTime!(path) : () => undefined; host.setModifiedTime = system.setModifiedTime ? (path, date) => system.setModifiedTime!(path, date) : noop; host.deleteFile = system.deleteFile ? path => system.deleteFile!(path) : noop; host.reportDiagnostic = reportDiagnostic || createDiagnosticReporter(system); host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system); return host; + + // TODO after program create } - export function createSolutionBuilderHost(system = sys, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary) { - const host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus) as SolutionBuilderHost; + export function createSolutionBuilderHost(system = sys, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary) { + const host = createSolutionBuilderHostBase(system, createProgram || createAbstractBuilder as any as CreateProgram, reportDiagnostic, reportSolutionBuilderStatus) as SolutionBuilderHost; host.reportErrorSummary = reportErrorSummary; return host; } - export function createSolutionBuilderWithWatchHost(system?: System, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter) { - const host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus) as SolutionBuilderWithWatchHost; + // TODO: we should use emit and semantic diagnostics builder but that needs to handle errors little differently so handle it later + export function createSolutionBuilderWithWatchHost(system = sys, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter) { + const host = createSolutionBuilderHostBase(system, createProgram || createSemanticDiagnosticsBuilderProgram as any as CreateProgram, reportDiagnostic, reportSolutionBuilderStatus) as SolutionBuilderWithWatchHost; const watchHost = createWatchHost(system, reportWatchStatus); - host.onWatchStatusChange = watchHost.onWatchStatusChange; - host.watchFile = watchHost.watchFile; - host.watchDirectory = watchHost.watchDirectory; - host.setTimeout = watchHost.setTimeout; - host.clearTimeout = watchHost.clearTimeout; + copyProperities(host, watchHost); return host; } @@ -413,13 +411,13 @@ namespace ts { * TODO: use SolutionBuilderWithWatchHost => watchedSolution * use SolutionBuilderHost => Solution */ - export function createSolutionBuilder(host: SolutionBuilderHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; - export function createSolutionBuilder(host: SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilderWithWatch; - export function createSolutionBuilder(host: SolutionBuilderHost | SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilderWithWatch { - const hostWithWatch = host as SolutionBuilderWithWatchHost; + export function createSolutionBuilder(host: SolutionBuilderHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; + export function createSolutionBuilder(host: SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilderWithWatch; + export function createSolutionBuilder(host: SolutionBuilderHost | SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilderWithWatch { + const hostWithWatch = host as SolutionBuilderWithWatchHost; const currentDirectory = host.getCurrentDirectory(); const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames()); - const parseConfigFileHost = parseConfigHostFromCompilerHost(host); + const parseConfigFileHost = parseConfigHostFromCompilerHostLike(host); // State of the solution let options = defaultOptions; @@ -434,6 +432,8 @@ namespace ts { let globalDependencyGraph: DependencyGraph | undefined; const writeFileName = (s: string) => host.trace && host.trace(s); let readFileWithCache = (f: string) => host.readFile(f); + let projectCompilerOptions = baseCompilerOptions; + const compilerHost = createCompilerHostFromProgramHost(host, () => projectCompilerOptions); // Watch state const diagnostics = createFileMap>(toPath); @@ -919,7 +919,7 @@ namespace ts { } function reportErrorSummary() { - if (options.watch || (host as SolutionBuilderHost).reportErrorSummary) { + if (options.watch || (host as SolutionBuilderHost).reportErrorSummary) { // Report errors from the other projects getGlobalDependencyGraph().buildQueue.forEach(project => { if (!projectErrorsReported.hasKey(project)) { @@ -932,7 +932,7 @@ namespace ts { reportWatchStatus(getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } else { - (host as SolutionBuilderHost).reportErrorSummary!(totalErrors); + (host as SolutionBuilderHost).reportErrorSummary!(totalErrors); } } } @@ -1051,17 +1051,17 @@ namespace ts { return BuildResultFlags.None; } - const programOptions: CreateProgramOptions = { - projectReferences: configFile.projectReferences, - host, - rootNames: configFile.fileNames, - options: configFile.options, - configFileParsingDiagnostics: configFile.errors - }; - if (host.beforeCreateProgram) { - host.beforeCreateProgram(options); - } - const program = createProgram(programOptions); + // TODO: handle resolve module name to cache result in project reference redirect + projectCompilerOptions = configFile.options; + const program = host.createProgram( + configFile.fileNames, + configFile.options, + compilerHost, + /*oldProgram*/ undefined, + configFile.errors, + configFile.projectReferences + ); + projectCompilerOptions = baseCompilerOptions; // Don't emit anything in the presence of syntactic errors or options diagnostics const syntaxDiagnostics = [ @@ -1105,7 +1105,7 @@ namespace ts { } } - writeFile(host, emitterDiagnostics, name, text, writeByteOrderMark); + writeFile(compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); if (priorChangeTime !== undefined) { newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime); unchangedOutputs.setValue(name, priorChangeTime); @@ -1209,12 +1209,15 @@ namespace ts { if (options.watch) { reportWatchStatus(Diagnostics.Starting_compilation_in_watch_mode); } // TODO:: In watch mode as well to use caches for incremental build once we can invalidate caches correctly and have right api // Override readFile for json files and output .d.ts to cache the text - const { originalReadFile, originalFileExists, originalDirectoryExists, - originalCreateDirectory, originalWriteFile, originalGetSourceFile, - readFileWithCache: newReadFileWithCache - } = changeCompilerHostToUseCache(host, toPath, /*useCacheForSourceFile*/ true); const savedReadFileWithCache = readFileWithCache; + const savedGetSourceFile = compilerHost.getSourceFile; + + const { originalReadFile, originalFileExists, originalDirectoryExists, + originalCreateDirectory, originalWriteFile, getSourceFileWithCache, + readFileWithCache: newReadFileWithCache + } = changeCompilerHostLikeToUseCache(host, toPath, (...args) => savedGetSourceFile.call(compilerHost, ...args)); readFileWithCache = newReadFileWithCache; + compilerHost.getSourceFile = getSourceFileWithCache!; const graph = getGlobalDependencyGraph(); reportBuildQueue(graph); @@ -1271,8 +1274,8 @@ namespace ts { host.directoryExists = originalDirectoryExists; host.createDirectory = originalCreateDirectory; host.writeFile = originalWriteFile; + compilerHost.getSourceFile = savedGetSourceFile; readFileWithCache = savedReadFileWithCache; - host.getSourceFile = originalGetSourceFile; return anyFailed ? ExitStatus.DiagnosticsPresent_OutputsSkipped : ExitStatus.Success; } @@ -1300,7 +1303,7 @@ namespace ts { } function relName(path: string): string { - return convertToRelativePath(path, host.getCurrentDirectory(), f => host.getCanonicalFileName(f)); + return convertToRelativePath(path, host.getCurrentDirectory(), f => compilerHost.getCanonicalFileName(f)); } /** diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b70b4e4d3d0..de444eea885 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2827,7 +2827,7 @@ namespace ts { fileName: string, data: string, writeByteOrderMark: boolean, - onError: ((message: string) => void) | undefined, + onError?: (message: string) => void, sourceFiles?: ReadonlyArray, ) => void; diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 2fbda3fde8a..a29d54ac981 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -203,23 +203,81 @@ namespace ts { return result; } + export function createCompilerHostFromProgramHost(host: ProgramHost, getCompilerOptions: () => CompilerOptions, directoryStructureHost: DirectoryStructureHost = host): CompilerHost { + const useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); + return { + getSourceFile: (fileName, languageVersion, onError) => { + let text: string | undefined; + try { + performance.mark("beforeIORead"); + text = host.readFile(fileName, getCompilerOptions().charset); + performance.mark("afterIORead"); + performance.measure("I/O Read", "beforeIORead", "afterIORead"); + } + catch (e) { + if (onError) { + onError(e.message); + } + text = ""; + } + + return text !== undefined ? createSourceFile(fileName, text, languageVersion) : undefined; + }, + getDefaultLibLocation: host.getDefaultLibLocation && (() => host.getDefaultLibLocation!()), + getDefaultLibFileName: options => host.getDefaultLibFileName(options), + writeFile, + getCurrentDirectory: memoize(() => host.getCurrentDirectory()), + useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, + getCanonicalFileName: createGetCanonicalFileName(useCaseSensitiveFileNames), + getNewLine: memoize(() => getNewLineCharacter(getCompilerOptions(), () => host.getNewLine())), + fileExists: f => host.fileExists(f), + readFile: f => host.readFile(f), + trace: host.trace && (s => host.trace!(s)), + directoryExists: directoryStructureHost.directoryExists && (path => directoryStructureHost.directoryExists!(path)), + getDirectories: (directoryStructureHost.getDirectories && ((path: string) => directoryStructureHost.getDirectories!(path)))!, // TODO: GH#18217 + realpath: host.realpath && (s => host.realpath!(s)), + getEnvironmentVariable: host.getEnvironmentVariable ? (name => host.getEnvironmentVariable!(name)) : (() => ""), + createHash: host.createHash && (data => host.createHash!(data)), + readDirectory: (path, extensions, exclude, include, depth?) => directoryStructureHost.readDirectory!(path, extensions, exclude, include, depth), + }; + + function ensureDirectoriesExist(directoryPath: string) { + if (directoryPath.length > getRootLength(directoryPath) && !host.directoryExists!(directoryPath)) { + const parentDirectory = getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + if (host.createDirectory) host.createDirectory(directoryPath); + } + } + + function writeFile(fileName: string, text: string, writeByteOrderMark: boolean, onError: (message: string) => void) { + try { + performance.mark("beforeIOWrite"); + ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName))); + + host.writeFile!(fileName, text, writeByteOrderMark); + + performance.mark("afterIOWrite"); + performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite"); + } + catch (e) { + if (onError) { + onError(e.message); + } + } + } + } + /** * Creates the watch compiler host that can be extended with config file or root file names and options host */ - function createWatchCompilerHost(system = sys, createProgram: CreateProgram | undefined, reportDiagnostic: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHost { - if (!createProgram) { - createProgram = createEmitAndSemanticDiagnosticsBuilderProgram as any as CreateProgram; - } - + export function createProgramHost(system: System, createProgram: CreateProgram): ProgramHost { + const getDefaultLibLocation = memoize(() => getDirectoryPath(normalizePath(system.getExecutingFilePath()))); let host: DirectoryStructureHost = system; host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) - const useCaseSensitiveFileNames = () => system.useCaseSensitiveFileNames; - const writeFileName = (s: string) => system.write(s + system.newLine); - const { onWatchStatusChange, watchFile, watchDirectory, setTimeout, clearTimeout } = createWatchHost(system, reportWatchStatus); return { - useCaseSensitiveFileNames, + useCaseSensitiveFileNames: () => system.useCaseSensitiveFileNames, getNewLine: () => system.newLine, - getCurrentDirectory: () => system.getCurrentDirectory(), + getCurrentDirectory: memoize(() => system.getCurrentDirectory()), getDefaultLibLocation, getDefaultLibFileName: options => combinePaths(getDefaultLibLocation(), getDefaultLibFileName(options)), fileExists: path => system.fileExists(path), @@ -229,25 +287,23 @@ namespace ts { readDirectory: (path, extensions, exclude, include, depth) => system.readDirectory(path, extensions, exclude, include, depth), realpath: system.realpath && (path => system.realpath!(path)), getEnvironmentVariable: system.getEnvironmentVariable && (name => system.getEnvironmentVariable(name)), - watchFile, - watchDirectory, - setTimeout, - clearTimeout, trace: s => system.write(s + system.newLine), - onWatchStatusChange, createDirectory: path => system.createDirectory(path), writeFile: (path, data, writeByteOrderMark) => system.writeFile(path, data, writeByteOrderMark), onCachedDirectoryStructureHostCreate: cacheHost => host = cacheHost || system, createHash: system.createHash && (s => system.createHash!(s)), - createProgram, - afterProgramCreate: emitFilesAndReportErrorUsingBuilder + createProgram }; + } - function getDefaultLibLocation() { - return getDirectoryPath(normalizePath(system.getExecutingFilePath())); - } - - function emitFilesAndReportErrorUsingBuilder(builderProgram: BuilderProgram) { + /** + * Creates the watch compiler host that can be extended with config file or root file names and options host + */ + function createWatchCompilerHost(system = sys, createProgram: CreateProgram | undefined, reportDiagnostic: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHost { + const writeFileName = (s: string) => system.write(s + system.newLine); + const result = createProgramHost(system, createProgram || createEmitAndSemanticDiagnosticsBuilderProgram as any as CreateProgram) as WatchCompilerHost; + copyProperities(result, createWatchHost(system, reportWatchStatus)); + result.afterProgramCreate = builderProgram => { const compilerOptions = builderProgram.getCompilerOptions(); const newLine = getNewLineCharacter(compilerOptions, () => system.newLine); @@ -255,13 +311,14 @@ namespace ts { builderProgram, reportDiagnostic, writeFileName, - errorCount => onWatchStatusChange!( + errorCount => result.onWatchStatusChange!( createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions ) ); - } + }; + return result; } /** @@ -300,6 +357,7 @@ namespace ts { export type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; /** Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program */ export type CreateProgram = (rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray | undefined) => T; + /** Host that has watch functionality used in --watch mode */ export interface WatchHost { /** If provided, called with Diagnostic message that informs about change in watch status */ @@ -314,19 +372,11 @@ namespace ts { /** If provided, will be used to reset existing delayed compilation */ clearTimeout?(timeoutId: any): void; } - export interface WatchCompilerHost extends WatchHost { - // TODO: GH#18217 Optional methods are frequently asserted - + export interface ProgramHost { /** * Used to create the program when need for program creation or recreation detected */ createProgram: CreateProgram; - /** If provided, callback to invoke after every new program creation */ - afterProgramCreate?(program: T): void; - - // Only for testing - /*@internal*/ - maxNumberOfFilesToIterateForInvalidation?: number; // Sub set of compiler host methods to read and generate new program useCaseSensitiveFileNames(): boolean; @@ -366,16 +416,25 @@ namespace ts { /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; } - /** Internal interface used to wire emit through same host */ + /*@internal*/ - export interface WatchCompilerHost { + export interface ProgramHost { // TODO: GH#18217 Optional methods are frequently asserted createDirectory?(path: string): void; writeFile?(path: string, data: string, writeByteOrderMark?: boolean): void; onCachedDirectoryStructureHostCreate?(host: CachedDirectoryStructureHost): void; } + export interface WatchCompilerHost extends ProgramHost, WatchHost { + /** If provided, callback to invoke after every new program creation */ + afterProgramCreate?(program: T): void; + + // Only for testing + /*@internal*/ + maxNumberOfFilesToIterateForInvalidation?: number; + } + /** * Host to create watch with root files and options */ @@ -488,8 +547,6 @@ namespace ts { const useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); const currentDirectory = host.getCurrentDirectory(); - const getCurrentDirectory = () => currentDirectory; - const readFile: (path: string, encoding?: string) => string | undefined = (path, encoding) => host.readFile(path, encoding); const { configFileName, optionsToExtend: optionsToExtendForConfigFile = {}, createProgram } = host; let { rootFiles: rootFileNames, options: compilerOptions, projectReferences } = host; let configFileSpecs: ConfigFileSpecs; @@ -502,15 +559,7 @@ namespace ts { host.onCachedDirectoryStructureHostCreate(cachedDirectoryStructureHost); } const directoryStructureHost: DirectoryStructureHost = cachedDirectoryStructureHost || host; - const parseConfigFileHost: ParseConfigFileHost = { - useCaseSensitiveFileNames, - readDirectory: (path, extensions, exclude, include, depth) => directoryStructureHost.readDirectory!(path, extensions, exclude, include, depth), - fileExists: path => host.fileExists(path), - readFile, - getCurrentDirectory, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic, - trace: host.trace ? s => host.trace!(s) : undefined - }; + const parseConfigFileHost = parseConfigHostFromCompilerHostLike(host, directoryStructureHost); // From tsc we want to get already parsed result and hence check for rootFileNames let newLine = updateNewLine(); @@ -534,42 +583,29 @@ namespace ts { watchFile(host, configFileName, scheduleProgramReload, PollingInterval.High, WatchType.ConfigFile); } - const compilerHost: CompilerHost & ResolutionCacheHost = { - // Members for CompilerHost - getSourceFile: (fileName, languageVersion, onError?, shouldCreateNewSourceFile?) => getVersionedSourceFileByPath(fileName, toPath(fileName), languageVersion, onError, shouldCreateNewSourceFile), - getSourceFileByPath: getVersionedSourceFileByPath, - getDefaultLibLocation: host.getDefaultLibLocation && (() => host.getDefaultLibLocation!()), - getDefaultLibFileName: options => host.getDefaultLibFileName(options), - writeFile, - getCurrentDirectory, - useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, - getCanonicalFileName, - getNewLine: () => newLine, - fileExists, - readFile, - trace: host.trace && (s => host.trace!(s)), - directoryExists: directoryStructureHost.directoryExists && (path => directoryStructureHost.directoryExists!(path)), - getDirectories: (directoryStructureHost.getDirectories && ((path: string) => directoryStructureHost.getDirectories!(path)))!, // TODO: GH#18217 - realpath: host.realpath && (s => host.realpath!(s)), - getEnvironmentVariable: host.getEnvironmentVariable ? (name => host.getEnvironmentVariable!(name)) : (() => ""), - onReleaseOldSourceFile, - createHash: host.createHash && (data => host.createHash!(data)), - // Members for ResolutionCacheHost - toPath, - getCompilationSettings: () => compilerOptions, - watchDirectoryOfFailedLookupLocation: (dir, cb, flags) => watchDirectory(host, dir, cb, flags, WatchType.FailedLookupLocations), - watchTypeRootsDirectory: (dir, cb, flags) => watchDirectory(host, dir, cb, flags, WatchType.TypeRoots), - getCachedDirectoryStructureHost: () => cachedDirectoryStructureHost, - onInvalidatedResolution: scheduleProgramUpdate, - onChangedAutomaticTypeDirectiveNames: () => { - hasChangedAutomaticTypeDirectiveNames = true; - scheduleProgramUpdate(); - }, - maxNumberOfFilesToIterateForInvalidation: host.maxNumberOfFilesToIterateForInvalidation, - getCurrentProgram, - writeLog, - readDirectory: (path, extensions, exclude, include, depth?) => directoryStructureHost.readDirectory!(path, extensions, exclude, include, depth), + const compilerHost = createCompilerHostFromProgramHost(host, () => compilerOptions, directoryStructureHost) as CompilerHost & ResolutionCacheHost; + // Members for CompilerHost + const getNewSourceFile = compilerHost.getSourceFile; + compilerHost.getSourceFile = (fileName, ...args) => getVersionedSourceFileByPath(fileName, toPath(fileName), ...args); + compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; + compilerHost.getNewLine = () => newLine; + compilerHost.fileExists = fileExists; + compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile; + // Members for ResolutionCacheHost + compilerHost.toPath = toPath; + compilerHost.getCompilationSettings = () => compilerOptions; + compilerHost.watchDirectoryOfFailedLookupLocation = (dir, cb, flags) => watchDirectory(host, dir, cb, flags, WatchType.FailedLookupLocations); + compilerHost.watchTypeRootsDirectory = (dir, cb, flags) => watchDirectory(host, dir, cb, flags, WatchType.TypeRoots); + compilerHost.getCachedDirectoryStructureHost = () => cachedDirectoryStructureHost; + compilerHost.onInvalidatedResolution = scheduleProgramUpdate; + compilerHost.onChangedAutomaticTypeDirectiveNames = () => { + hasChangedAutomaticTypeDirectiveNames = true; + scheduleProgramUpdate(); }; + compilerHost.maxNumberOfFilesToIterateForInvalidation = host.maxNumberOfFilesToIterateForInvalidation; + compilerHost.getCurrentProgram = getCurrentProgram; + compilerHost.writeLog = writeLog; + // Cache for the module resolution const resolutionCache = createResolutionCache(compilerHost, configFileName ? getDirectoryPath(getNormalizedAbsolutePath(configFileName, currentDirectory)) : @@ -712,7 +748,7 @@ namespace ts { // Create new source file if requested or the versions dont match if (!hostSourceFile || shouldCreateNewSourceFile || !isFilePresentOnHost(hostSourceFile) || hostSourceFile.version.toString() !== hostSourceFile.sourceFile.version) { - const sourceFile = getNewSourceFile(); + const sourceFile = getNewSourceFile.call(compilerHost, fileName, languageVersion, onError); if (hostSourceFile) { if (shouldCreateNewSourceFile) { hostSourceFile.version++; @@ -747,23 +783,6 @@ namespace ts { return sourceFile; } return hostSourceFile.sourceFile; - - function getNewSourceFile() { - let text: string | undefined; - try { - performance.mark("beforeIORead"); - text = host.readFile(fileName, compilerOptions.charset); - performance.mark("afterIORead"); - performance.measure("I/O Read", "beforeIORead", "afterIORead"); - } - catch (e) { - if (onError) { - onError(e.message); - } - } - - return text !== undefined ? createSourceFile(fileName, text, languageVersion) : undefined; - } } function nextSourceFileVersion(path: Path) { @@ -978,30 +997,5 @@ namespace ts { WatchType.WildcardDirectory ); } - - function ensureDirectoriesExist(directoryPath: string) { - if (directoryPath.length > getRootLength(directoryPath) && !host.directoryExists!(directoryPath)) { - const parentDirectory = getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - host.createDirectory!(directoryPath); - } - } - - function writeFile(fileName: string, text: string, writeByteOrderMark: boolean, onError: (message: string) => void) { - try { - performance.mark("beforeIOWrite"); - ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName))); - - host.writeFile!(fileName, text, writeByteOrderMark); - - performance.mark("afterIOWrite"); - performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite"); - } - catch (e) { - if (onError) { - onError(e.message); - } - } - } } } diff --git a/src/harness/fakes.ts b/src/harness/fakes.ts index d25211d36d3..6119dd153b9 100644 --- a/src/harness/fakes.ts +++ b/src/harness/fakes.ts @@ -375,7 +375,9 @@ namespace fakes { } } - export class SolutionBuilderHost extends CompilerHost implements ts.SolutionBuilderHost { + export class SolutionBuilderHost extends CompilerHost implements ts.SolutionBuilderHost { + createProgram = ts.createAbstractBuilder; + diagnostics: ts.Diagnostic[] = []; reportDiagnostic(diagnostic: ts.Diagnostic) { diff --git a/src/testRunner/unittests/config/projectReferences.ts b/src/testRunner/unittests/config/projectReferences.ts index 266b016c681..6c8863314fa 100644 --- a/src/testRunner/unittests/config/projectReferences.ts +++ b/src/testRunner/unittests/config/projectReferences.ts @@ -85,7 +85,7 @@ namespace ts { // We shouldn't have any errors about invalid tsconfig files in these tests assert(config && !error, flattenDiagnosticMessageText(error && error.messageText, "\n")); - const file = parseJsonConfigFileContent(config, parseConfigHostFromCompilerHost(host), getDirectoryPath(entryPointConfigFileName), {}, entryPointConfigFileName); + const file = parseJsonConfigFileContent(config, parseConfigHostFromCompilerHostLike(host), getDirectoryPath(entryPointConfigFileName), {}, entryPointConfigFileName); file.options.configFilePath = entryPointConfigFileName; const prog = createProgram({ rootNames: file.fileNames, diff --git a/src/testRunner/unittests/tsbuild.ts b/src/testRunner/unittests/tsbuild.ts index bf628e10598..4a3f259cc34 100644 --- a/src/testRunner/unittests/tsbuild.ts +++ b/src/testRunner/unittests/tsbuild.ts @@ -265,7 +265,7 @@ export class cNew {}`); // Build downstream projects should update 'tests', but not 'core' tick(); builder.buildInvalidatedProject(); - assert.isBelow(fs.statSync("/src/tests/index.js").mtimeMs, time(), "Downstream JS file should have been rebuilt"); + assert.equal(fs.statSync("/src/tests/index.js").mtimeMs, time(), "Downstream JS file should have been rebuilt"); assert.isBelow(fs.statSync("/src/core/index.js").mtimeMs, time(), "Upstream JS file should not have been rebuilt"); }); }); diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index 9d363dc4715..a9d961a14d6 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -206,9 +206,9 @@ namespace ts { // TODO: change this to host if watch => watchHost otherwiue without watch const buildHost = buildOptions.watch ? - createSolutionBuilderWithWatchHost(sys, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()) : - createSolutionBuilderHost(sys, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createReportErrorSummary(buildOptions)); - buildHost.beforeCreateProgram = enableStatistics; + createSolutionBuilderWithWatchHost(sys, createSemanticDiagnosticsBuilderProgram, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()) : + createSolutionBuilderHost(sys, createAbstractBuilder, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createReportErrorSummary(buildOptions)); + updateCreateProgram(buildHost); buildHost.afterProgramEmitAndDiagnostics = reportStatistics; const builder = createSolutionBuilder(buildHost, projects, buildOptions); @@ -234,7 +234,7 @@ namespace ts { const host = createCompilerHost(options); const currentDirectory = host.getCurrentDirectory(); const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames()); - changeCompilerHostToUseCache(host, fileName => toPath(fileName, currentDirectory, getCanonicalFileName), /*useCacheForSourceFile*/ false); + changeCompilerHostLikeToUseCache(host, fileName => toPath(fileName, currentDirectory, getCanonicalFileName)); enableStatistics(options); const programOptions: CreateProgramOptions = { @@ -255,15 +255,19 @@ namespace ts { return sys.exit(exitStatus); } - function updateWatchCompilationHost(watchCompilerHost: WatchCompilerHost) { - const compileUsingBuilder = watchCompilerHost.createProgram; - watchCompilerHost.createProgram = (rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) => { + function updateCreateProgram(host: { createProgram: CreateProgram; }) { + const compileUsingBuilder = host.createProgram; + host.createProgram = (rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) => { Debug.assert(rootNames !== undefined || (options === undefined && !!oldProgram)); if (options !== undefined) { enableStatistics(options); } return compileUsingBuilder(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences); }; + } + + function updateWatchCompilationHost(watchCompilerHost: WatchCompilerHost) { + updateCreateProgram(watchCompilerHost); const emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate!; // TODO: GH#18217 watchCompilerHost.afterProgramCreate = builderProgram => { emitFilesUsingBuilder(builderProgram); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index d5b2c020e74..3b1e45b0bfa 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1778,7 +1778,7 @@ declare namespace ts { type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles?: ReadonlyArray) => void; + type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray) => void; class OperationCanceledException { } interface CancellationToken { @@ -4332,13 +4332,11 @@ declare namespace ts { /** If provided, will be used to reset existing delayed compilation */ clearTimeout?(timeoutId: any): void; } - interface WatchCompilerHost extends WatchHost { + interface ProgramHost { /** * Used to create the program when need for program creation or recreation detected */ createProgram: CreateProgram; - /** If provided, callback to invoke after every new program creation */ - afterProgramCreate?(program: T): void; useCaseSensitiveFileNames(): boolean; getNewLine(): string; getCurrentDirectory(): string; @@ -4372,6 +4370,10 @@ declare namespace ts { /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; } + interface WatchCompilerHost extends ProgramHost, WatchHost { + /** If provided, callback to invoke after every new program creation */ + afterProgramCreate?(program: T): void; + } /** * Host to create watch with root files and options */ diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 3d6e4feb106..4e1b769378e 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1778,7 +1778,7 @@ declare namespace ts { type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles?: ReadonlyArray) => void; + type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray) => void; class OperationCanceledException { } interface CancellationToken { @@ -4332,13 +4332,11 @@ declare namespace ts { /** If provided, will be used to reset existing delayed compilation */ clearTimeout?(timeoutId: any): void; } - interface WatchCompilerHost extends WatchHost { + interface ProgramHost { /** * Used to create the program when need for program creation or recreation detected */ createProgram: CreateProgram; - /** If provided, callback to invoke after every new program creation */ - afterProgramCreate?(program: T): void; useCaseSensitiveFileNames(): boolean; getNewLine(): string; getCurrentDirectory(): string; @@ -4372,6 +4370,10 @@ declare namespace ts { /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; } + interface WatchCompilerHost extends ProgramHost, WatchHost { + /** If provided, callback to invoke after every new program creation */ + afterProgramCreate?(program: T): void; + } /** * Host to create watch with root files and options */ From 56a76d8b62de56d65559c6391312c96e1b24d635 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 19 Dec 2018 13:44:47 -0800 Subject: [PATCH 024/101] Revert BuilderProgram to be redirected object to Program in preparation to set Program in state to undefined for storing. --- src/compiler/builder.ts | 72 +++++++++++++++---- src/compiler/tsbuild.ts | 2 +- src/compiler/watch.ts | 17 ++++- src/tsc/tsc.ts | 2 +- .../reference/api/tsserverlibrary.d.ts | 38 +++++++++- tests/baselines/reference/api/typescript.d.ts | 38 +++++++++- 6 files changed, 150 insertions(+), 19 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index ce12373960a..14db0b367e2 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -411,11 +411,9 @@ namespace ts { oldProgram = undefined; oldState = undefined; - const result = createRedirectObject(state.program) as BuilderProgram; + const result = createRedirectedBuilderProgram(state, configFileParsingDiagnostics); result.getState = () => state; - result.getProgram = () => state.program; result.getAllDependencies = sourceFile => BuilderState.getAllDependencies(state, state.program, sourceFile); - result.getConfigFileParsingDiagnostics = () => configFileParsingDiagnostics; result.getSemanticDiagnostics = getSemanticDiagnostics; result.emit = emit; @@ -563,6 +561,25 @@ namespace ts { return diagnostics || emptyArray; } } + + export function createRedirectedBuilderProgram(state: { program: Program; }, configFileParsingDiagnostics: ReadonlyArray): BuilderProgram { + return { + getState: notImplemented, + getProgram: () => state.program, + getCompilerOptions: () => state.program.getCompilerOptions(), + getSourceFile: fileName => state.program.getSourceFile(fileName), + getSourceFiles: () => state.program.getSourceFiles(), + getOptionsDiagnostics: cancellationToken => state.program.getOptionsDiagnostics(cancellationToken), + getGlobalDiagnostics: cancellationToken => state.program.getGlobalDiagnostics(cancellationToken), + getConfigFileParsingDiagnostics: () => configFileParsingDiagnostics, + getSyntacticDiagnostics: (sourceFile, cancellationToken) => state.program.getSyntacticDiagnostics(sourceFile, cancellationToken), + getDeclarationDiagnostics: (sourceFile, cancellationToken) => state.program.getDeclarationDiagnostics(sourceFile, cancellationToken), + getSemanticDiagnostics: (sourceFile, cancellationToken) => state.program.getSemanticDiagnostics(sourceFile, cancellationToken), + emit: (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) => state.program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers), + getAllDependencies: notImplemented, + getCurrentDirectory: () => state.program.getCurrentDirectory() + }; + } } namespace ts { @@ -587,20 +604,50 @@ namespace ts { /** * Builder to manage the program state changes */ - export interface BuilderProgram extends Program { + export interface BuilderProgram { /*@internal*/ getState(): BuilderProgramState; /** * Returns current program */ getProgram(): Program; + /** + * Get compiler options of the program + */ + getCompilerOptions(): CompilerOptions; + /** + * Get the source file in the program with file name + */ + getSourceFile(fileName: string): SourceFile | undefined; + /** + * Get a list of files in the program + */ + getSourceFiles(): ReadonlyArray; + /** + * Get the diagnostics for compiler options + */ + getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + /** + * Get the diagnostics that dont belong to any file + */ + getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + /** + * Get the diagnostics from config file parsing + */ + getConfigFileParsingDiagnostics(): ReadonlyArray; + /** + * Get the syntax diagnostics, for all source files if source file is not supplied + */ + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + /** + * Get the declaration diagnostics, for all source files if source file is not supplied + */ + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; /** * Get all the dependencies of the file */ getAllDependencies(sourceFile: SourceFile): ReadonlyArray; - // These two are same signatures but because the doc comments are useful they are retained - /** * Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program * The semantic diagnostics are cached and managed here @@ -622,6 +669,10 @@ namespace ts { * in that order would be used to write the files */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; + /** + * Get the current directory of the program + */ + getCurrentDirectory(): string; } /** @@ -674,13 +725,6 @@ namespace ts { export function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram; export function createAbstractBuilder(newProgramOrRootNames: Program | ReadonlyArray | undefined, hostOrOptions: BuilderProgramHost | CompilerOptions | undefined, oldProgramOrHost?: CompilerHost | BuilderProgram, configFileParsingDiagnosticsOrOldProgram?: ReadonlyArray | BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram { const { newProgram, configFileParsingDiagnostics: newConfigFileParsingDiagnostics } = getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences); - const builderProgram = createRedirectObject(newProgram) as BuilderProgram; - builderProgram.getState = notImplemented; - builderProgram.getProgram = () => newProgram; - builderProgram.getAllDependencies = notImplemented; - - // Always return latest config file diagnostics - builderProgram.getConfigFileParsingDiagnostics = () => newConfigFileParsingDiagnostics; - return builderProgram; + return createRedirectedBuilderProgram({ program: newProgram }, newConfigFileParsingDiagnostics); } } diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index bc0a2f87680..ca3108616a6 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -331,7 +331,7 @@ namespace ts { // TODO: To do better with watch mode and normal build mode api that creates program and emits files // This currently helps enable --diagnostics and --extendedDiagnostics - afterProgramEmitAndDiagnostics?(program: Program): void; + afterProgramEmitAndDiagnostics?(program: T): void; } export interface SolutionBuilderHost extends SolutionBuilderHostBase { diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index a29d54ac981..cc6d1236fed 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -106,10 +106,25 @@ namespace ts { return `${newLine}${flattenDiagnosticMessageText(d.messageText, newLine)}${newLine}${newLine}`; } + /** + * Program structure needed to emit the files and report diagnostics + */ + export interface ProgramToEmitFilesAndReportErrors { + getCurrentDirectory(): string; + getCompilerOptions(): CompilerOptions; + getSourceFiles(): ReadonlyArray; + getSyntacticDiagnostics(): ReadonlyArray; + getOptionsDiagnostics(): ReadonlyArray; + getGlobalDiagnostics(): ReadonlyArray; + getSemanticDiagnostics(): ReadonlyArray; + getConfigFileParsingDiagnostics(): ReadonlyArray; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; + } + /** * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ - export function emitFilesAndReportErrors(program: Program, reportDiagnostic: DiagnosticReporter, writeFileName?: (s: string) => void, reportSummary?: ReportEmitErrorSummary, writeFile?: WriteFileCallback) { + export function emitFilesAndReportErrors(program: ProgramToEmitFilesAndReportErrors, reportDiagnostic: DiagnosticReporter, writeFileName?: (s: string) => void, reportSummary?: ReportEmitErrorSummary, writeFile?: WriteFileCallback) { // First get and report any syntactic errors. const diagnostics = program.getConfigFileParsingDiagnostics().slice(); const configFileParsingDiagnosticsLength = diagnostics.length; diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index a9d961a14d6..cafd06ca417 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -209,7 +209,7 @@ namespace ts { createSolutionBuilderWithWatchHost(sys, createSemanticDiagnosticsBuilderProgram, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()) : createSolutionBuilderHost(sys, createAbstractBuilder, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createReportErrorSummary(buildOptions)); updateCreateProgram(buildHost); - buildHost.afterProgramEmitAndDiagnostics = reportStatistics; + buildHost.afterProgramEmitAndDiagnostics = (program: BuilderProgram) => reportStatistics(program.getProgram()); const builder = createSolutionBuilder(buildHost, projects, buildOptions); if (buildOptions.clean) { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 3b1e45b0bfa..aee6b01eaff 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4245,11 +4245,43 @@ declare namespace ts { /** * Builder to manage the program state changes */ - interface BuilderProgram extends Program { + interface BuilderProgram { /** * Returns current program */ getProgram(): Program; + /** + * Get compiler options of the program + */ + getCompilerOptions(): CompilerOptions; + /** + * Get the source file in the program with file name + */ + getSourceFile(fileName: string): SourceFile | undefined; + /** + * Get a list of files in the program + */ + getSourceFiles(): ReadonlyArray; + /** + * Get the diagnostics for compiler options + */ + getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + /** + * Get the diagnostics that dont belong to any file + */ + getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + /** + * Get the diagnostics from config file parsing + */ + getConfigFileParsingDiagnostics(): ReadonlyArray; + /** + * Get the syntax diagnostics, for all source files if source file is not supplied + */ + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + /** + * Get the declaration diagnostics, for all source files if source file is not supplied + */ + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; /** * Get all the dependencies of the file */ @@ -4275,6 +4307,10 @@ declare namespace ts { * in that order would be used to write the files */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; + /** + * Get the current directory of the program + */ + getCurrentDirectory(): string; } /** * The builder that caches the semantic diagnostics for the program and handles the changed files and affected files diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 4e1b769378e..ca4177d87cc 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -4245,11 +4245,43 @@ declare namespace ts { /** * Builder to manage the program state changes */ - interface BuilderProgram extends Program { + interface BuilderProgram { /** * Returns current program */ getProgram(): Program; + /** + * Get compiler options of the program + */ + getCompilerOptions(): CompilerOptions; + /** + * Get the source file in the program with file name + */ + getSourceFile(fileName: string): SourceFile | undefined; + /** + * Get a list of files in the program + */ + getSourceFiles(): ReadonlyArray; + /** + * Get the diagnostics for compiler options + */ + getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + /** + * Get the diagnostics that dont belong to any file + */ + getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + /** + * Get the diagnostics from config file parsing + */ + getConfigFileParsingDiagnostics(): ReadonlyArray; + /** + * Get the syntax diagnostics, for all source files if source file is not supplied + */ + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + /** + * Get the declaration diagnostics, for all source files if source file is not supplied + */ + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; /** * Get all the dependencies of the file */ @@ -4275,6 +4307,10 @@ declare namespace ts { * in that order would be used to write the files */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; + /** + * Get the current directory of the program + */ + getCurrentDirectory(): string; } /** * The builder that caches the semantic diagnostics for the program and handles the changed files and affected files From 69193d9c20223d0feb5f5d8d475ddceb580842ca Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 19 Dec 2018 14:19:05 -0800 Subject: [PATCH 025/101] Add method to release held Program in BuilderProgram --- src/compiler/builder.ts | 79 +++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 30 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 14db0b367e2..b0bd840c610 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -49,7 +49,11 @@ namespace ts { /** * program corresponding to this state */ - program: Program; + program: Program | undefined; + /** + * compilerOptions for the program + */ + compilerOptions: CompilerOptions; } function hasSameKeys(map1: ReadonlyMap | undefined, map2: ReadonlyMap | undefined): boolean { @@ -64,13 +68,14 @@ namespace ts { const state = BuilderState.create(newProgram, getCanonicalFileName, oldState) as BuilderProgramState; state.program = newProgram; const compilerOptions = newProgram.getCompilerOptions(); + state.compilerOptions = compilerOptions; if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = createMap>(); } state.changedFilesSet = createMap(); const useOldState = BuilderState.canReuseOldState(state.referencedMap, oldState); - const oldCompilerOptions = useOldState ? oldState!.program.getCompilerOptions() : undefined; + const oldCompilerOptions = useOldState ? oldState!.compilerOptions : undefined; const canCopySemanticDiagnostics = useOldState && oldState!.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && !compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions!); if (useOldState) { @@ -109,7 +114,7 @@ namespace ts { state.changedFilesSet.set(sourceFilePath, true); } else if (canCopySemanticDiagnostics) { - const sourceFile = state.program.getSourceFileByPath(sourceFilePath as Path)!; + const sourceFile = newProgram.getSourceFileByPath(sourceFilePath as Path)!; if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) { return; } if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) { return; } @@ -179,10 +184,11 @@ namespace ts { // With --out or --outFile all outputs go into single file // so operations are performed directly on program, return program - const compilerOptions = state.program.getCompilerOptions(); + const program = Debug.assertDefined(state.program); + const compilerOptions = program.getCompilerOptions(); if (compilerOptions.outFile || compilerOptions.out) { Debug.assert(!state.semanticDiagnosticsPerFile); - return state.program; + return program; } // Get next batch of affected files @@ -190,7 +196,7 @@ namespace ts { if (state.exportedModulesMap) { state.currentAffectedFilesExportedModulesMap = state.currentAffectedFilesExportedModulesMap || createMap(); } - state.affectedFiles = BuilderState.getFilesAffectedBy(state, state.program, nextKey.value as Path, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap); + state.affectedFiles = BuilderState.getFilesAffectedBy(state, program, nextKey.value as Path, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap); state.currentChangedFilePath = nextKey.value as Path; state.affectedFilesIndex = 0; state.seenAffectedFiles = state.seenAffectedFiles || createMap(); @@ -209,9 +215,10 @@ namespace ts { // Clean lib file diagnostics if its all files excluding default files to emit if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles && !state.cleanedDiagnosticsOfLibFiles) { state.cleanedDiagnosticsOfLibFiles = true; - const options = state.program.getCompilerOptions(); - if (forEach(state.program.getSourceFiles(), f => - state.program.isSourceFileDefaultLibrary(f) && + const program = Debug.assertDefined(state.program); + const options = program.getCompilerOptions(); + if (forEach(program.getSourceFiles(), f => + program.isSourceFileDefaultLibrary(f) && !skipTypeChecking(f, options) && removeSemanticDiagnosticsOf(state, f.path) )) { @@ -336,7 +343,7 @@ namespace ts { } // Diagnostics werent cached, get them from program, and cache the result - const diagnostics = state.program.getSemanticDiagnostics(sourceFile, cancellationToken); + const diagnostics = Debug.assertDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken); state.semanticDiagnosticsPerFile!.set(path, diagnostics); return diagnostics; } @@ -370,7 +377,7 @@ namespace ts { rootNames: newProgramOrRootNames, options: hostOrOptions as CompilerOptions, host: oldProgramOrHost as CompilerHost, - oldProgram: oldProgram && oldProgram.getProgram(), + oldProgram: oldProgram && oldProgram.getProgramOrUndefined(), configFileParsingDiagnostics, projectReferences }); @@ -413,7 +420,7 @@ namespace ts { const result = createRedirectedBuilderProgram(state, configFileParsingDiagnostics); result.getState = () => state; - result.getAllDependencies = sourceFile => BuilderState.getAllDependencies(state, state.program, sourceFile); + result.getAllDependencies = sourceFile => BuilderState.getAllDependencies(state, Debug.assertDefined(state.program), sourceFile); result.getSemanticDiagnostics = getSemanticDiagnostics; result.emit = emit; @@ -445,7 +452,7 @@ namespace ts { state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - state.program.emit(affected === state.program ? undefined : affected as SourceFile, writeFile || host.writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers), + Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected as SourceFile, writeFile || host.writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers), affected ); } @@ -486,7 +493,7 @@ namespace ts { }; } } - return state.program.emit(targetSourceFile, writeFile || host.writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + return Debug.assertDefined(state.program).emit(targetSourceFile, writeFile || host.writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); } /** @@ -534,11 +541,11 @@ namespace ts { */ function getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray { assertSourceFileOkWithoutNextAffectedCall(state, sourceFile); - const compilerOptions = state.program.getCompilerOptions(); + const compilerOptions = Debug.assertDefined(state.program).getCompilerOptions(); if (compilerOptions.outFile || compilerOptions.out) { Debug.assert(!state.semanticDiagnosticsPerFile); // We dont need to cache the diagnostics just return them from program - return state.program.getSemanticDiagnostics(sourceFile, cancellationToken); + return Debug.assertDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken); } if (sourceFile) { @@ -555,29 +562,31 @@ namespace ts { } let diagnostics: Diagnostic[] | undefined; - for (const sourceFile of state.program.getSourceFiles()) { + for (const sourceFile of Debug.assertDefined(state.program).getSourceFiles()) { diagnostics = addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken)); } return diagnostics || emptyArray; } } - export function createRedirectedBuilderProgram(state: { program: Program; }, configFileParsingDiagnostics: ReadonlyArray): BuilderProgram { + export function createRedirectedBuilderProgram(state: { program: Program | undefined; compilerOptions: CompilerOptions; }, configFileParsingDiagnostics: ReadonlyArray): BuilderProgram { return { getState: notImplemented, - getProgram: () => state.program, - getCompilerOptions: () => state.program.getCompilerOptions(), - getSourceFile: fileName => state.program.getSourceFile(fileName), - getSourceFiles: () => state.program.getSourceFiles(), - getOptionsDiagnostics: cancellationToken => state.program.getOptionsDiagnostics(cancellationToken), - getGlobalDiagnostics: cancellationToken => state.program.getGlobalDiagnostics(cancellationToken), + getProgram: () => Debug.assertDefined(state.program), + getProgramOrUndefined: () => state.program, + releaseProgram: () => state.program = undefined, + getCompilerOptions: () => state.compilerOptions, + getSourceFile: fileName => Debug.assertDefined(state.program).getSourceFile(fileName), + getSourceFiles: () => Debug.assertDefined(state.program).getSourceFiles(), + getOptionsDiagnostics: cancellationToken => Debug.assertDefined(state.program).getOptionsDiagnostics(cancellationToken), + getGlobalDiagnostics: cancellationToken => Debug.assertDefined(state.program).getGlobalDiagnostics(cancellationToken), getConfigFileParsingDiagnostics: () => configFileParsingDiagnostics, - getSyntacticDiagnostics: (sourceFile, cancellationToken) => state.program.getSyntacticDiagnostics(sourceFile, cancellationToken), - getDeclarationDiagnostics: (sourceFile, cancellationToken) => state.program.getDeclarationDiagnostics(sourceFile, cancellationToken), - getSemanticDiagnostics: (sourceFile, cancellationToken) => state.program.getSemanticDiagnostics(sourceFile, cancellationToken), - emit: (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) => state.program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers), + getSyntacticDiagnostics: (sourceFile, cancellationToken) => Debug.assertDefined(state.program).getSyntacticDiagnostics(sourceFile, cancellationToken), + getDeclarationDiagnostics: (sourceFile, cancellationToken) => Debug.assertDefined(state.program).getDeclarationDiagnostics(sourceFile, cancellationToken), + getSemanticDiagnostics: (sourceFile, cancellationToken) => Debug.assertDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken), + emit: (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) => Debug.assertDefined(state.program).emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers), getAllDependencies: notImplemented, - getCurrentDirectory: () => state.program.getCurrentDirectory() + getCurrentDirectory: () => Debug.assertDefined(state.program).getCurrentDirectory() }; } } @@ -611,6 +620,16 @@ namespace ts { * Returns current program */ getProgram(): Program; + /** + * Returns current program that could be undefined if the program was released + */ + /*@internal*/ + getProgramOrUndefined(): Program | undefined; + /** + * Releases reference to the program, making all the other operations that need program to fail. + */ + /*@internal*/ + releaseProgram(): void; /** * Get compiler options of the program */ @@ -725,6 +744,6 @@ namespace ts { export function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram; export function createAbstractBuilder(newProgramOrRootNames: Program | ReadonlyArray | undefined, hostOrOptions: BuilderProgramHost | CompilerOptions | undefined, oldProgramOrHost?: CompilerHost | BuilderProgram, configFileParsingDiagnosticsOrOldProgram?: ReadonlyArray | BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram { const { newProgram, configFileParsingDiagnostics: newConfigFileParsingDiagnostics } = getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences); - return createRedirectedBuilderProgram({ program: newProgram }, newConfigFileParsingDiagnostics); + return createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics); } } From 47f51060e9c2deb555b49a9e071538de4aff2a08 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 19 Dec 2018 15:24:36 -0800 Subject: [PATCH 026/101] Use oldProgram to create the new Program. This helps in storing the semantic diagnostics --- src/compiler/builder.ts | 2 +- src/compiler/builderState.ts | 4 +-- src/compiler/sys.ts | 19 ++++++++------- src/compiler/tsbuild.ts | 47 ++++++++++++++++++++++++++++++------ 4 files changed, 53 insertions(+), 19 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index b0bd840c610..28a85f74320 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -410,7 +410,7 @@ namespace ts { /** * Computing hash to for signature verification */ - const computeHash = host.createHash || identity; + const computeHash = host.createHash || generateDjb2Hash; const state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); // To ensure that we arent storing any references to old program or new program without state diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index 7c7bebde9f9..0462beada9e 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -505,14 +505,14 @@ namespace ts.BuilderState { // Start with the paths this file was referenced by seenFileNamesMap.set(sourceFileWithUpdatedShape.path, sourceFileWithUpdatedShape); - const queue = getReferencedByPaths(state, sourceFileWithUpdatedShape.path); + const queue = getReferencedByPaths(state, sourceFileWithUpdatedShape.resolvedPath); while (queue.length > 0) { const currentPath = queue.pop()!; if (!seenFileNamesMap.has(currentPath)) { const currentSourceFile = programOfThisState.getSourceFileByPath(currentPath)!; seenFileNamesMap.set(currentPath, currentSourceFile); if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash!, exportedModulesMapCache)) { // TODO: GH#18217 - queue.push(...getReferencedByPaths(state, currentPath)); + queue.push(...getReferencedByPaths(state, currentSourceFile.resolvedPath)); } } } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 8ee1e4571b3..35e9a9ec35f 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -2,6 +2,16 @@ declare function setTimeout(handler: (...args: any[]) => void, timeout: number): declare function clearTimeout(handle: any): void; namespace ts { + /** + * djb2 hashing algorithm + * http://www.cse.yorku.ca/~oz/hash.html + */ + /* @internal */ + export function generateDjb2Hash(data: string): string { + const chars = data.split("").map(str => str.charCodeAt(0)); + return `${chars.reduce((prev, curr) => ((prev << 5) + prev) + curr, 5381)}`; + } + /** * Set a high stack trace limit to provide more information in case of an error. * Called for command-line and server use cases. @@ -1115,15 +1125,6 @@ namespace ts { } } - /** - * djb2 hashing algorithm - * http://www.cse.yorku.ca/~oz/hash.html - */ - function generateDjb2Hash(data: string): string { - const chars = data.split("").map(str => str.charCodeAt(0)); - return `${chars.reduce((prev, curr) => ((prev << 5) + prev) + curr, 5381)}`; - } - function createMD5HashUsingNativeCrypto(data: string): string { const hash = _crypto!.createHash("md5"); hash.update(data); diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index ca3108616a6..b833b7744e9 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -434,8 +434,12 @@ namespace ts { let readFileWithCache = (f: string) => host.readFile(f); let projectCompilerOptions = baseCompilerOptions; const compilerHost = createCompilerHostFromProgramHost(host, () => projectCompilerOptions); + const originalGetSourceFile = compilerHost.getSourceFile; + const computeHash = host.createHash || generateDjb2Hash; + updateGetSourceFile(); // Watch state + const builderPrograms = createFileMap(toPath); const diagnostics = createFileMap>(toPath); const projectPendingBuild = createFileMap(toPath); const projectErrorsReported = createFileMap(toPath); @@ -493,6 +497,29 @@ namespace ts { clearMap(allWatchedWildcardDirectories, wildCardWatches => clearMap(wildCardWatches, closeFileWatcherOf)); clearMap(allWatchedInputFiles, inputFileWatches => clearMap(inputFileWatches, closeFileWatcher)); clearMap(allWatchedConfigFiles, closeFileWatcher); + if (!options.watch) { + builderPrograms.clear(); + } + updateGetSourceFile(); + } + + function updateGetSourceFile() { + if (options.watch) { + if (compilerHost.getSourceFile === originalGetSourceFile) { + compilerHost.getSourceFile = (...args) => { + const result = originalGetSourceFile.call(compilerHost, ...args); + if (result && options.watch) { + result.version = computeHash.call(host, result.text); + } + return result; + }; + } + } + else { + if (compilerHost.getSourceFile !== originalGetSourceFile) { + compilerHost.getSourceFile = originalGetSourceFile; + } + } } function isParsedCommandLine(entry: ConfigFileCacheEntry): entry is ParsedCommandLine { @@ -1057,7 +1084,7 @@ namespace ts { configFile.fileNames, configFile.options, compilerHost, - /*oldProgram*/ undefined, + builderPrograms.getValue(proj), configFile.errors, configFile.projectReferences ); @@ -1123,22 +1150,28 @@ namespace ts { }; diagnostics.removeKey(proj); projectStatus.setValue(proj, status); - if (host.afterProgramEmitAndDiagnostics) { - host.afterProgramEmitAndDiagnostics(program); - } + afterProgramCreate(proj, program); return resultFlags; function buildErrors(diagnostics: ReadonlyArray, errorFlags: BuildResultFlags, errorType: string) { resultFlags |= errorFlags; reportAndStoreErrors(proj, diagnostics); projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: `${errorType} errors` }); - if (host.afterProgramEmitAndDiagnostics) { - host.afterProgramEmitAndDiagnostics(program); - } + afterProgramCreate(proj, program); return resultFlags; } } + function afterProgramCreate(proj: ResolvedConfigFileName, program: T) { + if (host.afterProgramEmitAndDiagnostics) { + host.afterProgramEmitAndDiagnostics(program); + } + if (options.watch) { + program.releaseProgram(); + builderPrograms.setValue(proj, program); + } + } + function updateOutputTimestamps(proj: ParsedCommandLine) { if (options.dry) { return reportStatus(Diagnostics.A_non_dry_build_would_build_project_0, proj.options.configFilePath!); From f1949bbae824fb22dad38efc9e6c6b929945301f Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 19 Dec 2018 17:08:36 -0800 Subject: [PATCH 027/101] Use emit builder to emit only changed files. --- src/compiler/builder.ts | 89 +++++++++++++++++++++++++++++++++++------ src/compiler/tsbuild.ts | 3 +- src/tsc/tsc.ts | 3 +- 3 files changed, 78 insertions(+), 17 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 28a85f74320..df3b056227f 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -54,6 +54,18 @@ namespace ts { * compilerOptions for the program */ compilerOptions: CompilerOptions; + /** + * Files pending to be emitted + */ + affectedFilesPendingEmit: ReadonlyArray | undefined; + /** + * Current index to retrieve pending affected file + */ + affectedFilesPendingEmitIndex: number | undefined; + /** + * Already seen affected files + */ + seenEmittedFiles: Map | undefined; } function hasSameKeys(map1: ReadonlyMap | undefined, map2: ReadonlyMap | undefined): boolean { @@ -89,6 +101,10 @@ namespace ts { // Copy old state's changed files set copyEntries(oldState!.changedFilesSet, state.changedFilesSet); + if (!compilerOptions.outFile && !compilerOptions.out && oldState!.affectedFilesPendingEmit) { + state.affectedFilesPendingEmit = oldState!.affectedFilesPendingEmit; + state.affectedFilesPendingEmitIndex = oldState!.affectedFilesPendingEmitIndex; + } } // Update changed files and copy semantic diagnostics if we can @@ -203,6 +219,27 @@ namespace ts { } } + /** + * Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet + */ + function getNextAffectedFilePendingEmit(state: BuilderProgramState): SourceFile | undefined { + const { affectedFilesPendingEmit } = state; + if (affectedFilesPendingEmit) { + const seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = createMap()); + for (let affectedFilesIndex = state.affectedFilesPendingEmitIndex!; affectedFilesIndex < affectedFilesPendingEmit.length; affectedFilesIndex++) { + const affectedFile = Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[affectedFilesIndex]); + if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { + // emit this file + state.affectedFilesPendingEmitIndex = affectedFilesIndex; + return affectedFile; + } + } + state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitIndex = undefined; + } + return undefined; + } + /** * Remove the semantic diagnostics cached from old state for affected File and the files that are referencing modules that export entities from affected file */ @@ -312,21 +349,26 @@ namespace ts { * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state: BuilderProgramState, affected: SourceFile | Program) { + function doneWithAffectedFile(state: BuilderProgramState, affected: SourceFile | Program, isPendingEmit?: boolean) { if (affected === state.program) { state.changedFilesSet.clear(); } else { state.seenAffectedFiles!.set((affected as SourceFile).path, true); - state.affectedFilesIndex!++; + if (isPendingEmit) { + state.affectedFilesPendingEmitIndex!++; + } + else { + state.affectedFilesIndex!++; + } } } /** * Returns the result with affected file */ - function toAffectedFileResult(state: BuilderProgramState, result: T, affected: SourceFile | Program): AffectedFileResult { - doneWithAffectedFile(state, affected); + function toAffectedFileResult(state: BuilderProgramState, result: T, affected: SourceFile | Program, isPendingEmit?: boolean): AffectedFileResult { + doneWithAffectedFile(state, affected, isPendingEmit); return { result, affected }; } @@ -442,10 +484,20 @@ namespace ts { * in that order would be used to write the files */ function emitNextAffectedFile(writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): AffectedFileResult { - const affected = getNextAffectedFile(state, cancellationToken, computeHash); + let affected = getNextAffectedFile(state, cancellationToken, computeHash); + let isPendingEmitFile = false; if (!affected) { + affected = getNextAffectedFilePendingEmit(state); // Done - return undefined; + if (!affected) { + return undefined; + } + isPendingEmitFile = true; + } + + // Mark seen emitted files if there are pending files to be emitted + if (state.affectedFilesPendingEmit && state.program !== affected) { + (state.seenEmittedFiles || (state.seenEmittedFiles = createMap())).set((affected as SourceFile).path, true); } return toAffectedFileResult( @@ -453,7 +505,8 @@ namespace ts { // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected as SourceFile, writeFile || host.writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers), - affected + affected, + isPendingEmitFile ); } @@ -552,12 +605,22 @@ namespace ts { return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken); } - if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) { - // When semantic builder asks for diagnostics of the whole program, - // ensure that all the affected files are handled - let affected: SourceFile | Program | undefined; - while (affected = getNextAffectedFile(state, cancellationToken, computeHash)) { - doneWithAffectedFile(state, affected); + // When semantic builder asks for diagnostics of the whole program, + // ensure that all the affected files are handled + let affected: SourceFile | Program | undefined; + let affectedFilesPendingEmit: Path[] | undefined; + while (affected = getNextAffectedFile(state, cancellationToken, computeHash)) { + if (affected !== state.program && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { + (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push((affected as SourceFile).path); + } + doneWithAffectedFile(state, affected); + } + + // In case of emit builder, cache the files to be emitted + if (affectedFilesPendingEmit) { + state.affectedFilesPendingEmit = concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + if (state.affectedFilesPendingEmitIndex === undefined) { + state.affectedFilesPendingEmitIndex = 0; } } diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index b833b7744e9..78cdf676d2f 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -389,9 +389,8 @@ namespace ts { return host; } - // TODO: we should use emit and semantic diagnostics builder but that needs to handle errors little differently so handle it later export function createSolutionBuilderWithWatchHost(system = sys, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter) { - const host = createSolutionBuilderHostBase(system, createProgram || createSemanticDiagnosticsBuilderProgram as any as CreateProgram, reportDiagnostic, reportSolutionBuilderStatus) as SolutionBuilderWithWatchHost; + const host = createSolutionBuilderHostBase(system, createProgram || createEmitAndSemanticDiagnosticsBuilderProgram as any as CreateProgram, reportDiagnostic, reportSolutionBuilderStatus) as SolutionBuilderWithWatchHost; const watchHost = createWatchHost(system, reportWatchStatus); copyProperities(host, watchHost); return host; diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index cafd06ca417..88c3cdedfd9 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -204,9 +204,8 @@ namespace ts { reportWatchModeWithoutSysSupport(); } - // TODO: change this to host if watch => watchHost otherwiue without watch const buildHost = buildOptions.watch ? - createSolutionBuilderWithWatchHost(sys, createSemanticDiagnosticsBuilderProgram, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()) : + createSolutionBuilderWithWatchHost(sys, createEmitAndSemanticDiagnosticsBuilderProgram, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()) : createSolutionBuilderHost(sys, createAbstractBuilder, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createReportErrorSummary(buildOptions)); updateCreateProgram(buildHost); buildHost.afterProgramEmitAndDiagnostics = (program: BuilderProgram) => reportStatistics(program.getProgram()); From 7b290fdbd4e892379c3ab3ed46d7b41f15a31a2b Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 20 Dec 2018 11:33:11 -0800 Subject: [PATCH 028/101] Update the timestamps of outputs that dont need to be written because of incremental build This ensures that after `tsbuild` after incremental build of `tsbuild -w` doesnt result in unnecessary rebuilds --- src/compiler/diagnosticMessages.json | 4 + src/compiler/tsbuild.ts | 107 ++++++++--- src/harness/fakes.ts | 3 + src/testRunner/unittests/tsbuild.ts | 57 +++--- src/testRunner/unittests/tsbuildWatchMode.ts | 181 +++++++++++-------- 5 files changed, 230 insertions(+), 122 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b0dfb85ce6d..b6fec29ca8e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3945,6 +3945,10 @@ "category": "Error", "code": 6370 }, + "Updating unchanged output timestamps of project '{0}'...": { + "category": "Message", + "code": 6371 + }, "The expected type comes from property '{0}' which is declared here on type '{1}'": { "category": "Message", diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 78cdf676d2f..ae5ddfcccf3 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -119,7 +119,7 @@ namespace ts { newestDeclarationFileContentChangedTime?: Date; newestOutputFileTime?: Date; newestOutputFileName?: string; - oldestOutputFileName?: string; + oldestOutputFileName: string; } /** @@ -332,6 +332,9 @@ namespace ts { // TODO: To do better with watch mode and normal build mode api that creates program and emits files // This currently helps enable --diagnostics and --extendedDiagnostics afterProgramEmitAndDiagnostics?(program: T): void; + + // For testing + now?(): Date; } export interface SolutionBuilderHost extends SolutionBuilderHostBase { @@ -991,16 +994,40 @@ namespace ts { return; } + if (status.type === UpToDateStatusType.UpToDateWithUpstreamTypes) { + // Fake build + updateOutputTimestamps(proj); + return; + } + const buildResult = buildSingleProject(resolved); - const dependencyGraph = getGlobalDependencyGraph(); - const referencingProjects = dependencyGraph.referencingProjectsMap.getValue(resolved); + if (buildResult & BuildResultFlags.AnyErrors) return; + + const { referencingProjectsMap, buildQueue } = getGlobalDependencyGraph(); + const referencingProjects = referencingProjectsMap.getValue(resolved); if (!referencingProjects) return; + // Always use build order to queue projects - for (const project of dependencyGraph.buildQueue) { + for (let index = buildQueue.indexOf(resolved) + 1; index < buildQueue.length; index++) { + const project = buildQueue[index]; const prepend = referencingProjects.getValue(project); - // If the project is referenced with prepend, always build downstream projectm, - // otherwise queue it only if declaration output changed - if (prepend || (prepend !== undefined && !(buildResult & BuildResultFlags.DeclarationOutputUnchanged))) { + if (prepend !== undefined) { + // If the project is referenced with prepend, always build downstream project, + // If declaration output is changed changed, build the project + // otherwise mark the project UpToDateWithUpstreamTypes so it updates output time stamps + const status = projectStatus.getValue(project); + if (prepend || !(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { + if (status && (status.type === UpToDateStatusType.UpToDate || status.type === UpToDateStatusType.UpToDateWithUpstreamTypes)) { + projectStatus.setValue(project, { + type: UpToDateStatusType.OutOfDateWithUpstream, + outOfDateOutputFileName: status.oldestOutputFileName, + newerProjectName: resolved + }); + } + } + else if (status && status.type === UpToDateStatusType.UpToDate) { + status.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + } addProjToQueue(project); } } @@ -1110,6 +1137,7 @@ namespace ts { let declDiagnostics: Diagnostic[] | undefined; const reportDeclarationDiagnostics = (d: Diagnostic) => (declDiagnostics || (declDiagnostics = [])).push(d); const outputFiles: OutputFile[] = []; + // TODO:: handle declaration diagnostics in incremental build. emitFilesAndReportErrors(program, reportDeclarationDiagnostics, writeFileName, /*reportSummary*/ undefined, (name, text, writeByteOrderMark) => outputFiles.push({ name, text, writeByteOrderMark })); // Don't emit .d.ts if there are decl file errors if (declDiagnostics) { @@ -1118,6 +1146,7 @@ namespace ts { // Actual Emit const emitterDiagnostics = createDiagnosticCollection(); + const emittedOutputs = createFileMap(toPath as ToPath); outputFiles.forEach(({ name, text, writeByteOrderMark }) => { let priorChangeTime: Date | undefined; if (!anyDtsChanged && isDeclarationFile(name)) { @@ -1131,6 +1160,7 @@ namespace ts { } } + emittedOutputs.setValue(name, true); writeFile(compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); if (priorChangeTime !== undefined) { newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime); @@ -1143,9 +1173,13 @@ namespace ts { return buildErrors(emitDiagnostics, BuildResultFlags.EmitErrors, "Emit"); } + // Update time stamps for rest of the outputs + newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(configFile, newestDeclarationFileContentChangedTime, Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs); + const status: UpToDateStatus = { type: UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime + newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime, + oldestOutputFileName: outputFiles.length ? outputFiles[0].name : getFirstProjectOutput(configFile) }; diagnostics.removeKey(proj); projectStatus.setValue(proj, status); @@ -1175,25 +1209,36 @@ namespace ts { if (options.dry) { return reportStatus(Diagnostics.A_non_dry_build_would_build_project_0, proj.options.configFilePath!); } - - if (options.verbose) { - reportStatus(Diagnostics.Updating_output_timestamps_of_project_0, proj.options.configFilePath!); - } - - const now = new Date(); - const outputs = getAllProjectOutputs(proj); - let priorNewestUpdateTime = minimumDate; - for (const file of outputs) { - if (isDeclarationFile(file)) { - priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || missingFileModifiedTime); - } - - host.setModifiedTime(file, now); - } - + const priorNewestUpdateTime = updateOutputTimestampsWorker(proj, minimumDate, Diagnostics.Updating_output_timestamps_of_project_0); projectStatus.setValue(proj.options.configFilePath as ResolvedConfigFilePath, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: priorNewestUpdateTime } as UpToDateStatus); } + function updateOutputTimestampsWorker(proj: ParsedCommandLine, priorNewestUpdateTime: Date, verboseMessage: DiagnosticMessage, skipOutputs?: FileMap) { + const outputs = getAllProjectOutputs(proj); + if (!skipOutputs || outputs.length !== skipOutputs.getSize()) { + if (options.verbose) { + reportStatus(verboseMessage, proj.options.configFilePath!); + } + const now = host.now ? host.now() : new Date(); + for (const file of outputs) { + if (skipOutputs && skipOutputs.hasKey(file)) { + continue; + } + + if (isDeclarationFile(file)) { + priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || missingFileModifiedTime); + } + + host.setModifiedTime(file, now); + if (proj.options.listEmittedFiles) { + writeFileName(`TSFILE: ${file}`); + } + } + } + + return priorNewestUpdateTime; + } + function getFilesToClean(): string[] { // Get the same graph for cleaning we'd use for building const graph = getGlobalDependencyGraph(); @@ -1368,6 +1413,20 @@ namespace ts { } } + function getFirstProjectOutput(project: ParsedCommandLine): string { + if (project.options.outFile || project.options.out) { + return first(getOutFileOutputs(project)); + } + + for (const inputFile of project.fileNames) { + const outputs = getOutputFileNames(inputFile, project); + if (outputs.length) { + return first(outputs); + } + } + return Debug.fail(`project ${project.options.configFilePath} expected to have atleast one output`); + } + export function formatUpToDateStatus(configFileName: string, status: UpToDateStatus, relName: (fileName: string) => string, formatMessage: (message: DiagnosticMessage, ...args: string[]) => T) { switch (status.type) { case UpToDateStatusType.OutOfDateWithSelf: diff --git a/src/harness/fakes.ts b/src/harness/fakes.ts index 6119dd153b9..e8c81617052 100644 --- a/src/harness/fakes.ts +++ b/src/harness/fakes.ts @@ -377,6 +377,9 @@ namespace fakes { export class SolutionBuilderHost extends CompilerHost implements ts.SolutionBuilderHost { createProgram = ts.createAbstractBuilder; + now() { + return new Date(this.sys.vfs.time()); + } diagnostics: ts.Diagnostic[] = []; diff --git a/src/testRunner/unittests/tsbuild.ts b/src/testRunner/unittests/tsbuild.ts index 4a3f259cc34..ba94072b230 100644 --- a/src/testRunner/unittests/tsbuild.ts +++ b/src/testRunner/unittests/tsbuild.ts @@ -234,39 +234,46 @@ namespace ts { // Update a timestamp in the middle project tick(); touch(fs, "/src/logic/index.ts"); + const originalWriteFile = fs.writeFileSync; + const writtenFiles = createMap(); + fs.writeFileSync = (path, data, encoding) => { + writtenFiles.set(path, true); + originalWriteFile.call(fs, path, data, encoding); + }; // Because we haven't reset the build context, the builder should assume there's nothing to do right now const status = builder.getUpToDateStatusOfFile(builder.resolveProjectName("/src/logic")); assert.equal(status.type, UpToDateStatusType.UpToDate, "Project should be assumed to be up-to-date"); + verifyInvalidation(/*expectedToWriteTests*/ false); // Rebuild this project - tick(); - builder.invalidateProject("/src/logic"); - builder.buildInvalidatedProject(); - // The file should be updated - assert.equal(fs.statSync("/src/logic/index.js").mtimeMs, time(), "JS file should have been rebuilt"); - assert.isBelow(fs.statSync("/src/tests/index.js").mtimeMs, time(), "Downstream JS file should *not* have been rebuilt"); - - // Does not build tests or core because there is no change in declaration file - tick(); - builder.buildInvalidatedProject(); - assert.isBelow(fs.statSync("/src/tests/index.js").mtimeMs, time(), "Downstream JS file should have been rebuilt"); - assert.isBelow(fs.statSync("/src/core/index.js").mtimeMs, time(), "Upstream JS file should not have been rebuilt"); - - // Rebuild this project - tick(); fs.writeFileSync("/src/logic/index.ts", `${fs.readFileSync("/src/logic/index.ts")} export class cNew {}`); - builder.invalidateProject("/src/logic"); - builder.buildInvalidatedProject(); - // The file should be updated - assert.equal(fs.statSync("/src/logic/index.js").mtimeMs, time(), "JS file should have been rebuilt"); - assert.isBelow(fs.statSync("/src/tests/index.js").mtimeMs, time(), "Downstream JS file should *not* have been rebuilt"); + verifyInvalidation(/*expectedToWriteTests*/ true); - // Build downstream projects should update 'tests', but not 'core' - tick(); - builder.buildInvalidatedProject(); - assert.equal(fs.statSync("/src/tests/index.js").mtimeMs, time(), "Downstream JS file should have been rebuilt"); - assert.isBelow(fs.statSync("/src/core/index.js").mtimeMs, time(), "Upstream JS file should not have been rebuilt"); + function verifyInvalidation(expectedToWriteTests: boolean) { + // Rebuild this project + tick(); + builder.invalidateProject("/src/logic"); + builder.buildInvalidatedProject(); + // The file should be updated + assert.isTrue(writtenFiles.has("/src/logic/index.js"), "JS file should have been rebuilt"); + assert.equal(fs.statSync("/src/logic/index.js").mtimeMs, time(), "JS file should have been rebuilt"); + assert.isFalse(writtenFiles.has("/src/tests/index.js"), "Downstream JS file should *not* have been rebuilt"); + assert.isBelow(fs.statSync("/src/tests/index.js").mtimeMs, time(), "Downstream JS file should *not* have been rebuilt"); + writtenFiles.clear(); + + // Build downstream projects should update 'tests', but not 'core' + tick(); + builder.buildInvalidatedProject(); + if (expectedToWriteTests) { + assert.isTrue(writtenFiles.has("/src/tests/index.js"), "Downstream JS file should have been rebuilt"); + } + else { + assert.equal(writtenFiles.size, 0, "Should not write any new files"); + } + assert.equal(fs.statSync("/src/tests/index.js").mtimeMs, time(), "Downstream JS file should have new timestamp"); + assert.isBelow(fs.statSync("/src/core/index.js").mtimeMs, time(), "Upstream JS file should not have been rebuilt"); + } }); }); diff --git a/src/testRunner/unittests/tsbuildWatchMode.ts b/src/testRunner/unittests/tsbuildWatchMode.ts index 72da8dbf85e..bdc8fe1be86 100644 --- a/src/testRunner/unittests/tsbuildWatchMode.ts +++ b/src/testRunner/unittests/tsbuildWatchMode.ts @@ -2,18 +2,37 @@ namespace ts.tscWatch { import projectsLocation = TestFSWithWatch.tsbuildProjectsLocation; import getFilePathInProject = TestFSWithWatch.getTsBuildProjectFilePath; import getFileFromProject = TestFSWithWatch.getTsBuildProjectFile; + type TsBuildWatchSystem = WatchedSystem & { writtenFiles: Map; }; + + function createTsBuildWatchSystem(fileOrFolderList: ReadonlyArray, params?: TestFSWithWatch.TestServerHostCreationParameters) { + const host = createWatchedSystem(fileOrFolderList, params) as TsBuildWatchSystem; + const originalWriteFile = host.writeFile; + host.writtenFiles = createMap(); + host.writeFile = (fileName, content) => { + originalWriteFile.call(host, fileName, content); + const path = host.toFullPath(fileName); + host.writtenFiles.set(path, true); + }; + return host; + } + export function createSolutionBuilder(system: WatchedSystem, rootNames: ReadonlyArray, defaultOptions?: BuildOptions) { const host = createSolutionBuilderWithWatchHost(system); return ts.createSolutionBuilder(host, rootNames, defaultOptions || { watch: true }); } - function createSolutionBuilderWithWatch(host: WatchedSystem, rootNames: ReadonlyArray, defaultOptions?: BuildOptions) { + function createSolutionBuilderWithWatch(host: TsBuildWatchSystem, rootNames: ReadonlyArray, defaultOptions?: BuildOptions) { const solutionBuilder = createSolutionBuilder(host, rootNames, defaultOptions); solutionBuilder.buildAllProjects(); solutionBuilder.startWatching(); return solutionBuilder; } + type OutputFileStamp = [string, Date | undefined, boolean]; + function transformOutputToOutputFileStamp(f: string, host: TsBuildWatchSystem): OutputFileStamp { + return [f, host.getModifiedTime(f), host.writtenFiles.has(host.toFullPath(f))] as OutputFileStamp; + } + describe("unittests:: tsbuild-watch program updates", () => { const project = "sample1"; const enum SubProject { @@ -61,12 +80,11 @@ namespace ts.tscWatch { return [`${file}.js`, `${file}.d.ts`]; } - type OutputFileStamp = [string, Date | undefined]; - function getOutputStamps(host: WatchedSystem, subProject: SubProject, baseFileNameWithoutExtension: string): OutputFileStamp[] { - return getOutputFileNames(subProject, baseFileNameWithoutExtension).map(f => [f, host.getModifiedTime(f)] as OutputFileStamp); + function getOutputStamps(host: TsBuildWatchSystem, subProject: SubProject, baseFileNameWithoutExtension: string): OutputFileStamp[] { + return getOutputFileNames(subProject, baseFileNameWithoutExtension).map(f => transformOutputToOutputFileStamp(f, host)); } - function getOutputFileStamps(host: WatchedSystem, additionalFiles?: ReadonlyArray<[SubProject, string]>): OutputFileStamp[] { + function getOutputFileStamps(host: TsBuildWatchSystem, additionalFiles?: ReadonlyArray<[SubProject, string]>): OutputFileStamp[] { const result = [ ...getOutputStamps(host, SubProject.core, "anotherModule"), ...getOutputStamps(host, SubProject.core, "index"), @@ -76,18 +94,21 @@ namespace ts.tscWatch { if (additionalFiles) { additionalFiles.forEach(([subProject, baseFileNameWithoutExtension]) => result.push(...getOutputStamps(host, subProject, baseFileNameWithoutExtension))); } + host.writtenFiles.clear(); return result; } - function verifyChangedFiles(actualStamps: OutputFileStamp[], oldTimeStamps: OutputFileStamp[], changedFiles: string[]) { + function verifyChangedFiles(actualStamps: OutputFileStamp[], oldTimeStamps: OutputFileStamp[], changedFiles: ReadonlyArray, modifiedTimeStampFiles: ReadonlyArray) { for (let i = 0; i < oldTimeStamps.length; i++) { const actual = actualStamps[i]; const old = oldTimeStamps[i]; - if (contains(changedFiles, actual[0])) { - assert.isTrue((actual[1] || 0) > (old[1] || 0), `${actual[0]} expected to written`); + const expectedIsChanged = contains(changedFiles, actual[0]); + assert.equal(actual[2], contains(changedFiles, actual[0]), `Expected ${actual[0]} to be written.`); + if (expectedIsChanged || contains(modifiedTimeStampFiles, actual[0])) { + assert.isTrue((actual[1] || 0) > (old[1] || 0), `${actual[0]} file expected to have newer modified time because it is expected to ${expectedIsChanged ? "be changed" : "have modified time stamp"}`); } else { - assert.equal(actual[1], old[1], `${actual[0]} expected to not change`); + assert.equal(actual[1], old[1], `${actual[0]} expected to not change or have timestamp modified.`); } } } @@ -101,7 +122,7 @@ namespace ts.tscWatch { const testProjectExpectedWatchedDirectoriesRecursive = [projectPath(SubProject.core), projectPath(SubProject.logic)]; function createSolutionInWatchMode(allFiles: ReadonlyArray, defaultOptions?: BuildOptions, disableConsoleClears?: boolean) { - const host = createWatchedSystem(allFiles, { currentDirectory: projectsLocation }); + const host = createTsBuildWatchSystem(allFiles, { currentDirectory: projectsLocation }); createSolutionBuilderWithWatch(host, [`${project}/${SubProject.tests}`], defaultOptions); verifyWatches(host); checkOutputErrorsInitial(host, emptyArray, disableConsoleClears); @@ -112,7 +133,7 @@ namespace ts.tscWatch { return host; } - function verifyWatches(host: WatchedSystem) { + function verifyWatches(host: TsBuildWatchSystem) { checkWatchedFiles(host, testProjectExpectedWatchedFiles); checkWatchedDirectories(host, emptyArray, /*recursive*/ false); checkWatchedDirectories(host, testProjectExpectedWatchedDirectoriesRecursive, /*recursive*/ true); @@ -134,30 +155,50 @@ namespace ts.tscWatch { const host = createSolutionInWatchMode(allFiles); return { host, verifyChangeWithFile, verifyChangeAfterTimeout, verifyWatches }; - function verifyChangeWithFile(fileName: string, content: string) { + function verifyChangeWithFile(fileName: string, content: string, local?: boolean) { const outputFileStamps = getOutputFileStamps(host, additionalFiles); host.writeFile(fileName, content); - verifyChangeAfterTimeout(outputFileStamps); + verifyChangeAfterTimeout(outputFileStamps, local); } - function verifyChangeAfterTimeout(outputFileStamps: OutputFileStamp[]) { + function verifyChangeAfterTimeout(outputFileStamps: OutputFileStamp[], local?: boolean) { host.checkTimeoutQueueLengthAndRun(1); // Builds core const changedCore = getOutputFileStamps(host, additionalFiles); - verifyChangedFiles(changedCore, outputFileStamps, [ - ...getOutputFileNames(SubProject.core, "anotherModule"), // This should not be written really - ...getOutputFileNames(SubProject.core, "index"), - ...(additionalFiles ? getOutputFileNames(SubProject.core, newFileWithoutExtension) : emptyArray) - ]); - host.checkTimeoutQueueLengthAndRun(1); // Builds logic + verifyChangedFiles( + changedCore, + outputFileStamps, + additionalFiles ? + getOutputFileNames(SubProject.core, newFileWithoutExtension) : + getOutputFileNames(SubProject.core, "index"), // Written files are new file or core index file thats changed + [ + ...getOutputFileNames(SubProject.core, "anotherModule"), + ...(additionalFiles ? getOutputFileNames(SubProject.core, "index") : emptyArray) + ] + ); + host.checkTimeoutQueueLengthAndRun(1); // Builds logic or updates timestamps const changedLogic = getOutputFileStamps(host, additionalFiles); - verifyChangedFiles(changedLogic, changedCore, [ - ...getOutputFileNames(SubProject.logic, "index") // Again these need not be written - ]); + verifyChangedFiles( + changedLogic, + changedCore, + additionalFiles || local ? + emptyArray : + getOutputFileNames(SubProject.logic, "index"), + additionalFiles || local ? + getOutputFileNames(SubProject.logic, "index") : + emptyArray + ); host.checkTimeoutQueueLengthAndRun(1); // Builds tests const changedTests = getOutputFileStamps(host, additionalFiles); - verifyChangedFiles(changedTests, changedLogic, [ - ...getOutputFileNames(SubProject.tests, "index") // Again these need not be written - ]); + verifyChangedFiles( + changedTests, + changedLogic, + additionalFiles || local ? + emptyArray : + getOutputFileNames(SubProject.tests, "index"), + additionalFiles || local ? + getOutputFileNames(SubProject.tests, "index") : + emptyArray + ); host.checkTimeoutQueueLength(0); checkOutputErrorsIncremental(host, emptyArray); verifyWatches(); @@ -193,19 +234,9 @@ export class someClass2 { }`); }); it("non local change does not start build of referencing projects", () => { - const host = createSolutionInWatchMode(allFiles); - const outputFileStamps = getOutputFileStamps(host); - host.writeFile(core[1].path, `${core[1].content} -function foo() { }`); - host.checkTimeoutQueueLengthAndRun(1); // Builds core - const changedCore = getOutputFileStamps(host); - verifyChangedFiles(changedCore, outputFileStamps, [ - ...getOutputFileNames(SubProject.core, "anotherModule"), // This should not be written really - ...getOutputFileNames(SubProject.core, "index"), - ]); - host.checkTimeoutQueueLength(0); - checkOutputErrorsIncremental(host, emptyArray); - verifyWatches(host); + const { verifyChangeWithFile } = createSolutionInWatchModeToVerifyChanges(); + verifyChangeWithFile(core[1].path, `${core[1].content} +function foo() { }`, /*local*/ true); }); it("builds when new file is added, and its subsequent updates", () => { @@ -242,7 +273,7 @@ export class someClass2 { }`); it("watches config files that are not present", () => { const allFiles = [libFile, ...core, logic[1], ...tests]; - const host = createWatchedSystem(allFiles, { currentDirectory: projectsLocation }); + const host = createTsBuildWatchSystem(allFiles, { currentDirectory: projectsLocation }); createSolutionBuilderWithWatch(host, [`${project}/${SubProject.tests}`]); checkWatchedFiles(host, [core[0], core[1], core[2]!, logic[0], ...tests].map(f => f.path.toLowerCase())); // tslint:disable-line no-unnecessary-type-assertion (TODO: type assertion should be necessary) checkWatchedDirectories(host, emptyArray, /*recursive*/ false); @@ -268,14 +299,10 @@ export class someClass2 { }`); host.writeFile(logic[0].path, logic[0].content); host.checkTimeoutQueueLengthAndRun(1); // Builds logic const changedLogic = getOutputFileStamps(host); - verifyChangedFiles(changedLogic, initial, [ - ...getOutputFileNames(SubProject.logic, "index") - ]); + verifyChangedFiles(changedLogic, initial, getOutputFileNames(SubProject.logic, "index"), emptyArray); host.checkTimeoutQueueLengthAndRun(1); // Builds tests const changedTests = getOutputFileStamps(host); - verifyChangedFiles(changedTests, changedLogic, [ - ...getOutputFileNames(SubProject.tests, "index") - ]); + verifyChangedFiles(changedTests, changedLogic, getOutputFileNames(SubProject.tests, "index"), emptyArray); host.checkTimeoutQueueLength(0); checkOutputErrorsIncremental(host, emptyArray); verifyWatches(host); @@ -305,7 +332,7 @@ export class someClass2 { }`); }; const projectFiles = [coreTsConfig, coreIndex, logicTsConfig, logicIndex]; - const host = createWatchedSystem([libFile, ...projectFiles], { currentDirectory: projectsLocation }); + const host = createTsBuildWatchSystem([libFile, ...projectFiles], { currentDirectory: projectsLocation }); createSolutionBuilderWithWatch(host, [`${project}/${SubProject.logic}`]); verifyWatches(); checkOutputErrorsInitial(host, emptyArray); @@ -318,6 +345,7 @@ export class someClass2 { }`); verifyChangeInCore(`${coreIndex.content} function myFunc() { return 10; }`); + // TODO:: local change does not build logic.js because builder doesnt find any changes in input files to generate output // Make local change to function bar verifyChangeInCore(`${coreIndex.content} function myFunc() { return 100; }`); @@ -328,14 +356,20 @@ function myFunc() { return 100; }`); host.checkTimeoutQueueLengthAndRun(1); // Builds core const changedCore = getOutputFileStamps(); - verifyChangedFiles(changedCore, outputFileStamps, [ - ...getOutputFileNames(SubProject.core, "index") - ]); + verifyChangedFiles( + changedCore, + outputFileStamps, + getOutputFileNames(SubProject.core, "index"), + emptyArray + ); host.checkTimeoutQueueLengthAndRun(1); // Builds logic const changedLogic = getOutputFileStamps(); - verifyChangedFiles(changedLogic, changedCore, [ - ...getOutputFileNames(SubProject.logic, "index") - ]); + verifyChangedFiles( + changedLogic, + changedCore, + getOutputFileNames(SubProject.logic, "index"), + emptyArray + ); host.checkTimeoutQueueLength(0); checkOutputErrorsIncremental(host, emptyArray); verifyWatches(); @@ -346,6 +380,7 @@ function myFunc() { return 100; }`); ...getOutputStamps(host, SubProject.core, "index"), ...getOutputStamps(host, SubProject.logic, "index"), ]; + host.writtenFiles.clear(); return result; } @@ -389,7 +424,7 @@ createSomeObject().message;` }; const files = [libFile, libraryTs, libraryTsconfig, appTs, appTsconfig]; - const host = createWatchedSystem(files, { currentDirectory: `${projectsLocation}/${project}` }); + const host = createTsBuildWatchSystem(files, { currentDirectory: `${projectsLocation}/${project}` }); createSolutionBuilderWithWatch(host, ["App"]); checkOutputErrorsInitial(host, emptyArray); @@ -418,7 +453,7 @@ let y: string = 10;`); host.checkTimeoutQueueLengthAndRun(1); // Builds logic const changedLogic = getOutputFileStamps(host); - verifyChangedFiles(changedLogic, outputFileStamps, emptyArray); + verifyChangedFiles(changedLogic, outputFileStamps, emptyArray, emptyArray); host.checkTimeoutQueueLength(0); checkOutputErrorsIncremental(host, [ `sample1/logic/index.ts(8,5): error TS2322: Type '10' is not assignable to type 'string'.\n` @@ -429,7 +464,7 @@ let x: string = 10;`); host.checkTimeoutQueueLengthAndRun(1); // Builds core const changedCore = getOutputFileStamps(host); - verifyChangedFiles(changedCore, changedLogic, emptyArray); + verifyChangedFiles(changedCore, changedLogic, emptyArray, emptyArray); host.checkTimeoutQueueLength(0); checkOutputErrorsIncremental(host, [ `sample1/core/index.ts(5,5): error TS2322: Type '10' is not assignable to type 'string'.\n`, @@ -448,7 +483,7 @@ let x: string = 10;`); describe("tsc-watch and tsserver works with project references", () => { describe("invoking when references are already built", () => { - function verifyWatchesOfProject(host: WatchedSystem, expectedWatchedFiles: ReadonlyArray, expectedWatchedDirectoriesRecursive: ReadonlyArray, expectedWatchedDirectories?: ReadonlyArray) { + function verifyWatchesOfProject(host: TsBuildWatchSystem, expectedWatchedFiles: ReadonlyArray, expectedWatchedDirectoriesRecursive: ReadonlyArray, expectedWatchedDirectories?: ReadonlyArray) { checkWatchedFilesDetailed(host, expectedWatchedFiles, 1); checkWatchedDirectoriesDetailed(host, expectedWatchedDirectories || emptyArray, 1, /*recursive*/ false); checkWatchedDirectoriesDetailed(host, expectedWatchedDirectoriesRecursive, 1, /*recursive*/ true); @@ -457,9 +492,9 @@ let x: string = 10;`); function createSolutionOfProject(allFiles: ReadonlyArray, currentDirectory: string, solutionBuilderconfig: string, - getOutputFileStamps: (host: WatchedSystem) => ReadonlyArray) { + getOutputFileStamps: (host: TsBuildWatchSystem) => ReadonlyArray) { // Build the composite project - const host = createWatchedSystem(allFiles, { currentDirectory }); + const host = createTsBuildWatchSystem(allFiles, { currentDirectory }); const solutionBuilder = createSolutionBuilder(host, [solutionBuilderconfig], {}); solutionBuilder.buildAllProjects(); const outputFileStamps = getOutputFileStamps(host); @@ -474,7 +509,7 @@ let x: string = 10;`); currentDirectory: string, solutionBuilderconfig: string, watchConfig: string, - getOutputFileStamps: (host: WatchedSystem) => ReadonlyArray) { + getOutputFileStamps: (host: TsBuildWatchSystem) => ReadonlyArray) { // Build the composite project const { host, solutionBuilder } = createSolutionOfProject(allFiles, currentDirectory, solutionBuilderconfig, getOutputFileStamps); @@ -489,7 +524,7 @@ let x: string = 10;`); currentDirectory: string, solutionBuilderconfig: string, openFileName: string, - getOutputFileStamps: (host: WatchedSystem) => ReadonlyArray) { + getOutputFileStamps: (host: TsBuildWatchSystem) => ReadonlyArray) { // Build the composite project const { host, solutionBuilder } = createSolutionOfProject(allFiles, currentDirectory, solutionBuilderconfig, getOutputFileStamps); @@ -527,12 +562,12 @@ let x: string = 10;`); return createSolutionAndServiceOfProject(allFiles, projectsLocation, `${project}/${SubProject.tests}`, tests[1].path, getOutputFileStamps); } - function verifyWatches(host: WatchedSystem, withTsserver?: boolean) { + function verifyWatches(host: TsBuildWatchSystem, withTsserver?: boolean) { verifyWatchesOfProject(host, withTsserver ? expectedWatchedFiles.filter(f => f !== tests[1].path.toLowerCase()) : expectedWatchedFiles, expectedWatchedDirectoriesRecursive); } function verifyScenario( - edit: (host: WatchedSystem, solutionBuilder: SolutionBuilder) => void, + edit: (host: TsBuildWatchSystem, solutionBuilder: SolutionBuilder) => void, expectedFilesAfterEdit: ReadonlyArray ) { it("with tsc-watch", () => { @@ -635,7 +670,7 @@ export function gfoo() { } function verifyWatchState( - host: WatchedSystem, + host: TsBuildWatchSystem, watch: Watch, expectedProgramFiles: ReadonlyArray, expectedWatchedFiles: ReadonlyArray, @@ -722,20 +757,20 @@ export function gfoo() { return createSolutionAndServiceOfProject(allFiles, getProjectPath(project), configToBuild, cTs.path, getOutputFileStamps); } - function getOutputFileStamps(host: WatchedSystem) { - return expectedFiles.map(file => [file, host.getModifiedTime(file)] as OutputFileStamp); + function getOutputFileStamps(host: TsBuildWatchSystem) { + return expectedFiles.map(file => transformOutputToOutputFileStamp(file, host)); } - function verifyProgram(host: WatchedSystem, watch: Watch) { + function verifyProgram(host: TsBuildWatchSystem, watch: Watch) { verifyWatchState(host, watch, expectedProgramFiles, expectedWatchedFiles, expectedWatchedDirectoriesRecursive, defaultDependencies, expectedWatchedDirectories); } - function verifyProject(host: WatchedSystem, service: projectSystem.TestProjectService, orphanInfos?: ReadonlyArray) { + function verifyProject(host: TsBuildWatchSystem, service: projectSystem.TestProjectService, orphanInfos?: ReadonlyArray) { verifyServerState(host, service, expectedProgramFiles, expectedWatchedFiles, expectedWatchedDirectoriesRecursive, orphanInfos); } function verifyServerState( - host: WatchedSystem, + host: TsBuildWatchSystem, service: projectSystem.TestProjectService, expectedProgramFiles: ReadonlyArray, expectedWatchedFiles: ReadonlyArray, @@ -755,13 +790,13 @@ export function gfoo() { } function verifyScenario( - edit: (host: WatchedSystem, solutionBuilder: SolutionBuilder) => void, + edit: (host: TsBuildWatchSystem, solutionBuilder: SolutionBuilder) => void, expectedEditErrors: ReadonlyArray, expectedProgramFiles: ReadonlyArray, expectedWatchedFiles: ReadonlyArray, expectedWatchedDirectoriesRecursive: ReadonlyArray, dependencies: ReadonlyArray<[string, ReadonlyArray]>, - revert?: (host: WatchedSystem) => void, + revert?: (host: TsBuildWatchSystem) => void, orphanInfosAfterEdit?: ReadonlyArray, orphanInfosAfterRevert?: ReadonlyArray) { it("with tsc-watch", () => { @@ -980,8 +1015,8 @@ export function gfoo() { [refs.path, [refs.path]], [cTsFile.path, [cTsFile.path, refs.path, bDts]] ]; - function getOutputFileStamps(host: WatchedSystem) { - return expectedFiles.map(file => [file, host.getModifiedTime(file)] as OutputFileStamp); + function getOutputFileStamps(host: TsBuildWatchSystem) { + return expectedFiles.map(file => transformOutputToOutputFileStamp(file, host)); } const { host, watch } = createSolutionAndWatchModeOfProject(allFiles, getProjectPath(project), "tsconfig.c.json", "tsconfig.c.json", getOutputFileStamps); verifyWatchState(host, watch, expectedProgramFiles, expectedWatchedFiles, expectedWatchedDirectoriesRecursive, defaultDependencies); From 0d9038c30a42f20e7c22eb0c6c5ca3ed00e21eca Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 21 Dec 2018 17:22:17 -0800 Subject: [PATCH 029/101] Handle prepend in incremental build. Always emit when program uses project reference with prepend since it cant tell changes in js/map files --- src/compiler/builder.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index df3b056227f..ef017e2ae97 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -66,6 +66,10 @@ namespace ts { * Already seen affected files */ seenEmittedFiles: Map | undefined; + /** + * true if program has been emitted + */ + programEmitComplete?: true; } function hasSameKeys(map1: ReadonlyMap | undefined, map2: ReadonlyMap | undefined): boolean { @@ -352,6 +356,7 @@ namespace ts { function doneWithAffectedFile(state: BuilderProgramState, affected: SourceFile | Program, isPendingEmit?: boolean) { if (affected === state.program) { state.changedFilesSet.clear(); + state.programEmitComplete = true; } else { state.seenAffectedFiles!.set((affected as SourceFile).path, true); @@ -487,12 +492,22 @@ namespace ts { let affected = getNextAffectedFile(state, cancellationToken, computeHash); let isPendingEmitFile = false; if (!affected) { - affected = getNextAffectedFilePendingEmit(state); - // Done - if (!affected) { - return undefined; + if (!state.compilerOptions.out && !state.compilerOptions.outFile) { + affected = getNextAffectedFilePendingEmit(state); + if (!affected) { + return undefined; + } + isPendingEmitFile = true; + } + else { + const program = Debug.assertDefined(state.program); + // Check if program uses any prepend project references, if thats the case we cant track of the js files of those, so emit even though there are no changes + if (state.programEmitComplete || !some(program.getProjectReferences(), ref => !!ref.prepend)) { + state.programEmitComplete = true; + return undefined; + } + affected = program; } - isPendingEmitFile = true; } // Mark seen emitted files if there are pending files to be emitted From b360ff770af33ea9fbad4bd90cdc79516fa9bd5f Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 26 Dec 2018 11:13:54 -0800 Subject: [PATCH 030/101] Write the tests for incremental build and declaration emit errors handling These will fail since its still TODO --- src/testRunner/unittests/tsbuildWatchMode.ts | 107 +++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/src/testRunner/unittests/tsbuildWatchMode.ts b/src/testRunner/unittests/tsbuildWatchMode.ts index bdc8fe1be86..083061cf96c 100644 --- a/src/testRunner/unittests/tsbuildWatchMode.ts +++ b/src/testRunner/unittests/tsbuildWatchMode.ts @@ -479,6 +479,113 @@ let x: string = 10;`); it("when preserveWatchOutput is passed on command line", () => { verifyIncrementalErrors({ preserveWatchOutput: true, watch: true }, /*disabledConsoleClear*/ true); }); + + describe("when declaration emit errors are present", () => { + const solution = "solution"; + const subProject = "app"; + const subProjectLocation = `${projectsLocation}/${solution}/${subProject}`; + const fileWithError: File = { + path: `${subProjectLocation}/fileWithError.ts`, + content: `export var myClassWithError = class { + tags() { } + private p = 12 + };` + }; + const fileWithFixedError: File = { + path: fileWithError.path, + content: fileWithError.content.replace("private p = 12", "") + }; + const fileWithoutError: File = { + path: `${subProjectLocation}/fileWithoutError.ts`, + content: `export class myClass { }` + }; + const tsconfig: File = { + path: `${subProjectLocation}/tsconfig.json`, + content: JSON.stringify({ compilerOptions: { composite: true } }) + }; + const expectedDtsEmitErrors = [ + `${subProject}/fileWithError.ts(1,12): error TS4094: Property 'p' of exported class expression may not be private or protected.\n` + ]; + const outputs = [ + changeExtension(fileWithError.path, Extension.Js), + changeExtension(fileWithError.path, Extension.Dts), + changeExtension(fileWithoutError.path, Extension.Js), + changeExtension(fileWithoutError.path, Extension.Dts) + ]; + + function verifyDtsErrors(host: TsBuildWatchSystem, isIncremental: boolean, expectedErrors: ReadonlyArray) { + (isIncremental ? checkOutputErrorsIncremental : checkOutputErrorsInitial)(host, expectedErrors); + outputs.forEach(f => assert.equal(host.fileExists(f), !expectedErrors.length, `Expected file ${f} to ${!expectedErrors.length ? "exist" : "not exist"}`)); + } + + function createSolutionWithWatch(withFixedError?: true) { + const files = [libFile, withFixedError ? fileWithFixedError : fileWithError, fileWithoutError, tsconfig]; + const host = createTsBuildWatchSystem(files, { currentDirectory: `${projectsLocation}/${solution}` }); + createSolutionBuilderWithWatch(host, [subProject]); + verifyDtsErrors(host, /*isIncremental*/ false, withFixedError ? emptyArray : expectedDtsEmitErrors); + return host; + } + + function incrementalBuild(host: TsBuildWatchSystem) { + host.checkTimeoutQueueLengthAndRun(1); // Build the app + host.checkTimeoutQueueLength(0); + } + + function fixError(host: TsBuildWatchSystem) { + // Fix error + host.writeFile(fileWithError.path, fileWithFixedError.content); + host.writtenFiles.clear(); + incrementalBuild(host); + verifyDtsErrors(host, /*isIncremental*/ true, emptyArray); + } + + it("when fixing error files all files are emitted", () => { + const host = createSolutionWithWatch(); + fixError(host); + }); + + it("when file with no error changes, declaration errors are reported", () => { + const host = createSolutionWithWatch(); + host.writeFile(fileWithoutError.path, fileWithoutError.content.replace(/myClass/g, "myClass2")); + incrementalBuild(host); + verifyDtsErrors(host, /*isIncremental*/ true, expectedDtsEmitErrors); + }); + + describe("when reporting errors on introducing error", () => { + function createSolutionWithIncrementalError() { + const host = createSolutionWithWatch(/*withFixedError*/ true); + host.writeFile(fileWithError.path, fileWithError.content); + host.writtenFiles.clear(); + + incrementalBuild(host); + checkOutputErrorsIncremental(host, expectedDtsEmitErrors); + assert.equal(host.writtenFiles.size, 0, `Expected not to write any files: ${arrayFrom(host.writtenFiles.keys())}`); + return host; + } + + function verifyWrittenFile(host: TsBuildWatchSystem, f: string) { + assert.isTrue(host.writtenFiles.has(host.toFullPath(f)), `Expected to write ${f}: ${arrayFrom(host.writtenFiles.keys())}`); + } + + it("when fixing errors only changed file is emitted", () => { + const host = createSolutionWithIncrementalError(); + fixError(host); + assert.equal(host.writtenFiles.size, 2, `Expected to write only changed files: ${arrayFrom(host.writtenFiles.keys())}`); + verifyWrittenFile(host, outputs[0]); + verifyWrittenFile(host, outputs[1]); + }); + + it("when file with no error changes, declaration errors are reported", () => { + const host = createSolutionWithIncrementalError(); + host.writeFile(fileWithoutError.path, fileWithoutError.content.replace(/myClass/g, "myClass2")); + host.writtenFiles.clear(); + + incrementalBuild(host); + checkOutputErrorsIncremental(host, expectedDtsEmitErrors); + assert.equal(host.writtenFiles.size, 0, `Expected not to write any files: ${arrayFrom(host.writtenFiles.keys())}`); + }); + }); + }); }); describe("tsc-watch and tsserver works with project references", () => { From 69abc124944ddd7fa9b8c64384be5538757fc536 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 26 Dec 2018 12:07:59 -0800 Subject: [PATCH 031/101] Handle declaration emit errors in tsbuild mode by backing up builder state This helps us revert to state where we pretend as if emit is not done (since we do not do emit if there are errors) --- src/compiler/builder.ts | 53 +++++++++++++++++++++++++++++++++++- src/compiler/builderState.ts | 37 +++++++++++++++++++++---- src/compiler/tsbuild.ts | 12 ++++---- 3 files changed, 89 insertions(+), 13 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index ef017e2ae97..a4c9dd0cc84 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -154,6 +154,38 @@ namespace ts { return state; } + /** + * Releases program and other related not needed properties + */ + function releaseCache(state: BuilderProgramState) { + BuilderState.releaseCache(state); + state.program = undefined; + } + + /** + * Creates a clone of the state + */ + function cloneBuilderProgramState(state: Readonly): BuilderProgramState { + const newState = BuilderState.clone(state) as BuilderProgramState; + newState.semanticDiagnosticsPerFile = cloneMapOrUndefined(state.semanticDiagnosticsPerFile); + newState.changedFilesSet = cloneMap(state.changedFilesSet); + newState.affectedFiles = state.affectedFiles; + newState.affectedFilesIndex = state.affectedFilesIndex; + newState.currentChangedFilePath = state.currentChangedFilePath; + newState.currentAffectedFilesSignatures = cloneMapOrUndefined(state.currentAffectedFilesSignatures); + newState.currentAffectedFilesExportedModulesMap = cloneMapOrUndefined(state.currentAffectedFilesExportedModulesMap); + newState.seenAffectedFiles = cloneMapOrUndefined(state.seenAffectedFiles); + newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles; + newState.semanticDiagnosticsFromOldState = cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); + newState.program = state.program; + newState.compilerOptions = state.compilerOptions; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; + newState.seenEmittedFiles = cloneMapOrUndefined(state.seenEmittedFiles); + newState.programEmitComplete = state.programEmitComplete; + return newState; + } + /** * Verifies that source file is ok to be used in calls that arent handled by next */ @@ -458,7 +490,8 @@ namespace ts { * Computing hash to for signature verification */ const computeHash = host.createHash || generateDjb2Hash; - const state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); + let state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); + let backupState: BuilderProgramState | undefined; // To ensure that we arent storing any references to old program or new program without state newProgram = undefined!; // TODO: GH#18217 @@ -467,9 +500,21 @@ namespace ts { const result = createRedirectedBuilderProgram(state, configFileParsingDiagnostics); result.getState = () => state; + result.backupCurrentState = () => { + Debug.assert(backupState === undefined); + backupState = cloneBuilderProgramState(state); + }; + result.useBackupState = () => { + state = Debug.assertDefined(backupState); + backupState = undefined; + }; result.getAllDependencies = sourceFile => BuilderState.getAllDependencies(state, Debug.assertDefined(state.program), sourceFile); result.getSemanticDiagnostics = getSemanticDiagnostics; result.emit = emit; + result.releaseProgram = () => { + releaseCache(state); + backupState = undefined; + }; if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) { (result as SemanticDiagnosticsBuilderProgram).getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile; @@ -650,6 +695,8 @@ namespace ts { export function createRedirectedBuilderProgram(state: { program: Program | undefined; compilerOptions: CompilerOptions; }, configFileParsingDiagnostics: ReadonlyArray): BuilderProgram { return { getState: notImplemented, + backupCurrentState: noop, + useBackupState: noop, getProgram: () => Debug.assertDefined(state.program), getProgramOrUndefined: () => state.program, releaseProgram: () => state.program = undefined, @@ -694,6 +741,10 @@ namespace ts { export interface BuilderProgram { /*@internal*/ getState(): BuilderProgramState; + /*@internal*/ + backupCurrentState(): void; + /*@internal*/ + useBackupState(): void; /** * Returns current program */ diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index 0462beada9e..552f46c378d 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -50,11 +50,15 @@ namespace ts { /** * Cache of all files excluding default library file for the current program */ - allFilesExcludingDefaultLibraryFile: ReadonlyArray | undefined; + allFilesExcludingDefaultLibraryFile?: ReadonlyArray; /** * Cache of all the file names */ - allFileNames: ReadonlyArray | undefined; + allFileNames?: ReadonlyArray; + } + + export function cloneMapOrUndefined(map: ReadonlyMap | undefined) { + return map ? cloneMap(map) : undefined; } } @@ -230,9 +234,32 @@ namespace ts.BuilderState { fileInfos, referencedMap, exportedModulesMap, - hasCalledUpdateShapeSignature, - allFilesExcludingDefaultLibraryFile: undefined, - allFileNames: undefined + hasCalledUpdateShapeSignature + }; + } + + /** + * Releases needed properties + */ + export function releaseCache(state: BuilderState) { + state.allFilesExcludingDefaultLibraryFile = undefined; + state.allFileNames = undefined; + } + + /** + * Creates a clone of the state + */ + export function clone(state: Readonly): BuilderState { + const fileInfos = createMap(); + state.fileInfos.forEach((value, key) => { + fileInfos.set(key, { ...value }); + }); + // Dont need to backup allFiles info since its cache anyway + return { + fileInfos, + referencedMap: cloneMapOrUndefined(state.referencedMap), + exportedModulesMap: cloneMapOrUndefined(state.exportedModulesMap), + hasCalledUpdateShapeSignature: cloneMap(state.hasCalledUpdateShapeSignature), }; } diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index ae5ddfcccf3..fa84b4bd9bb 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -382,8 +382,6 @@ namespace ts { host.reportDiagnostic = reportDiagnostic || createDiagnosticReporter(system); host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system); return host; - - // TODO after program create } export function createSolutionBuilderHost(system = sys, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary) { @@ -499,9 +497,7 @@ namespace ts { clearMap(allWatchedWildcardDirectories, wildCardWatches => clearMap(wildCardWatches, closeFileWatcherOf)); clearMap(allWatchedInputFiles, inputFileWatches => clearMap(inputFileWatches, closeFileWatcher)); clearMap(allWatchedConfigFiles, closeFileWatcher); - if (!options.watch) { - builderPrograms.clear(); - } + builderPrograms.clear(); updateGetSourceFile(); } @@ -576,7 +572,7 @@ namespace ts { hostWithWatch, resolved, () => { - invalidateProjectAndScheduleBuilds(resolved, ConfigFileProgramReloadLevel.Full); + invalidateProjectAndScheduleBuilds(resolved, ConfigFileProgramReloadLevel.Full); }, PollingInterval.High, WatchType.ConfigFile, @@ -1132,15 +1128,17 @@ namespace ts { return buildErrors(semanticDiagnostics, BuildResultFlags.TypeErrors, "Semantic"); } + // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly + program.backupCurrentState(); let newestDeclarationFileContentChangedTime = minimumDate; let anyDtsChanged = false; let declDiagnostics: Diagnostic[] | undefined; const reportDeclarationDiagnostics = (d: Diagnostic) => (declDiagnostics || (declDiagnostics = [])).push(d); const outputFiles: OutputFile[] = []; - // TODO:: handle declaration diagnostics in incremental build. emitFilesAndReportErrors(program, reportDeclarationDiagnostics, writeFileName, /*reportSummary*/ undefined, (name, text, writeByteOrderMark) => outputFiles.push({ name, text, writeByteOrderMark })); // Don't emit .d.ts if there are decl file errors if (declDiagnostics) { + program.useBackupState(); return buildErrors(declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"); } From 42484b504edadaaf1ef91c307974b643d3ee9eb2 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 27 Dec 2018 10:36:18 -0800 Subject: [PATCH 032/101] Use DirectoryStructureHost for fileExists and readFile --- src/compiler/program.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 6c132ad417d..7dd57a07b9f 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3121,12 +3121,12 @@ namespace ts { /* @internal */ export function parseConfigHostFromCompilerHostLike(host: CompilerHostLike, directoryStructureHost: DirectoryStructureHost = host): ParseConfigFileHost { return { - fileExists: f => host.fileExists(f), + fileExists: f => directoryStructureHost.fileExists(f), readDirectory(root, extensions, excludes, includes, depth) { Debug.assertDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'"); return directoryStructureHost.readDirectory!(root, extensions, excludes, includes, depth); }, - readFile: f => host.readFile(f), + readFile: f => directoryStructureHost.readFile(f), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: () => host.getCurrentDirectory(), onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || (() => undefined), From abc861862ab7c08b07216ba2c4ede7ccefc1cc60 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 10 Jan 2019 15:18:02 -0800 Subject: [PATCH 033/101] Fix typo --- src/compiler/core.ts | 2 +- src/compiler/tsbuild.ts | 2 +- src/compiler/watch.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 17f6c6f4fc3..74ac9e93047 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1391,7 +1391,7 @@ namespace ts { return result; } - export function copyProperities(first: T1, second: T2) { + export function copyProperties(first: T1, second: T2) { for (const id in second) { if (hasOwnProperty.call(second, id)) { (first as any)[id] = second[id]; diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index fa84b4bd9bb..8c1c93eeb0b 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -393,7 +393,7 @@ namespace ts { export function createSolutionBuilderWithWatchHost(system = sys, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter) { const host = createSolutionBuilderHostBase(system, createProgram || createEmitAndSemanticDiagnosticsBuilderProgram as any as CreateProgram, reportDiagnostic, reportSolutionBuilderStatus) as SolutionBuilderWithWatchHost; const watchHost = createWatchHost(system, reportWatchStatus); - copyProperities(host, watchHost); + copyProperties(host, watchHost); return host; } diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index cc6d1236fed..b92289635d3 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -317,7 +317,7 @@ namespace ts { function createWatchCompilerHost(system = sys, createProgram: CreateProgram | undefined, reportDiagnostic: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHost { const writeFileName = (s: string) => system.write(s + system.newLine); const result = createProgramHost(system, createProgram || createEmitAndSemanticDiagnosticsBuilderProgram as any as CreateProgram) as WatchCompilerHost; - copyProperities(result, createWatchHost(system, reportWatchStatus)); + copyProperties(result, createWatchHost(system, reportWatchStatus)); result.afterProgramCreate = builderProgram => { const compilerOptions = builderProgram.getCompilerOptions(); const newLine = getNewLineCharacter(compilerOptions, () => system.newLine); From a0764178377441c1f4736b43e20b2aafa55504b1 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 11 Jan 2019 22:13:29 +0200 Subject: [PATCH 034/101] remove unused error message 2568 --- src/compiler/diagnosticMessages.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4abdf2b0bb7..a534e41992e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2056,10 +2056,6 @@ "category": "Error", "code": 2567 }, - "Type '{0}' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators.": { - "category": "Error", - "code": 2568 - }, "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.": { "category": "Error", "code": 2569 From b23664adf722f45fef4799342392bc43c70ec848 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 11 Jan 2019 10:57:53 -0800 Subject: [PATCH 035/101] Test to verify external source map range addition --- src/testRunner/unittests/customTransforms.ts | 35 ++++++++++++++++++- .../sourceMapExternalSourceFiles.js | 7 ++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js diff --git a/src/testRunner/unittests/customTransforms.ts b/src/testRunner/unittests/customTransforms.ts index 304c0a55c59..aef9ed745ec 100644 --- a/src/testRunner/unittests/customTransforms.ts +++ b/src/testRunner/unittests/customTransforms.ts @@ -95,6 +95,39 @@ namespace ts { module: ModuleKind.ES2015, emitDecoratorMetadata: true, experimentalDecorators: true - }); + }); + + emitsCorrectly("sourceMapExternalSourceFiles", + [ + { + file: "source.ts", + // The text of length 'changed' is made to be on two lines so we know the line map change + text: `\`multi + line\` +'change'` + }, + ], + { + before: [ + context => node => visitNode(node, function visitor(node: Node): Node { + if (isStringLiteral(node) && node.text === "change") { + const text = "'changed'"; + const lineMap = computeLineStarts(text); + setSourceMapRange(node, { + pos: 0, end: text.length, source: { + text, + fileName: "another.html", + lineMap, + getLineAndCharacterOfPosition: pos => computeLineAndCharacterOfPosition(lineMap, pos) + } + }); + return node; + } + return visitEachChild(node, visitor, context); + }) + ] + }, + { sourceMap: true } + ); }); } diff --git a/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js b/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js new file mode 100644 index 00000000000..69406cfe308 --- /dev/null +++ b/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js @@ -0,0 +1,7 @@ +// [source.js.map] +{"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts","another.html"],"names":[],"mappings":"AAAA,iCACyB,CAAA;ACDzB,QACE,CDCM"} + +// [source.js] +"multi\n line"; +'change'; +//# sourceMappingURL=source.js.map \ No newline at end of file From 021c63f1c365c54b6c061d8e4fd0c5cd9f796fa9 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 11 Jan 2019 12:24:33 -0800 Subject: [PATCH 036/101] Use the SourceMapSource to get line and column instead of current source file Fixes #29300 --- src/compiler/emitter.ts | 2 +- .../reference/customTransforms/sourceMapExternalSourceFiles.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 9c09ed79a77..0afd8ee761c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4389,7 +4389,7 @@ namespace ts { return; } - const { line: sourceLine, character: sourceCharacter } = getLineAndCharacterOfPosition(currentSourceFile!, pos); + const { line: sourceLine, character: sourceCharacter } = getLineAndCharacterOfPosition(sourceMapSource, pos); sourceMapGenerator!.addMapping( writer.getLine(), writer.getColumn(), diff --git a/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js b/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js index 69406cfe308..7191d615fc6 100644 --- a/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js +++ b/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js @@ -1,5 +1,5 @@ // [source.js.map] -{"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts","another.html"],"names":[],"mappings":"AAAA,iCACyB,CAAA;ACDzB,QACE,CDCM"} +{"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts","another.html"],"names":[],"mappings":"AAAA,iCACyB,CAAA;ACDzB,QAAS,CDED"} // [source.js] "multi\n line"; From d029fae35ce6a49cf6eba6ea981d1d1299569fe2 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Fri, 11 Jan 2019 14:45:08 -0800 Subject: [PATCH 037/101] Add user preference to opt-in to renaming import paths --- src/harness/client.ts | 5 +++-- src/harness/fourslash.ts | 18 ++++++++++-------- src/harness/harnessLanguageService.ts | 4 ++-- src/server/protocol.ts | 1 + src/server/session.ts | 5 +++-- src/services/rename.ts | 8 ++++---- src/services/services.ts | 4 ++-- src/services/shims.ts | 6 +++--- src/services/types.ts | 6 +++++- src/testRunner/unittests/tsserver/rename.ts | 14 ++++++++++++-- .../reference/api/tsserverlibrary.d.ts | 6 +++++- tests/baselines/reference/api/typescript.d.ts | 5 ++++- .../findAllRefs_importType_exportEquals.ts | 1 + tests/cases/fourslash/fourslash.ts | 4 ++-- tests/cases/fourslash/renameImport.ts | 1 + 15 files changed, 58 insertions(+), 30 deletions(-) diff --git a/src/harness/client.ts b/src/harness/client.ts index 27365e3ecf1..937b859853b 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -384,7 +384,8 @@ namespace ts.server { return notImplemented(); } - getRenameInfo(fileName: string, position: number, findInStrings?: boolean, findInComments?: boolean): RenameInfo { + getRenameInfo(fileName: string, position: number, _options?: RenameInfoOptions, findInStrings?: boolean, findInComments?: boolean): RenameInfo { + // not using options they should be sent with a RenameInfo request, which this function does not perform const args: protocol.RenameRequestArgs = { ...this.createFileLocationRequestArgs(fileName, position), findInStrings, findInComments }; const request = this.processRequest(CommandNames.Rename, args); @@ -428,7 +429,7 @@ namespace ts.server { this.lastRenameEntry.inputs.position !== position || this.lastRenameEntry.inputs.findInStrings !== findInStrings || this.lastRenameEntry.inputs.findInComments !== findInComments) { - this.getRenameInfo(fileName, position, findInStrings, findInComments); + this.getRenameInfo(fileName, position, { allowRenameOfImportPath: true }, findInStrings, findInComments); } return this.lastRenameEntry!.locations; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index db1c326a504..fd11236501d 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1308,8 +1308,9 @@ Actual: ${stringify(fullActual)}`); } } - public verifyRenameInfoSucceeded(displayName: string | undefined, fullDisplayName: string | undefined, kind: string | undefined, kindModifiers: string | undefined, fileToRename: string | undefined, expectedRange: Range | undefined): void { - const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); + public verifyRenameInfoSucceeded(displayName: string | undefined, fullDisplayName: string | undefined, kind: string | undefined, kindModifiers: string | undefined, fileToRename: string | undefined, expectedRange: Range | undefined, allowRenameOfImportPath: boolean | undefined): void { + allowRenameOfImportPath = allowRenameOfImportPath === undefined ? true : allowRenameOfImportPath; + const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition, { allowRenameOfImportPath }); if (!renameInfo.canRename) { throw this.raiseError("Rename did not succeed"); } @@ -1334,8 +1335,9 @@ Actual: ${stringify(fullActual)}`); } } - public verifyRenameInfoFailed(message?: string) { - const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); + public verifyRenameInfoFailed(message?: string, allowRenameOfImportPath?: boolean) { + allowRenameOfImportPath = allowRenameOfImportPath === undefined ? true : allowRenameOfImportPath; + const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition, { allowRenameOfImportPath }); if (renameInfo.canRename) { throw this.raiseError("Rename was expected to fail"); } @@ -4091,12 +4093,12 @@ namespace FourSlashInterface { this.state.verifySemanticClassifications(classifications); } - public renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, expectedRange?: FourSlash.Range) { - this.state.verifyRenameInfoSucceeded(displayName, fullDisplayName, kind, kindModifiers, fileToRename, expectedRange); + public renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, expectedRange?: FourSlash.Range, allowRenameOfImportPath?: boolean) { + this.state.verifyRenameInfoSucceeded(displayName, fullDisplayName, kind, kindModifiers, fileToRename, expectedRange, allowRenameOfImportPath); } - public renameInfoFailed(message?: string) { - this.state.verifyRenameInfoFailed(message); + public renameInfoFailed(message?: string, allowRenameOfImportPath?: boolean) { + this.state.verifyRenameInfoFailed(message, allowRenameOfImportPath); } public renameLocations(startRanges: ArrayOrSingle, options: RenameLocationsOptions) { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 581d5cc045d..d233ddf4585 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -469,8 +469,8 @@ namespace Harness.LanguageService { getSignatureHelpItems(fileName: string, position: number, options: ts.SignatureHelpItemsOptions | undefined): ts.SignatureHelpItems { return unwrapJSONCallResult(this.shim.getSignatureHelpItems(fileName, position, options)); } - getRenameInfo(fileName: string, position: number): ts.RenameInfo { - return unwrapJSONCallResult(this.shim.getRenameInfo(fileName, position)); + getRenameInfo(fileName: string, position: number, options?: ts.RenameInfoOptions): ts.RenameInfo { + return unwrapJSONCallResult(this.shim.getRenameInfo(fileName, position, options)); } findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ts.RenameLocation[] { return unwrapJSONCallResult(this.shim.findRenameLocations(fileName, position, findInStrings, findInComments)); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 193621da82a..8b9df926d82 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2905,6 +2905,7 @@ namespace ts.server.protocol { readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; readonly lazyConfiguredProjectsFromExternalProject?: boolean; + readonly allowRenameOfImportPath?: boolean; } export interface CompilerOptions { diff --git a/src/server/session.ts b/src/server/session.ts index d534f445ee3..8c300b121e1 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1177,7 +1177,8 @@ namespace ts.server { private getRenameInfo(args: protocol.FileLocationRequestArgs): RenameInfo { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); - return project.getLanguageService().getRenameInfo(file, position); + const preferences = this.getHostPreferences(); + return project.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: preferences.allowRenameOfImportPath }); } private getProjects(args: protocol.FileRequestArgs, getScriptInfoEnsuringProjectsUptoDate?: boolean, ignoreNoProjectError?: boolean): Projects { @@ -1236,7 +1237,7 @@ namespace ts.server { if (!simplifiedResult) return locations; const defaultProject = this.getDefaultProject(args); - const renameInfo: protocol.RenameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position), Debug.assertDefined(this.projectService.getScriptInfo(file))); + const renameInfo: protocol.RenameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getHostPreferences().allowRenameOfImportPath }), Debug.assertDefined(this.projectService.getScriptInfo(file))); return { info: renameInfo, locs: this.toSpanGroups(locations) }; } diff --git a/src/services/rename.ts b/src/services/rename.ts index a51d79797bf..cef53d251ed 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -1,14 +1,14 @@ /* @internal */ namespace ts.Rename { - export function getRenameInfo(program: Program, sourceFile: SourceFile, position: number): RenameInfo { + export function getRenameInfo(program: Program, sourceFile: SourceFile, position: number, options?: RenameInfoOptions): RenameInfo { const node = getTouchingPropertyName(sourceFile, position); const renameInfo = node && nodeIsEligibleForRename(node) - ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, declaration => program.isSourceFileDefaultLibrary(declaration.getSourceFile())) + ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, options || {}, declaration => program.isSourceFileDefaultLibrary(declaration.getSourceFile())) : undefined; return renameInfo || getRenameInfoError(Diagnostics.You_cannot_rename_this_element); } - function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, isDefinedInLibraryFile: (declaration: Node) => boolean): RenameInfo | undefined { + function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, options: RenameInfoOptions, isDefinedInLibraryFile: (declaration: Node) => boolean): RenameInfo | undefined { const symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) return; // Only allow a symbol to be renamed if it actually has at least one declaration. @@ -26,7 +26,7 @@ namespace ts.Rename { } if (isStringLiteralLike(node) && tryGetImportFromModuleSpecifier(node)) { - return getRenameInfoForModule(node, sourceFile, symbol); + return options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } const kind = SymbolDisplay.getSymbolKind(typeChecker, symbol, node); diff --git a/src/services/services.ts b/src/services/services.ts index 15f9709cb38..6bf6566da36 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2062,9 +2062,9 @@ namespace ts { } } - function getRenameInfo(fileName: string, position: number): RenameInfo { + function getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo { synchronizeHostData(); - return Rename.getRenameInfo(program, getValidSourceFile(fileName), position); + return Rename.getRenameInfo(program, getValidSourceFile(fileName), position, options); } function getRefactorContext(file: SourceFile, positionOrRange: number | TextRange, preferences: UserPreferences, formatOptions?: FormatCodeSettings): RefactorContext { diff --git a/src/services/shims.ts b/src/services/shims.ts index ff66680bdbc..33ea4333e6f 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -164,7 +164,7 @@ namespace ts { * Returns a JSON-encoded value of the type: * { canRename: boolean, localizedErrorMessage: string, displayName: string, fullDisplayName: string, kind: string, kindModifiers: string, triggerSpan: { start; length } } */ - getRenameInfo(fileName: string, position: number): string; + getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): string; /** * Returns a JSON-encoded value of the type: @@ -831,10 +831,10 @@ namespace ts { ); } - public getRenameInfo(fileName: string, position: number): string { + public getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): string { return this.forwardJSONCall( `getRenameInfo('${fileName}', ${position})`, - () => this.languageService.getRenameInfo(fileName, position) + () => this.languageService.getRenameInfo(fileName, position, options) ); } diff --git a/src/services/types.ts b/src/services/types.ts index 5100a999306..b45a816d6e0 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -294,7 +294,7 @@ namespace ts { getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; - getRenameInfo(fileName: string, position: number): RenameInfo; + getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined; getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; @@ -848,6 +848,10 @@ namespace ts { localizedErrorMessage: string; } + export interface RenameInfoOptions { + readonly allowRenameOfImportPath?: boolean; + } + export interface SignatureHelpParameter { name: string; documentation: SymbolDisplayPart[]; diff --git a/src/testRunner/unittests/tsserver/rename.ts b/src/testRunner/unittests/tsserver/rename.ts index 75c08bb8bb0..4e95e79e31f 100644 --- a/src/testRunner/unittests/tsserver/rename.ts +++ b/src/testRunner/unittests/tsserver/rename.ts @@ -7,8 +7,18 @@ namespace ts.projectSystem { const session = createSession(createServerHost([aTs, bTs])); openFilesForSession([bTs], session); - const response = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";')); - assert.deepEqual(response, { + const response1 = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";')); + assert.deepEqual(response1, { + info: { + canRename: false, + localizedErrorMessage: "You cannot rename this element." + }, + locs: [{ file: bTs.path, locs: [protocolRenameSpanFromSubstring(bTs.content, "./a")] }], + }); + + session.getProjectService().setHostConfiguration({ preferences: { allowRenameOfImportPath: true } }); + const response2 = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";')); + assert.deepEqual(response2, { info: { canRename: true, fileToRename: aTs.path, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 91f492ddd1d..30effc9e91a 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4706,7 +4706,7 @@ declare namespace ts { getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; - getRenameInfo(fileName: string, position: number): RenameInfo; + getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined; getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; @@ -5150,6 +5150,9 @@ declare namespace ts { canRename: false; localizedErrorMessage: string; } + interface RenameInfoOptions { + readonly allowRenameOfImportPath?: boolean; + } interface SignatureHelpParameter { name: string; documentation: SymbolDisplayPart[]; @@ -7923,6 +7926,7 @@ declare namespace ts.server.protocol { readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; readonly lazyConfiguredProjectsFromExternalProject?: boolean; + readonly allowRenameOfImportPath?: boolean; } interface CompilerOptions { allowJs?: boolean; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 0e693f698f2..cd6d45a1647 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -4706,7 +4706,7 @@ declare namespace ts { getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; - getRenameInfo(fileName: string, position: number): RenameInfo; + getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined; getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; @@ -5150,6 +5150,9 @@ declare namespace ts { canRename: false; localizedErrorMessage: string; } + interface RenameInfoOptions { + readonly allowRenameOfImportPath?: boolean; + } interface SignatureHelpParameter { name: string; documentation: SymbolDisplayPart[]; diff --git a/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts b/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts index 496fa8a9d3b..3734b7a2e88 100644 --- a/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts +++ b/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts @@ -27,4 +27,5 @@ verify.renameLocations(r2, [r0, r1, r2]); for (const range of [r3b, r4b]) { goTo.rangeStart(range); verify.renameInfoSucceeded(/*displayName*/ "/a.ts", /*fullDisplayName*/ "/a.ts", /*kind*/ "module", /*kindModifiers*/ "", /*fileToRename*/ "/a.ts", range); + verify.renameInfoFailed("You cannot rename this element.", /*allowRenameOfImportPath*/ false); } diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 293c8d21574..ed71f8893b8 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -282,8 +282,8 @@ declare namespace FourSlashInterface { text: string; textSpan?: TextSpan; }[]): void; - renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, range?: Range): void; - renameInfoFailed(message?: string): void; + renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, range?: Range, allowRenameOfImportPath?: boolean): void; + renameInfoFailed(message?: string, allowRenameOfImportPath?: boolean): void; renameLocations(startRanges: ArrayOrSingle, options: RenameLocationsOptions): void; /** Verify the quick info available at the current marker. */ diff --git a/tests/cases/fourslash/renameImport.ts b/tests/cases/fourslash/renameImport.ts index 6fdef347205..8292da4013d 100644 --- a/tests/cases/fourslash/renameImport.ts +++ b/tests/cases/fourslash/renameImport.ts @@ -27,6 +27,7 @@ goTo.eachRange(range => { const name = target === "dir" ? "/dir" : target === "dir/index" ? "/dir/index.ts" : "/a.ts"; const kind = target === "dir" ? "directory" : "module"; verify.renameInfoSucceeded(/*displayName*/ name, /*fullDisplayName*/ name, /*kind*/ kind, /*kindModifiers*/ "", /*fileToRename*/ name, range); + verify.renameInfoFailed("You cannot rename this element.", /*allowRenameOfImportPath*/ false); }); goTo.marker("global"); From c88016d397b1fef00b6f4f39f0be1510e3d358ef Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Fri, 11 Jan 2019 14:52:47 -0800 Subject: [PATCH 038/101] Fix comment --- src/harness/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/client.ts b/src/harness/client.ts index 937b859853b..1c7c0adb834 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -385,7 +385,7 @@ namespace ts.server { } getRenameInfo(fileName: string, position: number, _options?: RenameInfoOptions, findInStrings?: boolean, findInComments?: boolean): RenameInfo { - // not using options they should be sent with a RenameInfo request, which this function does not perform + // Not passing along 'options' because server should already have those from the 'configure' command const args: protocol.RenameRequestArgs = { ...this.createFileLocationRequestArgs(fileName, position), findInStrings, findInComments }; const request = this.processRequest(CommandNames.Rename, args); From c909becdd5eba949cf48b4c0f8d89c783384d6a9 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 Jan 2019 12:40:50 -0800 Subject: [PATCH 039/101] Rename indexing variable --- src/compiler/builder.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 0db924913f4..89577cfd68a 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -265,11 +265,11 @@ namespace ts { const { affectedFilesPendingEmit } = state; if (affectedFilesPendingEmit) { const seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = createMap()); - for (let affectedFilesIndex = state.affectedFilesPendingEmitIndex!; affectedFilesIndex < affectedFilesPendingEmit.length; affectedFilesIndex++) { - const affectedFile = Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[affectedFilesIndex]); + for (let i = state.affectedFilesPendingEmitIndex!; i < affectedFilesPendingEmit.length; i++) { + const affectedFile = Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { // emit this file - state.affectedFilesPendingEmitIndex = affectedFilesIndex; + state.affectedFilesPendingEmitIndex = i; return affectedFile; } } @@ -695,6 +695,10 @@ namespace ts { // In case of emit builder, cache the files to be emitted if (affectedFilesPendingEmit) { state.affectedFilesPendingEmit = concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + // affectedFilesPendingEmitIndex === undefined + // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files + // so start from 0 as array would be affectedFilesPendingEmit + // else, continue to iterate from existing index, the current set is appended to existing files if (state.affectedFilesPendingEmitIndex === undefined) { state.affectedFilesPendingEmitIndex = 0; } From 39435887939e65650fffc14e19d80d9046b429a8 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 Jan 2019 12:48:22 -0800 Subject: [PATCH 040/101] CompilerHostLikeForCache rename --- src/compiler/program.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index fbe9a6c5089..8b66d82fa81 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -203,7 +203,7 @@ namespace ts { return compilerHost; } - interface ComplierHostLikeForCache { + interface CompilerHostLikeForCache { fileExists(fileName: string): boolean; readFile(fileName: string, encoding?: string): string | undefined; directoryExists?(directory: string): boolean; @@ -213,7 +213,7 @@ namespace ts { /*@internal*/ export function changeCompilerHostLikeToUseCache( - host: ComplierHostLikeForCache, + host: CompilerHostLikeForCache, toPath: (fileName: string) => Path, getSourceFile?: CompilerHost["getSourceFile"] ) { From ff97d86cfabd038275a479c82887d6416302e81b Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 Jan 2019 13:40:54 -0800 Subject: [PATCH 041/101] Fix typo --- src/compiler/tsbuild.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 8c1c93eeb0b..60c61f2e62c 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -1008,8 +1008,8 @@ namespace ts { const project = buildQueue[index]; const prepend = referencingProjects.getValue(project); if (prepend !== undefined) { - // If the project is referenced with prepend, always build downstream project, - // If declaration output is changed changed, build the project + // If the project is referenced with prepend, always build downstream projects, + // If declaration output is changed, build the project // otherwise mark the project UpToDateWithUpstreamTypes so it updates output time stamps const status = projectStatus.getValue(project); if (prepend || !(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { From e745fca4133b62ff8e0d8f6024c6a4c8c3b9cf1f Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 Jan 2019 14:35:05 -0800 Subject: [PATCH 042/101] Fix typo --- src/compiler/tsbuild.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 60c61f2e62c..4395b302944 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -1422,7 +1422,7 @@ namespace ts { return first(outputs); } } - return Debug.fail(`project ${project.options.configFilePath} expected to have atleast one output`); + return Debug.fail(`project ${project.options.configFilePath} expected to have at least one output`); } export function formatUpToDateStatus(configFileName: string, status: UpToDateStatus, relName: (fileName: string) => string, formatMessage: (message: DiagnosticMessage, ...args: string[]) => T) { From 6e54cbdaff4d988a8bad6e63af8d91a1330b354b Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 Jan 2019 15:09:34 -0800 Subject: [PATCH 043/101] Handle generating action for export equals with anonymous symbol Fixes #28845 --- src/services/completions.ts | 4 ++- ...ompletionsImport_exportEquals_anonymous.ts | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 8203b66549b..f17ee862cca 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -367,7 +367,9 @@ namespace ts.Completions { } function getSymbolName(symbol: Symbol, origin: SymbolOriginInfo | undefined, target: ScriptTarget): string { - return origin && originIsExport(origin) && origin.isDefaultExport && symbol.escapedName === InternalSymbolName.Default + return origin && originIsExport(origin) && ( + (origin.isDefaultExport && symbol.escapedName === InternalSymbolName.Default) || + (symbol.escapedName === InternalSymbolName.ExportEquals)) // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase. ? firstDefined(symbol.declarations, d => isExportAssignment(d) && isIdentifier(d.expression) ? d.expression.text : undefined) || codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) diff --git a/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts b/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts new file mode 100644 index 00000000000..c5e87877cfb --- /dev/null +++ b/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts @@ -0,0 +1,28 @@ +/// + +// Use `/src` to test that directory names are not included in conversion from module path to identifier. +// @noLib: true + +// @Filename: /src/foo-bar.ts +////export = 0; + +// @Filename: /src/b.ts +////exp/*0*/ +////fooB/*1*/ + +goTo.marker("0"); +const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true }; +const exportEntry: FourSlashInterface.ExpectedCompletionEntryObject = { name: "fooBar", source: "/src/foo-bar", sourceDisplay: "./foo-bar", text: "(property) export=: 0", kind: "property", hasAction: true }; +verify.completions( + { marker: "0", exact: ["undefined", exportEntry, ...completion.statementKeywordsWithTypes], preferences }, + { marker: "1", includes: exportEntry, preferences } +); +verify.applyCodeActionFromCompletion("0", { + name: "fooBar", + source: "/src/foo-bar", + description: `Import 'fooBar' from module "./foo-bar"`, + newFileContent: `import fooBar = require("./foo-bar"); + +exp +fooB`, +}); \ No newline at end of file From 2c50ed30890c46d2671894eda21dbf2882166e0a Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Mon, 14 Jan 2019 17:05:25 -0800 Subject: [PATCH 044/101] Respond to CR --- src/harness/fourslash.ts | 9 ++++----- src/services/rename.ts | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index fd11236501d..1276de7de44 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1308,9 +1308,8 @@ Actual: ${stringify(fullActual)}`); } } - public verifyRenameInfoSucceeded(displayName: string | undefined, fullDisplayName: string | undefined, kind: string | undefined, kindModifiers: string | undefined, fileToRename: string | undefined, expectedRange: Range | undefined, allowRenameOfImportPath: boolean | undefined): void { - allowRenameOfImportPath = allowRenameOfImportPath === undefined ? true : allowRenameOfImportPath; - const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition, { allowRenameOfImportPath }); + public verifyRenameInfoSucceeded(displayName: string | undefined, fullDisplayName: string | undefined, kind: string | undefined, kindModifiers: string | undefined, fileToRename: string | undefined, expectedRange: Range | undefined, renameInfoOptions: ts.RenameInfoOptions | undefined): void { + const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition, renameInfoOptions || { allowRenameOfImportPath: true }); if (!renameInfo.canRename) { throw this.raiseError("Rename did not succeed"); } @@ -4093,8 +4092,8 @@ namespace FourSlashInterface { this.state.verifySemanticClassifications(classifications); } - public renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, expectedRange?: FourSlash.Range, allowRenameOfImportPath?: boolean) { - this.state.verifyRenameInfoSucceeded(displayName, fullDisplayName, kind, kindModifiers, fileToRename, expectedRange, allowRenameOfImportPath); + public renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, expectedRange?: FourSlash.Range, options?: ts.RenameInfoOptions) { + this.state.verifyRenameInfoSucceeded(displayName, fullDisplayName, kind, kindModifiers, fileToRename, expectedRange, options); } public renameInfoFailed(message?: string, allowRenameOfImportPath?: boolean) { diff --git a/src/services/rename.ts b/src/services/rename.ts index cef53d251ed..484349acc86 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -3,12 +3,12 @@ namespace ts.Rename { export function getRenameInfo(program: Program, sourceFile: SourceFile, position: number, options?: RenameInfoOptions): RenameInfo { const node = getTouchingPropertyName(sourceFile, position); const renameInfo = node && nodeIsEligibleForRename(node) - ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, options || {}, declaration => program.isSourceFileDefaultLibrary(declaration.getSourceFile())) + ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, declaration => program.isSourceFileDefaultLibrary(declaration.getSourceFile()), options) : undefined; return renameInfo || getRenameInfoError(Diagnostics.You_cannot_rename_this_element); } - function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, options: RenameInfoOptions, isDefinedInLibraryFile: (declaration: Node) => boolean): RenameInfo | undefined { + function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, isDefinedInLibraryFile: (declaration: Node) => boolean, options?: RenameInfoOptions): RenameInfo | undefined { const symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) return; // Only allow a symbol to be renamed if it actually has at least one declaration. @@ -26,7 +26,7 @@ namespace ts.Rename { } if (isStringLiteralLike(node) && tryGetImportFromModuleSpecifier(node)) { - return options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; + return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } const kind = SymbolDisplay.getSymbolKind(typeChecker, symbol, node); From 5763e2c3d436d516e1e2932ed16a61705ae15a69 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 14 Jan 2019 17:08:04 -0800 Subject: [PATCH 045/101] Remove overzealous simple relationship check for unique symbols --- src/compiler/checker.ts | 1 - tests/baselines/reference/uniqueSymbols.js | 7 + .../baselines/reference/uniqueSymbols.symbols | 797 +++++++++--------- tests/baselines/reference/uniqueSymbols.types | 7 + .../types/uniqueSymbol/uniqueSymbols.ts | 4 + 5 files changed, 419 insertions(+), 397 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b48ba6bbcd6..f365af51ac6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11667,7 +11667,6 @@ namespace ts { if (s & TypeFlags.Undefined && (!strictNullChecks || t & (TypeFlags.Undefined | TypeFlags.Void))) return true; if (s & TypeFlags.Null && (!strictNullChecks || t & TypeFlags.Null)) return true; if (s & TypeFlags.Object && t & TypeFlags.NonPrimitive) return true; - if (s & TypeFlags.UniqueESSymbol || t & TypeFlags.UniqueESSymbol) return false; if (relation === assignableRelation || relation === comparableRelation) { if (s & TypeFlags.Any) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any diff --git a/tests/baselines/reference/uniqueSymbols.js b/tests/baselines/reference/uniqueSymbols.js index 0e6bde4fe47..54f59e8e217 100644 --- a/tests/baselines/reference/uniqueSymbols.js +++ b/tests/baselines/reference/uniqueSymbols.js @@ -28,6 +28,10 @@ var varInitToConstDeclAmbient = constType; const constInitToConstCallWithTypeQuery: typeof constCall = constCall; const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; +// assignment from any +// https://github.com/Microsoft/TypeScript/issues/29108 +const fromAny: unique symbol = {} as any; + // function return inference function funcReturnConstCall() { return constCall; } function funcReturnLetCall() { return letCall; } @@ -286,6 +290,9 @@ var varInitToConstDeclAmbient = constType; // declaration from initializer with type query const constInitToConstCallWithTypeQuery = constCall; const constInitToConstDeclAmbientWithTypeQuery = constType; +// assignment from any +// https://github.com/Microsoft/TypeScript/issues/29108 +const fromAny = {}; // function return inference function funcReturnConstCall() { return constCall; } function funcReturnLetCall() { return letCall; } diff --git a/tests/baselines/reference/uniqueSymbols.symbols b/tests/baselines/reference/uniqueSymbols.symbols index 6fef1873082..d7da3595a59 100644 --- a/tests/baselines/reference/uniqueSymbols.symbols +++ b/tests/baselines/reference/uniqueSymbols.symbols @@ -81,717 +81,722 @@ const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; >constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) >constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) +// assignment from any +// https://github.com/Microsoft/TypeScript/issues/29108 +const fromAny: unique symbol = {} as any; +>fromAny : Symbol(fromAny, Decl(uniqueSymbols.ts, 31, 5)) + // function return inference function funcReturnConstCall() { return constCall; } ->funcReturnConstCall : Symbol(funcReturnConstCall, Decl(uniqueSymbols.ts, 27, 77)) +>funcReturnConstCall : Symbol(funcReturnConstCall, Decl(uniqueSymbols.ts, 31, 41)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) function funcReturnLetCall() { return letCall; } ->funcReturnLetCall : Symbol(funcReturnLetCall, Decl(uniqueSymbols.ts, 30, 52)) +>funcReturnLetCall : Symbol(funcReturnLetCall, Decl(uniqueSymbols.ts, 34, 52)) >letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) function funcReturnVarCall() { return varCall; } ->funcReturnVarCall : Symbol(funcReturnVarCall, Decl(uniqueSymbols.ts, 31, 48)) +>funcReturnVarCall : Symbol(funcReturnVarCall, Decl(uniqueSymbols.ts, 35, 48)) >varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) // function return value with type query function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; } ->funcReturnConstCallWithTypeQuery : Symbol(funcReturnConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 32, 48)) +>funcReturnConstCallWithTypeQuery : Symbol(funcReturnConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 36, 48)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) // generator function yield inference function* genFuncYieldConstCall() { yield constCall; } ->genFuncYieldConstCall : Symbol(genFuncYieldConstCall, Decl(uniqueSymbols.ts, 35, 83)) +>genFuncYieldConstCall : Symbol(genFuncYieldConstCall, Decl(uniqueSymbols.ts, 39, 83)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) function* genFuncYieldLetCall() { yield letCall; } ->genFuncYieldLetCall : Symbol(genFuncYieldLetCall, Decl(uniqueSymbols.ts, 38, 54)) +>genFuncYieldLetCall : Symbol(genFuncYieldLetCall, Decl(uniqueSymbols.ts, 42, 54)) >letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) function* genFuncYieldVarCall() { yield varCall; } ->genFuncYieldVarCall : Symbol(genFuncYieldVarCall, Decl(uniqueSymbols.ts, 39, 50)) +>genFuncYieldVarCall : Symbol(genFuncYieldVarCall, Decl(uniqueSymbols.ts, 43, 50)) >varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) // generator function yield with return type query function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } ->genFuncYieldConstCallWithTypeQuery : Symbol(genFuncYieldConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 40, 50)) +>genFuncYieldConstCallWithTypeQuery : Symbol(genFuncYieldConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 44, 50)) >IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) // async function return inference async function asyncFuncReturnConstCall() { return constCall; } ->asyncFuncReturnConstCall : Symbol(asyncFuncReturnConstCall, Decl(uniqueSymbols.ts, 43, 103)) +>asyncFuncReturnConstCall : Symbol(asyncFuncReturnConstCall, Decl(uniqueSymbols.ts, 47, 103)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) async function asyncFuncReturnLetCall() { return letCall; } ->asyncFuncReturnLetCall : Symbol(asyncFuncReturnLetCall, Decl(uniqueSymbols.ts, 46, 63)) +>asyncFuncReturnLetCall : Symbol(asyncFuncReturnLetCall, Decl(uniqueSymbols.ts, 50, 63)) >letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) async function asyncFuncReturnVarCall() { return varCall; } ->asyncFuncReturnVarCall : Symbol(asyncFuncReturnVarCall, Decl(uniqueSymbols.ts, 47, 59)) +>asyncFuncReturnVarCall : Symbol(asyncFuncReturnVarCall, Decl(uniqueSymbols.ts, 51, 59)) >varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) // async generator function yield inference async function* asyncGenFuncYieldConstCall() { yield constCall; } ->asyncGenFuncYieldConstCall : Symbol(asyncGenFuncYieldConstCall, Decl(uniqueSymbols.ts, 48, 59)) +>asyncGenFuncYieldConstCall : Symbol(asyncGenFuncYieldConstCall, Decl(uniqueSymbols.ts, 52, 59)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) async function* asyncGenFuncYieldLetCall() { yield letCall; } ->asyncGenFuncYieldLetCall : Symbol(asyncGenFuncYieldLetCall, Decl(uniqueSymbols.ts, 51, 65)) +>asyncGenFuncYieldLetCall : Symbol(asyncGenFuncYieldLetCall, Decl(uniqueSymbols.ts, 55, 65)) >letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) async function* asyncGenFuncYieldVarCall() { yield varCall; } ->asyncGenFuncYieldVarCall : Symbol(asyncGenFuncYieldVarCall, Decl(uniqueSymbols.ts, 52, 61)) +>asyncGenFuncYieldVarCall : Symbol(asyncGenFuncYieldVarCall, Decl(uniqueSymbols.ts, 56, 61)) >varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) // classes class C { ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) static readonly readonlyStaticCall = Symbol(); ->readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) static readonly readonlyStaticType: unique symbol; ->readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); ->readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) static readwriteStaticCall = Symbol(); ->readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) readonly readonlyCall = Symbol(); ->readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) readwriteCall = Symbol(); ->readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) } declare const c: C; ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) const constInitToCReadonlyStaticCall = C.readonlyStaticCall; ->constInitToCReadonlyStaticCall : Symbol(constInitToCReadonlyStaticCall, Decl(uniqueSymbols.ts, 67, 5)) ->C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>constInitToCReadonlyStaticCall : Symbol(constInitToCReadonlyStaticCall, Decl(uniqueSymbols.ts, 71, 5)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) const constInitToCReadonlyStaticType = C.readonlyStaticType; ->constInitToCReadonlyStaticType : Symbol(constInitToCReadonlyStaticType, Decl(uniqueSymbols.ts, 68, 5)) ->C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>constInitToCReadonlyStaticType : Symbol(constInitToCReadonlyStaticType, Decl(uniqueSymbols.ts, 72, 5)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; ->constInitToCReadonlyStaticTypeAndCall : Symbol(constInitToCReadonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 69, 5)) ->C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) +>constInitToCReadonlyStaticTypeAndCall : Symbol(constInitToCReadonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 73, 5)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) const constInitToCReadwriteStaticCall = C.readwriteStaticCall; ->constInitToCReadwriteStaticCall : Symbol(constInitToCReadwriteStaticCall, Decl(uniqueSymbols.ts, 70, 5)) ->C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) +>constInitToCReadwriteStaticCall : Symbol(constInitToCReadwriteStaticCall, Decl(uniqueSymbols.ts, 74, 5)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; ->constInitToCReadonlyStaticCallWithTypeQuery : Symbol(constInitToCReadonlyStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 72, 5)) ->C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) ->C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>constInitToCReadonlyStaticCallWithTypeQuery : Symbol(constInitToCReadonlyStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 76, 5)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; ->constInitToCReadonlyStaticTypeWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeWithTypeQuery, Decl(uniqueSymbols.ts, 73, 5)) ->C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) ->C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>constInitToCReadonlyStaticTypeWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeWithTypeQuery, Decl(uniqueSymbols.ts, 77, 5)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; ->constInitToCReadonlyStaticTypeAndCallWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeAndCallWithTypeQuery, Decl(uniqueSymbols.ts, 74, 5)) ->C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) ->C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) +>constInitToCReadonlyStaticTypeAndCallWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeAndCallWithTypeQuery, Decl(uniqueSymbols.ts, 78, 5)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; ->constInitToCReadwriteStaticCallWithTypeQuery : Symbol(constInitToCReadwriteStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 75, 5)) ->C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) ->C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) +>constInitToCReadwriteStaticCallWithTypeQuery : Symbol(constInitToCReadwriteStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 79, 5)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) const constInitToCReadonlyCall = c.readonlyCall; ->constInitToCReadonlyCall : Symbol(constInitToCReadonlyCall, Decl(uniqueSymbols.ts, 77, 5)) ->c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>constInitToCReadonlyCall : Symbol(constInitToCReadonlyCall, Decl(uniqueSymbols.ts, 81, 5)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) const constInitToCReadwriteCall = c.readwriteCall; ->constInitToCReadwriteCall : Symbol(constInitToCReadwriteCall, Decl(uniqueSymbols.ts, 78, 5)) ->c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>constInitToCReadwriteCall : Symbol(constInitToCReadwriteCall, Decl(uniqueSymbols.ts, 82, 5)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall; ->constInitToCReadonlyCallWithTypeQuery : Symbol(constInitToCReadonlyCallWithTypeQuery, Decl(uniqueSymbols.ts, 79, 5)) ->c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) ->c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>constInitToCReadonlyCallWithTypeQuery : Symbol(constInitToCReadonlyCallWithTypeQuery, Decl(uniqueSymbols.ts, 83, 5)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall; ->constInitToCReadwriteCallWithTypeQuery : Symbol(constInitToCReadwriteCallWithTypeQuery, Decl(uniqueSymbols.ts, 80, 5)) ->c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) ->c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>constInitToCReadwriteCallWithTypeQuery : Symbol(constInitToCReadwriteCallWithTypeQuery, Decl(uniqueSymbols.ts, 84, 5)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall; ->constInitToCReadonlyCallWithIndexedAccess : Symbol(constInitToCReadonlyCallWithIndexedAccess, Decl(uniqueSymbols.ts, 81, 5)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>constInitToCReadonlyCallWithIndexedAccess : Symbol(constInitToCReadonlyCallWithIndexedAccess, Decl(uniqueSymbols.ts, 85, 5)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall; ->constInitToCReadwriteCallWithIndexedAccess : Symbol(constInitToCReadwriteCallWithIndexedAccess, Decl(uniqueSymbols.ts, 82, 5)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>constInitToCReadwriteCallWithIndexedAccess : Symbol(constInitToCReadwriteCallWithIndexedAccess, Decl(uniqueSymbols.ts, 86, 5)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) // interfaces interface I { ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) readonly readonlyType: unique symbol; ->readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) } declare const i: I; ->i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 92, 13)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) const constInitToIReadonlyType = i.readonlyType; ->constInitToIReadonlyType : Symbol(constInitToIReadonlyType, Decl(uniqueSymbols.ts, 90, 5)) ->i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) ->i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) ->readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>constInitToIReadonlyType : Symbol(constInitToIReadonlyType, Decl(uniqueSymbols.ts, 94, 5)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 92, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; ->constInitToIReadonlyTypeWithTypeQuery : Symbol(constInitToIReadonlyTypeWithTypeQuery, Decl(uniqueSymbols.ts, 91, 5)) ->i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) ->i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) ->readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) ->i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) ->i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) ->readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>constInitToIReadonlyTypeWithTypeQuery : Symbol(constInitToIReadonlyTypeWithTypeQuery, Decl(uniqueSymbols.ts, 95, 5)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 92, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 92, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; ->constInitToIReadonlyTypeWithIndexedAccess : Symbol(constInitToIReadonlyTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 92, 5)) ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) ->i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) ->i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) ->readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>constInitToIReadonlyTypeWithIndexedAccess : Symbol(constInitToIReadonlyTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 96, 5)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 92, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) // type literals type L = { ->L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 96, 84)) readonly readonlyType: unique symbol; ->readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) nested: { ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) readonly readonlyNestedType: unique symbol; ->readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) } }; declare const l: L; ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 96, 84)) const constInitToLReadonlyType = l.readonlyType; ->constInitToLReadonlyType : Symbol(constInitToLReadonlyType, Decl(uniqueSymbols.ts, 103, 5)) ->l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>constInitToLReadonlyType : Symbol(constInitToLReadonlyType, Decl(uniqueSymbols.ts, 107, 5)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; ->constInitToLReadonlyNestedType : Symbol(constInitToLReadonlyNestedType, Decl(uniqueSymbols.ts, 104, 5)) ->l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>constInitToLReadonlyNestedType : Symbol(constInitToLReadonlyNestedType, Decl(uniqueSymbols.ts, 108, 5)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; ->constInitToLReadonlyTypeWithTypeQuery : Symbol(constInitToLReadonlyTypeWithTypeQuery, Decl(uniqueSymbols.ts, 105, 5)) ->l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) ->l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>constInitToLReadonlyTypeWithTypeQuery : Symbol(constInitToLReadonlyTypeWithTypeQuery, Decl(uniqueSymbols.ts, 109, 5)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; ->constInitToLReadonlyNestedTypeWithTypeQuery : Symbol(constInitToLReadonlyNestedTypeWithTypeQuery, Decl(uniqueSymbols.ts, 106, 5)) ->l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>constInitToLReadonlyNestedTypeWithTypeQuery : Symbol(constInitToLReadonlyNestedTypeWithTypeQuery, Decl(uniqueSymbols.ts, 110, 5)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; ->constInitToLReadonlyTypeWithIndexedAccess : Symbol(constInitToLReadonlyTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 107, 5)) ->L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) ->l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>constInitToLReadonlyTypeWithIndexedAccess : Symbol(constInitToLReadonlyTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 111, 5)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 96, 84)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; ->constInitToLReadonlyNestedTypeWithIndexedAccess : Symbol(constInitToLReadonlyNestedTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 108, 5)) ->L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) ->l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>constInitToLReadonlyNestedTypeWithIndexedAccess : Symbol(constInitToLReadonlyNestedTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 112, 5)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 96, 84)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) // type argument inference const promiseForConstCall = Promise.resolve(constCall); ->promiseForConstCall : Symbol(promiseForConstCall, Decl(uniqueSymbols.ts, 111, 5)) +>promiseForConstCall : Symbol(promiseForConstCall, Decl(uniqueSymbols.ts, 115, 5)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) const arrayOfConstCall = [constCall]; ->arrayOfConstCall : Symbol(arrayOfConstCall, Decl(uniqueSymbols.ts, 112, 5)) +>arrayOfConstCall : Symbol(arrayOfConstCall, Decl(uniqueSymbols.ts, 116, 5)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) // unique symbol widening in expressions declare const s: unique symbol; ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) declare namespace N { const s: unique symbol; } ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 120, 27)) declare const o: { [s]: "a", [N.s]: "b" }; ->o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) ->[s] : Symbol([s], Decl(uniqueSymbols.ts, 117, 18)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->[N.s] : Symbol([N.s], Decl(uniqueSymbols.ts, 117, 28)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>o : Symbol(o, Decl(uniqueSymbols.ts, 121, 13)) +>[s] : Symbol([s], Decl(uniqueSymbols.ts, 121, 18)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>[N.s] : Symbol([N.s], Decl(uniqueSymbols.ts, 121, 28)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) declare function f(x: T): T; ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->T : Symbol(T, Decl(uniqueSymbols.ts, 118, 19)) ->x : Symbol(x, Decl(uniqueSymbols.ts, 118, 22)) ->T : Symbol(T, Decl(uniqueSymbols.ts, 118, 19)) ->T : Symbol(T, Decl(uniqueSymbols.ts, 118, 19)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>T : Symbol(T, Decl(uniqueSymbols.ts, 122, 19)) +>x : Symbol(x, Decl(uniqueSymbols.ts, 122, 22)) +>T : Symbol(T, Decl(uniqueSymbols.ts, 122, 19)) +>T : Symbol(T, Decl(uniqueSymbols.ts, 122, 19)) declare function g(x: typeof s): void; ->g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) ->x : Symbol(x, Decl(uniqueSymbols.ts, 119, 19)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>g : Symbol(g, Decl(uniqueSymbols.ts, 122, 31), Decl(uniqueSymbols.ts, 123, 38)) +>x : Symbol(x, Decl(uniqueSymbols.ts, 123, 19)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) declare function g(x: typeof N.s): void; ->g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) ->x : Symbol(x, Decl(uniqueSymbols.ts, 120, 19)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>g : Symbol(g, Decl(uniqueSymbols.ts, 122, 31), Decl(uniqueSymbols.ts, 123, 38)) +>x : Symbol(x, Decl(uniqueSymbols.ts, 124, 19)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // widening positions // argument inference f(s); ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) f(N.s); ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) f(N["s"]); ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // array literal elements [s]; ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) [N.s]; ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) [N["s"]]; ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // property assignments/methods const o2 = { ->o2 : Symbol(o2, Decl(uniqueSymbols.ts, 135, 5)) +>o2 : Symbol(o2, Decl(uniqueSymbols.ts, 139, 5)) a: s, ->a : Symbol(a, Decl(uniqueSymbols.ts, 135, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>a : Symbol(a, Decl(uniqueSymbols.ts, 139, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) b: N.s, ->b : Symbol(b, Decl(uniqueSymbols.ts, 136, 9)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>b : Symbol(b, Decl(uniqueSymbols.ts, 140, 9)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) c: N["s"], ->c : Symbol(c, Decl(uniqueSymbols.ts, 137, 11)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 141, 11)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) method1() { return s; }, ->method1 : Symbol(method1, Decl(uniqueSymbols.ts, 138, 14)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method1 : Symbol(method1, Decl(uniqueSymbols.ts, 142, 14)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) async method2() { return s; }, ->method2 : Symbol(method2, Decl(uniqueSymbols.ts, 140, 28)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method2 : Symbol(method2, Decl(uniqueSymbols.ts, 144, 28)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) async * method3() { yield s; }, ->method3 : Symbol(method3, Decl(uniqueSymbols.ts, 141, 34)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method3 : Symbol(method3, Decl(uniqueSymbols.ts, 145, 34)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) * method4() { yield s; }, ->method4 : Symbol(method4, Decl(uniqueSymbols.ts, 142, 35)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method4 : Symbol(method4, Decl(uniqueSymbols.ts, 146, 35)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) method5(p = s) { return p; }, ->method5 : Symbol(method5, Decl(uniqueSymbols.ts, 143, 29)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 144, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 144, 12)) +>method5 : Symbol(method5, Decl(uniqueSymbols.ts, 147, 29)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 148, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 148, 12)) }; // property initializers class C0 { ->C0 : Symbol(C0, Decl(uniqueSymbols.ts, 145, 2)) +>C0 : Symbol(C0, Decl(uniqueSymbols.ts, 149, 2)) static readonly a = s; ->a : Symbol(C0.a, Decl(uniqueSymbols.ts, 148, 10)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>a : Symbol(C0.a, Decl(uniqueSymbols.ts, 152, 10)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) static readonly b = N.s; ->b : Symbol(C0.b, Decl(uniqueSymbols.ts, 149, 26)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>b : Symbol(C0.b, Decl(uniqueSymbols.ts, 153, 26)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) static readonly c = N["s"]; ->c : Symbol(C0.c, Decl(uniqueSymbols.ts, 150, 28)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>c : Symbol(C0.c, Decl(uniqueSymbols.ts, 154, 28)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) static d = s; ->d : Symbol(C0.d, Decl(uniqueSymbols.ts, 151, 31)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>d : Symbol(C0.d, Decl(uniqueSymbols.ts, 155, 31)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) static e = N.s; ->e : Symbol(C0.e, Decl(uniqueSymbols.ts, 153, 17)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>e : Symbol(C0.e, Decl(uniqueSymbols.ts, 157, 17)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) static f = N["s"]; ->f : Symbol(C0.f, Decl(uniqueSymbols.ts, 154, 19)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>f : Symbol(C0.f, Decl(uniqueSymbols.ts, 158, 19)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) readonly a = s; ->a : Symbol(C0.a, Decl(uniqueSymbols.ts, 155, 22)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>a : Symbol(C0.a, Decl(uniqueSymbols.ts, 159, 22)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) readonly b = N.s; ->b : Symbol(C0.b, Decl(uniqueSymbols.ts, 157, 19)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>b : Symbol(C0.b, Decl(uniqueSymbols.ts, 161, 19)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) readonly c = N["s"]; ->c : Symbol(C0.c, Decl(uniqueSymbols.ts, 158, 21)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>c : Symbol(C0.c, Decl(uniqueSymbols.ts, 162, 21)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) d = s; ->d : Symbol(C0.d, Decl(uniqueSymbols.ts, 159, 24)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>d : Symbol(C0.d, Decl(uniqueSymbols.ts, 163, 24)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) e = N.s; ->e : Symbol(C0.e, Decl(uniqueSymbols.ts, 161, 10)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>e : Symbol(C0.e, Decl(uniqueSymbols.ts, 165, 10)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) f = N["s"]; ->f : Symbol(C0.f, Decl(uniqueSymbols.ts, 162, 12)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>f : Symbol(C0.f, Decl(uniqueSymbols.ts, 166, 12)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) method1() { return s; } ->method1 : Symbol(C0.method1, Decl(uniqueSymbols.ts, 163, 15)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method1 : Symbol(C0.method1, Decl(uniqueSymbols.ts, 167, 15)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) async method2() { return s; } ->method2 : Symbol(C0.method2, Decl(uniqueSymbols.ts, 165, 27)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method2 : Symbol(C0.method2, Decl(uniqueSymbols.ts, 169, 27)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) async * method3() { yield s; } ->method3 : Symbol(C0.method3, Decl(uniqueSymbols.ts, 166, 33)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method3 : Symbol(C0.method3, Decl(uniqueSymbols.ts, 170, 33)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) * method4() { yield s; } ->method4 : Symbol(C0.method4, Decl(uniqueSymbols.ts, 167, 34)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method4 : Symbol(C0.method4, Decl(uniqueSymbols.ts, 171, 34)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) method5(p = s) { return p; } ->method5 : Symbol(C0.method5, Decl(uniqueSymbols.ts, 168, 28)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 169, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 169, 12)) +>method5 : Symbol(C0.method5, Decl(uniqueSymbols.ts, 172, 28)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 173, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 173, 12)) } // non-widening positions // element access o[s]; ->o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>o : Symbol(o, Decl(uniqueSymbols.ts, 121, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) o[N.s]; ->o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>o : Symbol(o, Decl(uniqueSymbols.ts, 121, 13)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) o[N["s"]]; ->o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>o : Symbol(o, Decl(uniqueSymbols.ts, 121, 13)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // arguments (no-inference) f(s); ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) f(N.s); ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) f(N["s"]); ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) g(s); ->g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>g : Symbol(g, Decl(uniqueSymbols.ts, 122, 31), Decl(uniqueSymbols.ts, 123, 38)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) g(N.s); ->g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>g : Symbol(g, Decl(uniqueSymbols.ts, 122, 31), Decl(uniqueSymbols.ts, 123, 38)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) g(N["s"]); ->g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>g : Symbol(g, Decl(uniqueSymbols.ts, 122, 31), Decl(uniqueSymbols.ts, 123, 38)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // falsy expressions s || ""; ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) N.s || ""; ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) N["s"] || ""; ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // conditionals Math.random() * 2 ? s : "a"; >Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) >Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) Math.random() * 2 ? N.s : "a"; >Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) >Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) Math.random() * 2 ? N["s"] : "a"; >Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) >Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // computed property names ({ [s]: "a", ->[s] : Symbol([s], Decl(uniqueSymbols.ts, 198, 2)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>[s] : Symbol([s], Decl(uniqueSymbols.ts, 202, 2)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) [N.s]: "b", ->[N.s] : Symbol([N.s], Decl(uniqueSymbols.ts, 199, 13)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>[N.s] : Symbol([N.s], Decl(uniqueSymbols.ts, 203, 13)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) }); class C1 { ->C1 : Symbol(C1, Decl(uniqueSymbols.ts, 201, 3)) +>C1 : Symbol(C1, Decl(uniqueSymbols.ts, 205, 3)) static [s]: "a"; ->[s] : Symbol(C1[s], Decl(uniqueSymbols.ts, 203, 10)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>[s] : Symbol(C1[s], Decl(uniqueSymbols.ts, 207, 10)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) static [N.s]: "b"; ->[N.s] : Symbol(C1[N.s], Decl(uniqueSymbols.ts, 204, 20)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>[N.s] : Symbol(C1[N.s], Decl(uniqueSymbols.ts, 208, 20)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) [s]: "a"; ->[s] : Symbol(C1[s], Decl(uniqueSymbols.ts, 205, 22)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>[s] : Symbol(C1[s], Decl(uniqueSymbols.ts, 209, 22)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) [N.s]: "b"; ->[N.s] : Symbol(C1[N.s], Decl(uniqueSymbols.ts, 207, 13)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>[N.s] : Symbol(C1[N.s], Decl(uniqueSymbols.ts, 211, 13)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) } // contextual types interface Context { ->Context : Symbol(Context, Decl(uniqueSymbols.ts, 209, 1)) +>Context : Symbol(Context, Decl(uniqueSymbols.ts, 213, 1)) method1(): typeof s; ->method1 : Symbol(Context.method1, Decl(uniqueSymbols.ts, 213, 19)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method1 : Symbol(Context.method1, Decl(uniqueSymbols.ts, 217, 19)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) method2(): Promise; ->method2 : Symbol(Context.method2, Decl(uniqueSymbols.ts, 214, 24)) +>method2 : Symbol(Context.method2, Decl(uniqueSymbols.ts, 218, 24)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) method3(): AsyncIterableIterator; ->method3 : Symbol(Context.method3, Decl(uniqueSymbols.ts, 215, 33)) +>method3 : Symbol(Context.method3, Decl(uniqueSymbols.ts, 219, 33)) >AsyncIterableIterator : Symbol(AsyncIterableIterator, Decl(lib.esnext.asynciterable.d.ts, --, --)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) method4(): IterableIterator; ->method4 : Symbol(Context.method4, Decl(uniqueSymbols.ts, 216, 47)) +>method4 : Symbol(Context.method4, Decl(uniqueSymbols.ts, 220, 47)) >IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) method5(p?: typeof s): typeof s; ->method5 : Symbol(Context.method5, Decl(uniqueSymbols.ts, 217, 42)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 218, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method5 : Symbol(Context.method5, Decl(uniqueSymbols.ts, 221, 42)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 222, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) } const o3: Context = { ->o3 : Symbol(o3, Decl(uniqueSymbols.ts, 221, 5)) ->Context : Symbol(Context, Decl(uniqueSymbols.ts, 209, 1)) +>o3 : Symbol(o3, Decl(uniqueSymbols.ts, 225, 5)) +>Context : Symbol(Context, Decl(uniqueSymbols.ts, 213, 1)) method1() { ->method1 : Symbol(method1, Decl(uniqueSymbols.ts, 221, 21)) +>method1 : Symbol(method1, Decl(uniqueSymbols.ts, 225, 21)) return s; // return type should not widen due to contextual type ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) }, async method2() { ->method2 : Symbol(method2, Decl(uniqueSymbols.ts, 224, 6)) +>method2 : Symbol(method2, Decl(uniqueSymbols.ts, 228, 6)) return s; // return type should not widen due to contextual type ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) }, async * method3() { ->method3 : Symbol(method3, Decl(uniqueSymbols.ts, 227, 6)) +>method3 : Symbol(method3, Decl(uniqueSymbols.ts, 231, 6)) yield s; // yield type should not widen due to contextual type ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) }, * method4() { ->method4 : Symbol(method4, Decl(uniqueSymbols.ts, 230, 6)) +>method4 : Symbol(method4, Decl(uniqueSymbols.ts, 234, 6)) yield s; // yield type should not widen due to contextual type ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) }, method5(p = s) { // parameter should not widen due to contextual type ->method5 : Symbol(method5, Decl(uniqueSymbols.ts, 233, 6)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 234, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method5 : Symbol(method5, Decl(uniqueSymbols.ts, 237, 6)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 238, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) return p; ->p : Symbol(p, Decl(uniqueSymbols.ts, 234, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 238, 12)) }, }; @@ -799,60 +804,60 @@ const o3: Context = { // allowed when not emitting declarations const o4 = { ->o4 : Symbol(o4, Decl(uniqueSymbols.ts, 241, 5)) +>o4 : Symbol(o4, Decl(uniqueSymbols.ts, 245, 5)) method1(p: typeof s): typeof s { ->method1 : Symbol(method1, Decl(uniqueSymbols.ts, 241, 12)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 242, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method1 : Symbol(method1, Decl(uniqueSymbols.ts, 245, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 246, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) return p; ->p : Symbol(p, Decl(uniqueSymbols.ts, 242, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 246, 12)) }, method2(p: I["readonlyType"]): I["readonlyType"] { ->method2 : Symbol(method2, Decl(uniqueSymbols.ts, 244, 6)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 245, 12)) ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) +>method2 : Symbol(method2, Decl(uniqueSymbols.ts, 248, 6)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 249, 12)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) return p; ->p : Symbol(p, Decl(uniqueSymbols.ts, 245, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 249, 12)) } }; const ce0 = class { ->ce0 : Symbol(ce0, Decl(uniqueSymbols.ts, 250, 5)) +>ce0 : Symbol(ce0, Decl(uniqueSymbols.ts, 254, 5)) method1(p: typeof s): typeof s { ->method1 : Symbol(ce0.method1, Decl(uniqueSymbols.ts, 250, 19)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 251, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method1 : Symbol(ce0.method1, Decl(uniqueSymbols.ts, 254, 19)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 255, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) return p; ->p : Symbol(p, Decl(uniqueSymbols.ts, 251, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 255, 12)) } method2(p: I["readonlyType"]): I["readonlyType"] { ->method2 : Symbol(ce0.method2, Decl(uniqueSymbols.ts, 253, 5)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 254, 12)) ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) +>method2 : Symbol(ce0.method2, Decl(uniqueSymbols.ts, 257, 5)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 258, 12)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) return p; ->p : Symbol(p, Decl(uniqueSymbols.ts, 254, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 258, 12)) } }; function funcInferredReturnType(obj: { method(p: typeof s): void }) { ->funcInferredReturnType : Symbol(funcInferredReturnType, Decl(uniqueSymbols.ts, 257, 2)) ->obj : Symbol(obj, Decl(uniqueSymbols.ts, 259, 32)) ->method : Symbol(method, Decl(uniqueSymbols.ts, 259, 38)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 259, 46)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>funcInferredReturnType : Symbol(funcInferredReturnType, Decl(uniqueSymbols.ts, 261, 2)) +>obj : Symbol(obj, Decl(uniqueSymbols.ts, 263, 32)) +>method : Symbol(method, Decl(uniqueSymbols.ts, 263, 38)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 263, 46)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) return obj; ->obj : Symbol(obj, Decl(uniqueSymbols.ts, 259, 32)) +>obj : Symbol(obj, Decl(uniqueSymbols.ts, 263, 32)) } diff --git a/tests/baselines/reference/uniqueSymbols.types b/tests/baselines/reference/uniqueSymbols.types index 7bf4b7fdf4a..9ee3be1cb28 100644 --- a/tests/baselines/reference/uniqueSymbols.types +++ b/tests/baselines/reference/uniqueSymbols.types @@ -85,6 +85,13 @@ const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; >constType : unique symbol >constType : unique symbol +// assignment from any +// https://github.com/Microsoft/TypeScript/issues/29108 +const fromAny: unique symbol = {} as any; +>fromAny : unique symbol +>{} as any : any +>{} : {} + // function return inference function funcReturnConstCall() { return constCall; } >funcReturnConstCall : () => symbol diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts index 498a1c2904d..59d00a55ed9 100644 --- a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts @@ -31,6 +31,10 @@ var varInitToConstDeclAmbient = constType; const constInitToConstCallWithTypeQuery: typeof constCall = constCall; const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; +// assignment from any +// https://github.com/Microsoft/TypeScript/issues/29108 +const fromAny: unique symbol = {} as any; + // function return inference function funcReturnConstCall() { return constCall; } function funcReturnLetCall() { return letCall; } From 104434182b6bf0922920b935ad8a083201fd8ed7 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Mon, 14 Jan 2019 17:01:46 -0800 Subject: [PATCH 046/101] Harden telemetryOnOpenFile against disabled projects As for syntax-only servers, we can't meaningfully report open-file telemetry for projects with disabled language services. Hopefully, a deeper fix will follow, but this solves the immediate problem that VS disables the LS for all projects when it sees a failure in applyChangedToOpenFiles (because it assumes the server state is corrupt). --- src/server/editorServices.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index cd1c69a2d67..3e062efc272 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -2777,7 +2777,12 @@ namespace ts.server { return; } - const info: OpenFileInfo = { checkJs: !!scriptInfo.getDefaultProject().getSourceFile(scriptInfo.path)!.checkJsDirective }; + const project = scriptInfo.getDefaultProject(); + if (!project.languageServiceEnabled) { + return; + } + + const info: OpenFileInfo = { checkJs: !!project.getSourceFile(scriptInfo.path)!.checkJsDirective }; this.eventHandler({ eventName: OpenFileInfoTelemetryEvent, data: { info } }); } From 208148d05c6d2c2f0cee93a9bcc913dee1286198 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 14 Jan 2019 17:47:52 -0800 Subject: [PATCH 047/101] Fix crash in getTextOfPropertyName --- src/compiler/checker.ts | 36 ++++++---- src/compiler/utilities.ts | 3 +- .../crashInGetTextOfComputedPropertyName.js | 48 +++++++++++++ ...ashInGetTextOfComputedPropertyName.symbols | 71 +++++++++++++++++++ ...crashInGetTextOfComputedPropertyName.types | 71 +++++++++++++++++++ .../crashInGetTextOfComputedPropertyName.ts | 30 ++++++++ 6 files changed, 243 insertions(+), 16 deletions(-) create mode 100644 tests/baselines/reference/crashInGetTextOfComputedPropertyName.js create mode 100644 tests/baselines/reference/crashInGetTextOfComputedPropertyName.symbols create mode 100644 tests/baselines/reference/crashInGetTextOfComputedPropertyName.types create mode 100644 tests/cases/compiler/crashInGetTextOfComputedPropertyName.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b48ba6bbcd6..48232a2e026 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6447,6 +6447,13 @@ namespace ts { return isDynamicName(node) && !isLateBindableName(node); } + /** + * Gets the late-bound name for a computed property name. + */ + function getLateBoundName(node: LateBoundName) { + return getLateBoundNameFromType(checkComputedPropertyName(node)); + } + /** * Gets the symbolic name for a late-bound member from its type. */ @@ -7354,7 +7361,7 @@ namespace ts { function isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression | JsxAttributes): boolean { const list = obj.properties as NodeArray; return list.some(property => { - const name = property.name && getTextOfPropertyName(property.name); + const name = property.name && !isComputedNonLiteralName(property.name) ? getTextOfPropertyName(property.name) : undefined; const expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); return !!expected && isLiteralType(expected) && !isTypeIdenticalTo(getTypeOfNode(property), expected); }); @@ -15059,7 +15066,10 @@ namespace ts { } function getTypeOfDestructuredProperty(type: Type, name: PropertyName) { - const text = getTextOfPropertyName(name); + const text = !isComputedNonLiteralName(name) ? getTextOfPropertyName(name) : + isLateBindableName(name) ? getLateBoundName(name) : + undefined; + if (text === undefined) return errorType; return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || isNumericLiteralName(text) && getIndexTypeOfType(type, IndexKind.Number) || getIndexTypeOfType(type, IndexKind.String) || @@ -17191,11 +17201,9 @@ namespace ts { const parentDeclaration = declaration.parent.parent; const name = declaration.propertyName || declaration.name; const parentType = getContextualTypeForVariableLikeDeclaration(parentDeclaration); - if (parentType && !isBindingPattern(name)) { + if (parentType && !isBindingPattern(name) && !isComputedNonLiteralName(name)) { const text = getTextOfPropertyName(name); - if (text !== undefined) { - return getTypeOfPropertyOfType(parentType, text); - } + return getTypeOfPropertyOfType(parentType, text); } } @@ -22201,8 +22209,8 @@ namespace ts { function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType: Type, property: ObjectLiteralElementLike, allProperties?: NodeArray, rightIsThis = false) { if (property.kind === SyntaxKind.PropertyAssignment || property.kind === SyntaxKind.ShorthandPropertyAssignment) { const name = property.name; - const text = getTextOfPropertyName(name); - if (text) { + if (!isComputedNonLiteralName(name)) { + const text = getTextOfPropertyName(name); const prop = getPropertyOfType(objectLiteralType, text); if (prop) { markPropertyAsReferenced(prop, property, rightIsThis); @@ -25524,14 +25532,12 @@ namespace ts { const parent = node.parent.parent; const parentType = getTypeForBindingElementParent(parent); const name = node.propertyName || node.name; - if (!isBindingPattern(name)) { + if (!isBindingPattern(name) && !isComputedNonLiteralName(name)) { const nameText = getTextOfPropertyName(name); - if (nameText) { - const property = getPropertyOfType(parentType!, nameText); // TODO: GH#18217 - if (property) { - markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === SyntaxKind.SuperKeyword, parentType!, property); - } + const property = getPropertyOfType(parentType!, nameText); // TODO: GH#18217 + if (property) { + markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === SyntaxKind.SuperKeyword, parentType!, property); } } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9c6b27de13c..3964c487fc2 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -778,7 +778,8 @@ namespace ts { case SyntaxKind.NoSubstitutionTemplateLiteral: return escapeLeadingUnderscores(name.text); case SyntaxKind.ComputedPropertyName: - return isStringOrNumericLiteralLike(name.expression) ? escapeLeadingUnderscores(name.expression.text) : undefined!; // TODO: GH#18217 Almost all uses of this assume the result to be defined! + if (isStringOrNumericLiteralLike(name.expression)) return escapeLeadingUnderscores(name.expression.text); + return Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); default: return Debug.assertNever(name); } diff --git a/tests/baselines/reference/crashInGetTextOfComputedPropertyName.js b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.js new file mode 100644 index 00000000000..71d5df00e2a --- /dev/null +++ b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.js @@ -0,0 +1,48 @@ +//// [crashInGetTextOfComputedPropertyName.ts] +// https://github.com/Microsoft/TypeScript/issues/29006 +export interface A { type: 'a' } +export interface B { type: 'b' } +export type AB = A | B + +const itemId = 'some-id' + +// --- test on first level --- +const items: { [id: string]: AB } = {} +const { [itemId]: itemOk1 } = items +typeof itemOk1 // pass + +// --- test on second level --- +interface ObjWithItems { + items: {[s: string]: AB} +} +const objWithItems: ObjWithItems = { items: {}} + +const itemOk2 = objWithItems.items[itemId] +typeof itemOk2 // pass + +const { + items: { [itemId]: itemWithTSError } = {} /*happens when default value is provided*/ +} = objWithItems + +// in order to re-produce the error, uncomment next line: +typeof itemWithTSError // :( + +// will result in: +// Error from compilation: TypeError: Cannot read property 'charCodeAt' of undefined TypeError: Cannot read property 'charCodeAt' of undefined + +//// [crashInGetTextOfComputedPropertyName.js] +"use strict"; +exports.__esModule = true; +var itemId = 'some-id'; +// --- test on first level --- +var items = {}; +var _a = itemId, itemOk1 = items[_a]; +typeof itemOk1; // pass +var objWithItems = { items: {} }; +var itemOk2 = objWithItems.items[itemId]; +typeof itemOk2; // pass +var _b = objWithItems.items /*happens when default value is provided*/, _c = itemId, itemWithTSError = (_b === void 0 ? {} /*happens when default value is provided*/ : _b)[_c]; +// in order to re-produce the error, uncomment next line: +typeof itemWithTSError; // :( +// will result in: +// Error from compilation: TypeError: Cannot read property 'charCodeAt' of undefined TypeError: Cannot read property 'charCodeAt' of undefined diff --git a/tests/baselines/reference/crashInGetTextOfComputedPropertyName.symbols b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.symbols new file mode 100644 index 00000000000..d0f1721258c --- /dev/null +++ b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.symbols @@ -0,0 +1,71 @@ +=== tests/cases/compiler/crashInGetTextOfComputedPropertyName.ts === +// https://github.com/Microsoft/TypeScript/issues/29006 +export interface A { type: 'a' } +>A : Symbol(A, Decl(crashInGetTextOfComputedPropertyName.ts, 0, 0)) +>type : Symbol(A.type, Decl(crashInGetTextOfComputedPropertyName.ts, 1, 20)) + +export interface B { type: 'b' } +>B : Symbol(B, Decl(crashInGetTextOfComputedPropertyName.ts, 1, 32)) +>type : Symbol(B.type, Decl(crashInGetTextOfComputedPropertyName.ts, 2, 20)) + +export type AB = A | B +>AB : Symbol(AB, Decl(crashInGetTextOfComputedPropertyName.ts, 2, 32)) +>A : Symbol(A, Decl(crashInGetTextOfComputedPropertyName.ts, 0, 0)) +>B : Symbol(B, Decl(crashInGetTextOfComputedPropertyName.ts, 1, 32)) + +const itemId = 'some-id' +>itemId : Symbol(itemId, Decl(crashInGetTextOfComputedPropertyName.ts, 5, 5)) + +// --- test on first level --- +const items: { [id: string]: AB } = {} +>items : Symbol(items, Decl(crashInGetTextOfComputedPropertyName.ts, 8, 5)) +>id : Symbol(id, Decl(crashInGetTextOfComputedPropertyName.ts, 8, 16)) +>AB : Symbol(AB, Decl(crashInGetTextOfComputedPropertyName.ts, 2, 32)) + +const { [itemId]: itemOk1 } = items +>itemId : Symbol(itemId, Decl(crashInGetTextOfComputedPropertyName.ts, 5, 5)) +>itemOk1 : Symbol(itemOk1, Decl(crashInGetTextOfComputedPropertyName.ts, 9, 7)) +>items : Symbol(items, Decl(crashInGetTextOfComputedPropertyName.ts, 8, 5)) + +typeof itemOk1 // pass +>itemOk1 : Symbol(itemOk1, Decl(crashInGetTextOfComputedPropertyName.ts, 9, 7)) + +// --- test on second level --- +interface ObjWithItems { +>ObjWithItems : Symbol(ObjWithItems, Decl(crashInGetTextOfComputedPropertyName.ts, 10, 14)) + + items: {[s: string]: AB} +>items : Symbol(ObjWithItems.items, Decl(crashInGetTextOfComputedPropertyName.ts, 13, 24)) +>s : Symbol(s, Decl(crashInGetTextOfComputedPropertyName.ts, 14, 13)) +>AB : Symbol(AB, Decl(crashInGetTextOfComputedPropertyName.ts, 2, 32)) +} +const objWithItems: ObjWithItems = { items: {}} +>objWithItems : Symbol(objWithItems, Decl(crashInGetTextOfComputedPropertyName.ts, 16, 5)) +>ObjWithItems : Symbol(ObjWithItems, Decl(crashInGetTextOfComputedPropertyName.ts, 10, 14)) +>items : Symbol(items, Decl(crashInGetTextOfComputedPropertyName.ts, 16, 36)) + +const itemOk2 = objWithItems.items[itemId] +>itemOk2 : Symbol(itemOk2, Decl(crashInGetTextOfComputedPropertyName.ts, 18, 5)) +>objWithItems.items : Symbol(ObjWithItems.items, Decl(crashInGetTextOfComputedPropertyName.ts, 13, 24)) +>objWithItems : Symbol(objWithItems, Decl(crashInGetTextOfComputedPropertyName.ts, 16, 5)) +>items : Symbol(ObjWithItems.items, Decl(crashInGetTextOfComputedPropertyName.ts, 13, 24)) +>itemId : Symbol(itemId, Decl(crashInGetTextOfComputedPropertyName.ts, 5, 5)) + +typeof itemOk2 // pass +>itemOk2 : Symbol(itemOk2, Decl(crashInGetTextOfComputedPropertyName.ts, 18, 5)) + +const { + items: { [itemId]: itemWithTSError } = {} /*happens when default value is provided*/ +>items : Symbol(ObjWithItems.items, Decl(crashInGetTextOfComputedPropertyName.ts, 13, 24)) +>itemId : Symbol(itemId, Decl(crashInGetTextOfComputedPropertyName.ts, 5, 5)) +>itemWithTSError : Symbol(itemWithTSError, Decl(crashInGetTextOfComputedPropertyName.ts, 22, 12)) + +} = objWithItems +>objWithItems : Symbol(objWithItems, Decl(crashInGetTextOfComputedPropertyName.ts, 16, 5)) + +// in order to re-produce the error, uncomment next line: +typeof itemWithTSError // :( +>itemWithTSError : Symbol(itemWithTSError, Decl(crashInGetTextOfComputedPropertyName.ts, 22, 12)) + +// will result in: +// Error from compilation: TypeError: Cannot read property 'charCodeAt' of undefined TypeError: Cannot read property 'charCodeAt' of undefined diff --git a/tests/baselines/reference/crashInGetTextOfComputedPropertyName.types b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.types new file mode 100644 index 00000000000..7d9ce4aa34b --- /dev/null +++ b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.types @@ -0,0 +1,71 @@ +=== tests/cases/compiler/crashInGetTextOfComputedPropertyName.ts === +// https://github.com/Microsoft/TypeScript/issues/29006 +export interface A { type: 'a' } +>type : "a" + +export interface B { type: 'b' } +>type : "b" + +export type AB = A | B +>AB : AB + +const itemId = 'some-id' +>itemId : "some-id" +>'some-id' : "some-id" + +// --- test on first level --- +const items: { [id: string]: AB } = {} +>items : { [id: string]: AB; } +>id : string +>{} : {} + +const { [itemId]: itemOk1 } = items +>itemId : "some-id" +>itemOk1 : AB +>items : { [id: string]: AB; } + +typeof itemOk1 // pass +>typeof itemOk1 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>itemOk1 : AB + +// --- test on second level --- +interface ObjWithItems { + items: {[s: string]: AB} +>items : { [s: string]: AB; } +>s : string +} +const objWithItems: ObjWithItems = { items: {}} +>objWithItems : ObjWithItems +>{ items: {}} : { items: {}; } +>items : {} +>{} : {} + +const itemOk2 = objWithItems.items[itemId] +>itemOk2 : AB +>objWithItems.items[itemId] : AB +>objWithItems.items : { [s: string]: AB; } +>objWithItems : ObjWithItems +>items : { [s: string]: AB; } +>itemId : "some-id" + +typeof itemOk2 // pass +>typeof itemOk2 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>itemOk2 : AB + +const { + items: { [itemId]: itemWithTSError } = {} /*happens when default value is provided*/ +>items : any +>itemId : "some-id" +>itemWithTSError : AB +>{} : {} + +} = objWithItems +>objWithItems : ObjWithItems + +// in order to re-produce the error, uncomment next line: +typeof itemWithTSError // :( +>typeof itemWithTSError : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>itemWithTSError : AB + +// will result in: +// Error from compilation: TypeError: Cannot read property 'charCodeAt' of undefined TypeError: Cannot read property 'charCodeAt' of undefined diff --git a/tests/cases/compiler/crashInGetTextOfComputedPropertyName.ts b/tests/cases/compiler/crashInGetTextOfComputedPropertyName.ts new file mode 100644 index 00000000000..d7ad08dd812 --- /dev/null +++ b/tests/cases/compiler/crashInGetTextOfComputedPropertyName.ts @@ -0,0 +1,30 @@ +// https://github.com/Microsoft/TypeScript/issues/29006 +export interface A { type: 'a' } +export interface B { type: 'b' } +export type AB = A | B + +const itemId = 'some-id' + +// --- test on first level --- +const items: { [id: string]: AB } = {} +const { [itemId]: itemOk1 } = items +typeof itemOk1 // pass + +// --- test on second level --- +interface ObjWithItems { + items: {[s: string]: AB} +} +const objWithItems: ObjWithItems = { items: {}} + +const itemOk2 = objWithItems.items[itemId] +typeof itemOk2 // pass + +const { + items: { [itemId]: itemWithTSError } = {} /*happens when default value is provided*/ +} = objWithItems + +// in order to re-produce the error, uncomment next line: +typeof itemWithTSError // :( + +// will result in: +// Error from compilation: TypeError: Cannot read property 'charCodeAt' of undefined TypeError: Cannot read property 'charCodeAt' of undefined \ No newline at end of file From b86cb27d0b222f1cadb00e391928923c26244257 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Mon, 14 Jan 2019 18:13:13 -0800 Subject: [PATCH 048/101] Fix trailing whitespace --- src/server/editorServices.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 3e062efc272..bc8197f9354 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -2780,7 +2780,7 @@ namespace ts.server { const project = scriptInfo.getDefaultProject(); if (!project.languageServiceEnabled) { return; - } + } const info: OpenFileInfo = { checkJs: !!project.getSourceFile(scriptInfo.path)!.checkJsDirective }; this.eventHandler({ eventName: OpenFileInfoTelemetryEvent, data: { info } }); From 520e33fa513a8c5ce17d2e9db390f1f9c241d555 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 Jan 2019 15:09:34 -0800 Subject: [PATCH 049/101] PR feedback --- src/compiler/watch.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index b92289635d3..6dbed259547 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -203,17 +203,14 @@ namespace ts { TypeRoots = "Type roots" } - interface WatchFactory extends ts.WatchFactory { - watchLogLevel: WatchLogLevel; + interface WatchFactory extends ts.WatchFactory { writeLog: (s: string) => void; } export function createWatchFactory(host: { trace?(s: string): void; }, options: { extendedDiagnostics?: boolean; diagnostics?: boolean; }) { - const watchLogLevel = host.trace ? options.extendedDiagnostics ? WatchLogLevel.Verbose : - options.diagnostics ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None; + const watchLogLevel = host.trace ? options.extendedDiagnostics ? WatchLogLevel.Verbose : options.diagnostics ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None; const writeLog: (s: string) => void = watchLogLevel !== WatchLogLevel.None ? (s => host.trace!(s)) : noop; const result = getWatchFactory(watchLogLevel, writeLog) as WatchFactory; - result.watchLogLevel = watchLogLevel; result.writeLog = writeLog; return result; } @@ -590,7 +587,7 @@ namespace ts { newLine = updateNewLine(); } - const { watchFile, watchFilePath, watchDirectory, watchLogLevel, writeLog } = createWatchFactory(host, compilerOptions); + const { watchFile, watchFilePath, watchDirectory, writeLog } = createWatchFactory(host, compilerOptions); const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); writeLog(`Current directory: ${currentDirectory} CaseSensitiveFileNames: ${useCaseSensitiveFileNames}`); @@ -685,11 +682,9 @@ namespace ts { function createNewProgram(program: Program, hasInvalidatedResolution: HasInvalidatedResolution) { // Compile the program - if (watchLogLevel !== WatchLogLevel.None) { - writeLog("CreatingProgramWith::"); - writeLog(` roots: ${JSON.stringify(rootFileNames)}`); - writeLog(` options: ${JSON.stringify(compilerOptions)}`); - } + writeLog("CreatingProgramWith::"); + writeLog(` roots: ${JSON.stringify(rootFileNames)}`); + writeLog(` options: ${JSON.stringify(compilerOptions)}`); const needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !program; hasChangedCompilerOptions = false; From 3fb09630a82c3f94e47ec37515cb0733b6cfcdb5 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 15 Jan 2019 10:55:15 -0800 Subject: [PATCH 050/101] Add regression test --- src/testRunner/unittests/tsserver/projects.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/testRunner/unittests/tsserver/projects.ts b/src/testRunner/unittests/tsserver/projects.ts index 00941a1d3c9..3a648c9189e 100644 --- a/src/testRunner/unittests/tsserver/projects.ts +++ b/src/testRunner/unittests/tsserver/projects.ts @@ -103,6 +103,30 @@ namespace ts.projectSystem { assert.isFalse(proj3.languageServiceEnabled); }); + it("should not crash when opening a file in a project with a disabled language service", () => { + const file1 = { + path: "/a/b/f1.js", + content: "let x =1;", + fileSize: 50 * 1024 * 1024 + }; + const file2 = { + path: "/a/b/f2.js", + content: "let x =1;", + fileSize: 100 + }; + + const projName = "proj1"; + + const host = createServerHost([file1, file2]); + const projectService = createProjectService(host, { useSingleInferredProject: true }, { eventHandler: noop }); + + projectService.openExternalProject({ rootFiles: toExternalFiles([file1.path, file2.path]), options: {}, projectFileName: projName }); + const proj1 = projectService.findProject(projName)!; + assert.isFalse(proj1.languageServiceEnabled); + + assert.doesNotThrow(() => projectService.openClientFile(file2.path)); + }); + describe("ignoreConfigFiles", () => { it("external project including config file", () => { const file1 = { From 49689894d747714d6b2b8461b9033020efec9625 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 15 Jan 2019 11:32:36 -0800 Subject: [PATCH 051/101] Elaborate jsx children elementwise (#29264) * Heavy WIP, but has good contextual typing fix * Add arity error, refine messages and spans * Small error message change * Better error messages, text-specific message --- src/compiler/checker.ts | 133 ++++++++++++- src/compiler/diagnosticMessages.json | 12 ++ src/compiler/utilities.ts | 3 +- .../checkJsxChildrenProperty14.errors.txt | 8 +- .../checkJsxChildrenProperty2.errors.txt | 40 +--- .../checkJsxChildrenProperty4.errors.txt | 27 ++- .../checkJsxChildrenProperty5.errors.txt | 22 +-- .../checkJsxChildrenProperty7.errors.txt | 40 +--- ...sxFactoryDeclarationsLocalTypes.errors.txt | 32 ++- ...xChildrenGenericContextualTypes.errors.txt | 30 +-- ...drenIndividualErrorElaborations.errors.txt | 128 ++++++++++++ .../jsxChildrenIndividualErrorElaborations.js | 119 ++++++++++++ ...hildrenIndividualErrorElaborations.symbols | 169 ++++++++++++++++ ...xChildrenIndividualErrorElaborations.types | 183 ++++++++++++++++++ ...jsxChildrenIndividualErrorElaborations.tsx | 78 ++++++++ 15 files changed, 883 insertions(+), 141 deletions(-) create mode 100644 tests/baselines/reference/jsxChildrenIndividualErrorElaborations.errors.txt create mode 100644 tests/baselines/reference/jsxChildrenIndividualErrorElaborations.js create mode 100644 tests/baselines/reference/jsxChildrenIndividualErrorElaborations.symbols create mode 100644 tests/baselines/reference/jsxChildrenIndividualErrorElaborations.types create mode 100644 tests/cases/compiler/jsxChildrenIndividualErrorElaborations.tsx diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f365af51ac6..ab460212d53 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11196,7 +11196,7 @@ namespace ts { case SyntaxKind.ArrayLiteralExpression: return elaborateArrayLiteral(node as ArrayLiteralExpression, source, target, relation); case SyntaxKind.JsxAttributes: - return elaborateJsxAttributes(node as JsxAttributes, source, target, relation); + return elaborateJsxComponents(node as JsxAttributes, source, target, relation); case SyntaxKind.ArrowFunction: return elaborateArrowFunction(node as ArrowFunction, source, target, relation); } @@ -11336,8 +11336,113 @@ namespace ts { } } - function elaborateJsxAttributes(node: JsxAttributes, source: Type, target: Type, relation: Map) { - return elaborateElementwise(generateJsxAttributes(node), source, target, relation); + function *generateJsxChildren(node: JsxElement, getInvalidTextDiagnostic: () => DiagnosticMessage): ElaborationIterator { + if (!length(node.children)) return; + let memberOffset = 0; + for (let i = 0; i < node.children.length; i++) { + const child = node.children[i]; + const nameType = getLiteralType(i - memberOffset); + const elem = getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic); + if (elem) { + yield elem; + } + else { + memberOffset++; + } + } + } + + function getElaborationElementForJsxChild(child: JsxChild, nameType: LiteralType, getInvalidTextDiagnostic: () => DiagnosticMessage) { + switch (child.kind) { + case SyntaxKind.JsxExpression: + // child is of the type of the expression + return { errorNode: child, innerExpression: child.expression, nameType }; + case SyntaxKind.JsxText: + if (child.containsOnlyWhiteSpaces) { + break; // Whitespace only jsx text isn't real jsx text + } + // child is a string + return { errorNode: child, innerExpression: undefined, nameType, errorMessage: getInvalidTextDiagnostic() }; + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxFragment: + // child is of type JSX.Element + return { errorNode: child, innerExpression: child, nameType }; + default: + return Debug.assertNever(child, "Found invalid jsx child"); + } + } + + function elaborateJsxComponents(node: JsxAttributes, source: Type, target: Type, relation: Map) { + let result = elaborateElementwise(generateJsxAttributes(node), source, target, relation); + let invalidTextDiagnostic: DiagnosticMessage | undefined; + if (isJsxOpeningElement(node.parent) && isJsxElement(node.parent.parent)) { + const containingElement = node.parent.parent; + const childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); + const childrenPropName = childPropName === undefined ? "children" : unescapeLeadingUnderscores(childPropName); + const childrenNameType = getLiteralType(childrenPropName); + const childrenTargetType = getIndexedAccessType(target, childrenNameType); + const validChildren = filter(containingElement.children, i => !isJsxText(i) || !i.containsOnlyWhiteSpaces); + if (!length(validChildren)) { + return result; + } + const moreThanOneRealChildren = length(validChildren) > 1; + const arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType); + const nonArrayLikeTargetParts = filterType(childrenTargetType, t => !isArrayOrTupleLikeType(t)); + if (moreThanOneRealChildren) { + if (arrayLikeTargetParts !== neverType) { + const realSource = createTupleType(checkJsxChildren(containingElement, CheckMode.Normal)); + result = elaborateElementwise(generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic), realSource, arrayLikeTargetParts, relation) || result; + } + else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) { + // arity mismatch + result = true; + error( + containingElement.openingElement.tagName, + Diagnostics.This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided, + childrenPropName, + typeToString(childrenTargetType) + ); + } + } + else { + if (nonArrayLikeTargetParts !== neverType) { + const child = validChildren[0]; + const elem = getElaborationElementForJsxChild(child, childrenNameType, getInvalidTextualChildDiagnostic); + if (elem) { + result = elaborateElementwise( + (function*() { yield elem; })(), + source, + target, + relation + ) || result; + } + } + else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) { + // arity mismatch + result = true; + error( + containingElement.openingElement.tagName, + Diagnostics.This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_provided, + childrenPropName, + typeToString(childrenTargetType) + ); + } + } + } + return result; + + function getInvalidTextualChildDiagnostic() { + if (!invalidTextDiagnostic) { + const tagNameText = getTextOfNode(node.parent.tagName); + const childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); + const childrenPropName = childPropName === undefined ? "children" : unescapeLeadingUnderscores(childPropName); + const childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); + const diagnostic = Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; + invalidTextDiagnostic = { ...diagnostic, key: "!!ALREADY FORMATTED!!", message: formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }; + } + return invalidTextDiagnostic; + } } function *generateLimitedTupleElements(node: ArrayLiteralExpression, target: Type): ElaborationIterator { @@ -13477,6 +13582,10 @@ namespace ts { return isTupleType(type) || !!getPropertyOfType(type, "0" as __String); } + function isArrayOrTupleLikeType(type: Type): boolean { + return isArrayLikeType(type) || isTupleLikeType(type); + } + function getTupleElementType(type: Type, index: number) { const propType = getTypeOfPropertyOfType(type, "" + index as __String); if (propType) { @@ -17492,11 +17601,23 @@ namespace ts { return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } - function getContextualTypeForChildJsxExpression(node: JsxElement) { + function getContextualTypeForChildJsxExpression(node: JsxElement, child: JsxChild) { const attributesType = getApparentTypeOfContextualType(node.openingElement.tagName); // JSX expression is in children of JSX Element, we will look for an "children" atttribute (we get the name from JSX.ElementAttributesProperty) const jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); - return attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName) : undefined; + if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) { + return undefined; + } + const childIndex = node.children.indexOf(child); + const childFieldType = getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName); + return childFieldType && mapType(childFieldType, t => { + if (isArrayLikeType(t)) { + return getIndexedAccessType(t, getLiteralType(childIndex)); + } + else { + return t; + } + }, /*noReductions*/ true); } function getContextualTypeForJsxExpression(node: JsxExpression): Type | undefined { @@ -17504,7 +17625,7 @@ namespace ts { return isJsxAttributeLike(exprParent) ? getContextualType(node) : isJsxElement(exprParent) - ? getContextualTypeForChildJsxExpression(exprParent) + ? getContextualTypeForChildJsxExpression(exprParent, node) : undefined; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4e99c001d80..a4bd48e8562 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2541,6 +2541,18 @@ "category": "Error", "code": 2744 }, + "This JSX tag's '{0}' prop expects type '{1}' which requires multiple children, but only a single child was provided.": { + "category": "Error", + "code": 2745 + }, + "This JSX tag's '{0}' prop expects a single child of type '{1}', but multiple children were provided.": { + "category": "Error", + "code": 2746 + }, + "'{0}' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of '{1}' is '{2}'.": { + "category": "Error", + "code": 2747 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9c6b27de13c..33a902b8035 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -888,7 +888,7 @@ namespace ts { } const isMissing = nodeIsMissing(errorNode); - const pos = isMissing + const pos = isMissing || isJsxText(node) ? errorNode.pos : skipTrivia(sourceFile.text, errorNode.pos); @@ -7024,6 +7024,7 @@ namespace ts { }; } + export function formatMessage(_dummy: any, message: DiagnosticMessage, ...args: (string | number | undefined)[]): string; export function formatMessage(_dummy: any, message: DiagnosticMessage): string { let text = getLocaleSpecificMessage(message); diff --git a/tests/baselines/reference/checkJsxChildrenProperty14.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty14.errors.txt index b401345a5e1..0f44d023a76 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty14.errors.txt +++ b/tests/baselines/reference/checkJsxChildrenProperty14.errors.txt @@ -1,6 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(42,11): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'SingleChildProp'. - Types of property 'children' are incompatible. - Type 'Element[]' is missing the following properties from type 'Element': type, props +tests/cases/conformance/jsx/file.tsx(42,11): error TS2746: This JSX tag's 'children' prop expects a single child of type 'Element', but multiple children were provided. ==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== @@ -47,6 +45,4 @@ tests/cases/conformance/jsx/file.tsx(42,11): error TS2322: Type '{ children: Ele // Error let k5 = <>