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 01/88] 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 02/88] 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 03/88] 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 04/88] 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 05/88] 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 06/88] 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 07/88] 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 08/88] 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 09/88] #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 10/88] 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 11/88] 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 12/88] 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 13/88] 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 14/88] 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 15/88] 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 16/88] 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 17/88] 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 18/88] 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 19/88] --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 20/88] 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 21/88] 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 22/88] 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 23/88] 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 24/88] 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 25/88] 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 26/88] 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 27/88] 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 28/88] 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 29/88] 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 30/88] 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 31/88] 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 32/88] 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 33/88] 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 34/88] 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 c909becdd5eba949cf48b4c0f8d89c783384d6a9 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 Jan 2019 12:40:50 -0800 Subject: [PATCH 35/88] 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 36/88] 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 37/88] 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 38/88] 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 208148d05c6d2c2f0cee93a9bcc913dee1286198 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 14 Jan 2019 17:47:52 -0800 Subject: [PATCH 39/88] 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 520e33fa513a8c5ce17d2e9db390f1f9c241d555 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 Jan 2019 15:09:34 -0800 Subject: [PATCH 40/88] 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 9cd5f2dd3c9bd7414f93a2976d877c60cbd1a770 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 15 Jan 2019 17:39:02 -0800 Subject: [PATCH 41/88] Add regression test. (#29433) --- .../documentHighlightsTypeParameterInHeritageClause01.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/cases/fourslash/server/documentHighlightsTypeParameterInHeritageClause01.ts diff --git a/tests/cases/fourslash/server/documentHighlightsTypeParameterInHeritageClause01.ts b/tests/cases/fourslash/server/documentHighlightsTypeParameterInHeritageClause01.ts new file mode 100644 index 00000000000..c96e510c522 --- /dev/null +++ b/tests/cases/fourslash/server/documentHighlightsTypeParameterInHeritageClause01.ts @@ -0,0 +1,6 @@ +/// + +////interface I<[|T|]> extends I<[|T|]>, [|T|] { +////} + +verify.rangesAreDocumentHighlights(); \ No newline at end of file From 41a7bf4b7365bd628b8756811d1334f877413a4a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 15 Jan 2019 22:31:57 -0800 Subject: [PATCH 42/88] Fake up value declaration for synthetic jsx children symbol so they get excess property checked (#29359) --- src/compiler/checker.ts | 4 ++ .../checkJsxChildrenProperty15.errors.txt | 31 ++++++++++ .../reference/checkJsxChildrenProperty15.js | 27 +++++++++ .../checkJsxChildrenProperty15.symbols | 46 +++++++++++++++ .../checkJsxChildrenProperty15.types | 57 +++++++++++++++++++ ...elessFunctionComponentOverload4.errors.txt | 6 +- .../jsx/checkJsxChildrenProperty15.tsx | 18 ++++++ 7 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/checkJsxChildrenProperty15.errors.txt create mode 100644 tests/baselines/reference/checkJsxChildrenProperty15.js create mode 100644 tests/baselines/reference/checkJsxChildrenProperty15.symbols create mode 100644 tests/baselines/reference/checkJsxChildrenProperty15.types create mode 100644 tests/cases/conformance/jsx/checkJsxChildrenProperty15.tsx diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f7cec89fe80..cb132ebf927 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18550,6 +18550,10 @@ namespace ts { childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : (getArrayLiteralTupleTypeIfApplicable(childrenTypes, childrenContextualType, /*hasRestElement*/ false) || createArrayType(getUnionType(childrenTypes))); + // Fake up a property declaration for the children + childrenPropSymbol.valueDeclaration = createPropertySignature(/*modifiers*/ undefined, unescapeLeadingUnderscores(jsxChildrenPropertyName), /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); + childrenPropSymbol.valueDeclaration.parent = attributes; + childrenPropSymbol.valueDeclaration.symbol = childrenPropSymbol; const childPropMap = createSymbolTable(); childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol); spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), diff --git a/tests/baselines/reference/checkJsxChildrenProperty15.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty15.errors.txt new file mode 100644 index 00000000000..605a293ffaa --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty15.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/jsx/file.tsx(10,13): error TS2322: Type '{ children: Element; }' is not assignable to type 'IntrinsicAttributes'. + Property 'children' does not exist on type 'IntrinsicAttributes'. +tests/cases/conformance/jsx/file.tsx(11,13): error TS2322: Type '{ children: Element; key: string; }' is not assignable to type 'IntrinsicAttributes'. + Property 'children' does not exist on type 'IntrinsicAttributes'. +tests/cases/conformance/jsx/file.tsx(12,13): error TS2322: Type '{ children: Element[]; key: string; }' is not assignable to type 'IntrinsicAttributes'. + Property 'children' does not exist on type 'IntrinsicAttributes'. + + +==== tests/cases/conformance/jsx/file.tsx (3 errors) ==== + import React = require('react'); + + const Tag = (x: {}) =>
; + + // OK + const k1 = ; + const k2 = ; + + // Not OK (excess children) + const k3 = } />; + ~~~ +!!! error TS2322: Type '{ children: Element; }' is not assignable to type 'IntrinsicAttributes'. +!!! error TS2322: Property 'children' does not exist on type 'IntrinsicAttributes'. + const k4 =
; + ~~~ +!!! error TS2322: Type '{ children: Element; key: string; }' is not assignable to type 'IntrinsicAttributes'. +!!! error TS2322: Property 'children' does not exist on type 'IntrinsicAttributes'. + const k5 =
; + ~~~ +!!! error TS2322: Type '{ children: Element[]; key: string; }' is not assignable to type 'IntrinsicAttributes'. +!!! error TS2322: Property 'children' does not exist on type 'IntrinsicAttributes'. + \ No newline at end of file diff --git a/tests/baselines/reference/checkJsxChildrenProperty15.js b/tests/baselines/reference/checkJsxChildrenProperty15.js new file mode 100644 index 00000000000..9ceaa97cc39 --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty15.js @@ -0,0 +1,27 @@ +//// [file.tsx] +import React = require('react'); + +const Tag = (x: {}) =>
; + +// OK +const k1 = ; +const k2 = ; + +// Not OK (excess children) +const k3 = } />; +const k4 =
; +const k5 =
; + + +//// [file.jsx] +"use strict"; +exports.__esModule = true; +var React = require("react"); +var Tag = function (x) { return
; }; +// OK +var k1 = ; +var k2 = ; +// Not OK (excess children) +var k3 = }/>; +var k4 =
; +var k5 =
; diff --git a/tests/baselines/reference/checkJsxChildrenProperty15.symbols b/tests/baselines/reference/checkJsxChildrenProperty15.symbols new file mode 100644 index 00000000000..ec8e0ab5b0b --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty15.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/jsx/file.tsx === +import React = require('react'); +>React : Symbol(React, Decl(file.tsx, 0, 0)) + +const Tag = (x: {}) =>
; +>Tag : Symbol(Tag, Decl(file.tsx, 2, 5)) +>x : Symbol(x, Decl(file.tsx, 2, 13)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) + +// OK +const k1 = ; +>k1 : Symbol(k1, Decl(file.tsx, 5, 5)) +>Tag : Symbol(Tag, Decl(file.tsx, 2, 5)) + +const k2 = ; +>k2 : Symbol(k2, Decl(file.tsx, 6, 5)) +>Tag : Symbol(Tag, Decl(file.tsx, 2, 5)) +>Tag : Symbol(Tag, Decl(file.tsx, 2, 5)) + +// Not OK (excess children) +const k3 = } />; +>k3 : Symbol(k3, Decl(file.tsx, 9, 5)) +>Tag : Symbol(Tag, Decl(file.tsx, 2, 5)) +>children : Symbol(children, Decl(file.tsx, 9, 15)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) + +const k4 =
; +>k4 : Symbol(k4, Decl(file.tsx, 10, 5)) +>Tag : Symbol(Tag, Decl(file.tsx, 2, 5)) +>key : Symbol(key, Decl(file.tsx, 10, 15)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>Tag : Symbol(Tag, Decl(file.tsx, 2, 5)) + +const k5 =
; +>k5 : Symbol(k5, Decl(file.tsx, 11, 5)) +>Tag : Symbol(Tag, Decl(file.tsx, 2, 5)) +>key : Symbol(key, Decl(file.tsx, 11, 15)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>Tag : Symbol(Tag, Decl(file.tsx, 2, 5)) + diff --git a/tests/baselines/reference/checkJsxChildrenProperty15.types b/tests/baselines/reference/checkJsxChildrenProperty15.types new file mode 100644 index 00000000000..00b70f990fc --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty15.types @@ -0,0 +1,57 @@ +=== tests/cases/conformance/jsx/file.tsx === +import React = require('react'); +>React : typeof React + +const Tag = (x: {}) =>
; +>Tag : (x: {}) => JSX.Element +>(x: {}) =>
: (x: {}) => JSX.Element +>x : {} +>
: JSX.Element +>div : any +>div : any + +// OK +const k1 = ; +>k1 : JSX.Element +> : JSX.Element +>Tag : (x: {}) => JSX.Element + +const k2 = ; +>k2 : JSX.Element +> : JSX.Element +>Tag : (x: {}) => JSX.Element +>Tag : (x: {}) => JSX.Element + +// Not OK (excess children) +const k3 = } />; +>k3 : JSX.Element +>} /> : JSX.Element +>Tag : (x: {}) => JSX.Element +>children : JSX.Element +>
: JSX.Element +>div : any +>div : any + +const k4 =
; +>k4 : JSX.Element +>
: JSX.Element +>Tag : (x: {}) => JSX.Element +>key : string +>
: JSX.Element +>div : any +>div : any +>Tag : (x: {}) => JSX.Element + +const k5 =
; +>k5 : JSX.Element +>
: JSX.Element +>Tag : (x: {}) => JSX.Element +>key : string +>
: JSX.Element +>div : any +>div : any +>
: JSX.Element +>div : any +>div : any +>Tag : (x: {}) => JSX.Element + diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.errors.txt b/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.errors.txt index 2e88e0a2001..733bb200e99 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.errors.txt +++ b/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.errors.txt @@ -12,9 +12,10 @@ tests/cases/conformance/jsx/file.tsx(26,40): error TS2322: Type 'string' is not tests/cases/conformance/jsx/file.tsx(33,32): error TS2322: Type 'string' is not assignable to type 'boolean'. tests/cases/conformance/jsx/file.tsx(34,29): error TS2322: Type 'string' is not assignable to type 'boolean'. tests/cases/conformance/jsx/file.tsx(35,29): error TS2322: Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/jsx/file.tsx(36,29): error TS2322: Type 'string' is not assignable to type 'boolean'. -==== tests/cases/conformance/jsx/file.tsx (10 errors) ==== +==== tests/cases/conformance/jsx/file.tsx (11 errors) ==== import React = require('react') declare function OneThing(): JSX.Element; declare function OneThing(l: {yy: number, yy1: string}): JSX.Element; @@ -82,4 +83,7 @@ tests/cases/conformance/jsx/file.tsx(35,29): error TS2322: Type 'string' is not !!! error TS2322: Type 'string' is not assignable to type 'boolean'. !!! related TS6500 tests/cases/conformance/jsx/file.tsx:30:38: The expected type comes from property 'y1' which is declared here on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }' const e4 = Hi + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! related TS6500 tests/cases/conformance/jsx/file.tsx:30:38: The expected type comes from property 'y1' which is declared here on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }' \ No newline at end of file diff --git a/tests/cases/conformance/jsx/checkJsxChildrenProperty15.tsx b/tests/cases/conformance/jsx/checkJsxChildrenProperty15.tsx new file mode 100644 index 00000000000..7f91b9516dd --- /dev/null +++ b/tests/cases/conformance/jsx/checkJsxChildrenProperty15.tsx @@ -0,0 +1,18 @@ +// @filename: file.tsx +// @jsx: preserve +// @noLib: true +// @skipLibCheck: true +// @libFiles: react.d.ts,lib.d.ts + +import React = require('react'); + +const Tag = (x: {}) =>
; + +// OK +const k1 = ; +const k2 = ; + +// Not OK (excess children) +const k3 = } />; +const k4 =
; +const k5 =
; From 5fc8f1dd801dbacfe7e2d624f80b7a6a3868d180 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Wed, 16 Jan 2019 10:58:07 -0800 Subject: [PATCH 43/88] Add opt-in user preference for prefix and suffix text on renames (#29314) * Add user preference to control renaming through exports * Only impact renaming * Update baselines * Use flag to control all prefix and suffix text and imports * [WIP] add tests * Only skip export import specifier with flag * [WIP] Update tests * Update test * Pick up preference from host and update test * Shorten flag name * Add missing utility function * Update comment * [WIP] rename flag and respond to cr * [WIP] Add flag for forRelatedSymbol * Use larger search symbol set for old-style rename * Respond to CR * Fix small error * Fix type mismatch * Update comment and remove unnecessary exprot * Respond to CR --- src/compiler/types.ts | 1 + src/harness/fourslash.ts | 5 +- src/harness/harnessLanguageService.ts | 4 +- src/server/protocol.ts | 1 + src/server/session.ts | 8 ++- src/services/findAllReferences.ts | 65 ++++++++++++++----- src/services/services.ts | 5 +- src/services/shims.ts | 8 +-- src/services/types.ts | 2 +- src/testRunner/unittests/tsserver/rename.ts | 34 ++++++++-- .../reference/api/tsserverlibrary.d.ts | 4 +- tests/baselines/reference/api/typescript.d.ts | 3 +- .../findAllRefsPrefixSuffixPreference.ts | 56 ++++++++++++++++ tests/cases/fourslash/fourslash.ts | 3 +- 14 files changed, 163 insertions(+), 36 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsPrefixSuffixPreference.ts diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 125c3297863..c6c34c7434e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5864,6 +5864,7 @@ namespace ts { /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ readonly importModuleSpecifierEnding?: "minimal" | "index" | "js"; readonly allowTextChangesInNewFiles?: boolean; + readonly providePrefixAndSuffixTextForRename?: boolean; } /** Represents a bigint literal value without requiring bigint support */ diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 1276de7de44..2b04b4bd8cd 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1170,7 +1170,7 @@ Actual: ${stringify(fullActual)}`); } public verifyRenameLocations(startRanges: ArrayOrSingle, options: FourSlashInterface.RenameLocationsOptions) { - const { findInStrings = false, findInComments = false, ranges = this.getRanges() } = ts.isArray(options) ? { findInStrings: false, findInComments: false, ranges: options } : options; + const { findInStrings = false, findInComments = false, ranges = this.getRanges(), providePrefixAndSuffixTextForRename = true } = ts.isArray(options) ? { findInStrings: false, findInComments: false, ranges: options, providePrefixAndSuffixTextForRename: true } : options; for (const startRange of toArray(startRanges)) { this.goToRangeStart(startRange); @@ -1182,7 +1182,7 @@ Actual: ${stringify(fullActual)}`); } const references = this.languageService.findRenameLocations( - this.activeFile.fileName, this.currentCaretPosition, findInStrings, findInComments); + this.activeFile.fileName, this.currentCaretPosition, findInStrings, findInComments, providePrefixAndSuffixTextForRename); const sort = (locations: ReadonlyArray | undefined) => locations && ts.sort(locations, (r1, r2) => ts.compareStringsCaseSensitive(r1.fileName, r2.fileName) || r1.textSpan.start - r2.textSpan.start); @@ -5087,6 +5087,7 @@ namespace FourSlashInterface { readonly findInStrings?: boolean; readonly findInComments?: boolean; readonly ranges: ReadonlyArray; + readonly providePrefixAndSuffixTextForRename?: boolean; }; export type RenameLocationOptions = FourSlash.Range | { readonly range: FourSlash.Range, readonly prefixText?: string, readonly suffixText?: string }; } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index d233ddf4585..a78ef88e5b7 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -472,8 +472,8 @@ namespace Harness.LanguageService { 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)); + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ts.RenameLocation[] { + return unwrapJSONCallResult(this.shim.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename)); } getDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[] { return unwrapJSONCallResult(this.shim.getDefinitionAtPosition(fileName, position)); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 8b9df926d82..11930de4d8c 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 providePrefixAndSuffixTextForRename?: boolean; readonly allowRenameOfImportPath?: boolean; } diff --git a/src/server/session.ts b/src/server/session.ts index 8c300b121e1..2257c6740f4 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -314,7 +314,8 @@ namespace ts.server { defaultProject: Project, initialLocation: DocumentPosition, findInStrings: boolean, - findInComments: boolean + findInComments: boolean, + hostPreferences: UserPreferences ): ReadonlyArray { const outputs: RenameLocation[] = []; @@ -323,7 +324,7 @@ namespace ts.server { defaultProject, initialLocation, ({ project, location }, tryAddToTodo) => { - for (const output of project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments) || emptyArray) { + for (const output of project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments, hostPreferences.providePrefixAndSuffixTextForRename) || emptyArray) { if (!contains(outputs, output, documentSpansEqual) && !tryAddToTodo(project, documentSpanLocation(output))) { outputs.push(output); } @@ -1232,7 +1233,8 @@ namespace ts.server { this.getDefaultProject(args), { fileName: args.file, pos: position }, !!args.findInStrings, - !!args.findInComments + !!args.findInComments, + this.getHostPreferences() ); if (!simplifiedResult) return locations; diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index f290826690e..bac1811f429 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -39,6 +39,11 @@ namespace ts.FindAllReferences { readonly isForRename?: boolean; /** True if we are searching for implementations. We will have a different method of adding references if so. */ readonly implementations?: boolean; + /** + * True to opt in for enhanced renaming of shorthand properties and import/export specifiers. + * Default is false for backwards compatibility. + */ + readonly providePrefixAndSuffixTextForRename?: boolean; } export function findReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number): ReferencedSymbol[] | undefined { @@ -157,8 +162,8 @@ namespace ts.FindAllReferences { return { displayParts, kind: symbolKind }; } - export function toRenameLocation(entry: Entry, originalNode: Node, checker: TypeChecker): RenameLocation { - return { ...entryToDocumentSpan(entry), ...getPrefixAndSuffixText(entry, originalNode, checker) }; + export function toRenameLocation(entry: Entry, originalNode: Node, checker: TypeChecker, providePrefixAndSuffixText: boolean): RenameLocation { + return { ...entryToDocumentSpan(entry), ...(providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker)) }; } export function toReferenceEntry(entry: Entry): ReferenceEntry { @@ -484,7 +489,7 @@ namespace ts.FindAllReferences.Core { /** Core find-all-references algorithm for a normal symbol. */ function getReferencedSymbolsForSymbol(originalSymbol: Symbol, node: Node | undefined, sourceFiles: ReadonlyArray, sourceFilesSet: ReadonlyMap, checker: TypeChecker, cancellationToken: CancellationToken, options: Options): SymbolAndEntries[] { - const symbol = node && skipPastExportOrImportSpecifierOrUnion(originalSymbol, node, checker, !!options.isForRename) || originalSymbol; + const symbol = node && skipPastExportOrImportSpecifierOrUnion(originalSymbol, node, checker, /*useLocalSymbolForExportSpecifier*/ !isForRenameWithPrefixAndSuffixText(options)) || originalSymbol; // Compute the meaning from the location and the symbol it references const searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : SemanticMeaning.All; @@ -492,7 +497,7 @@ namespace ts.FindAllReferences.Core { const result: SymbolAndEntries[] = []; const state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : SpecialSearchKind.None, checker, cancellationToken, searchMeaning, options, result); - const exportSpecifier = !options.isForRename ? undefined : find(symbol.declarations, isExportSpecifier); + const exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) ? undefined : find(symbol.declarations, isExportSpecifier); if (exportSpecifier) { // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); @@ -502,7 +507,7 @@ namespace ts.FindAllReferences.Core { searchForImportsOfExport(node, symbol, { exportingModuleSymbol: Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: ExportKind.Default }, state); } else { - const search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, !!options.isForRename, !!options.implementations) : [symbol] }); + const search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, !!options.isForRename, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). @@ -538,9 +543,9 @@ namespace ts.FindAllReferences.Core { } /** Handle a few special cases relating to export/import specifiers. */ - function skipPastExportOrImportSpecifierOrUnion(symbol: Symbol, node: Node, checker: TypeChecker, isForRename: boolean): Symbol | undefined { + function skipPastExportOrImportSpecifierOrUnion(symbol: Symbol, node: Node, checker: TypeChecker, useLocalSymbolForExportSpecifier: boolean): Symbol | undefined { const { parent } = node; - if (isExportSpecifier(parent) && !isForRename) { + if (isExportSpecifier(parent) && useLocalSymbolForExportSpecifier) { return getLocalSymbolForExportSpecifier(node as Identifier, symbol, parent, checker); } // If the symbol is declared as part of a declaration like `{ type: "a" } | { type: "b" }`, use the property on the union type to get more references. @@ -1071,6 +1076,8 @@ namespace ts.FindAllReferences.Core { addReferencesHere: boolean, alwaysGetReferences?: boolean, ): void { + Debug.assert(!alwaysGetReferences || !!state.options.providePrefixAndSuffixTextForRename, "If alwaysGetReferences is true, then prefix/suffix text must be enabled"); + const { parent, propertyName, name } = exportSpecifier; const exportDeclaration = parent.parent; const localSymbol = getLocalSymbolForExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, state.checker); @@ -1102,7 +1109,7 @@ namespace ts.FindAllReferences.Core { } // For `export { foo as bar }`, rename `foo`, but not `bar`. - if (!state.options.isForRename || alwaysGetReferences) { + if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { const exportKind = referenceLocation.originalKeywordKind === SyntaxKind.DefaultKeyword ? ExportKind.Default : ExportKind.Named; const exportSymbol = Debug.assertDefined(exportSpecifier.symbol); const exportInfo = Debug.assertDefined(getExportInfo(exportSymbol, exportKind, state.checker)); @@ -1110,7 +1117,7 @@ namespace ts.FindAllReferences.Core { } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. - if (search.comingFrom !== ImportExport.Export && exportDeclaration.moduleSpecifier && !propertyName && !state.options.isForRename) { + if (search.comingFrom !== ImportExport.Export && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { const imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (imported) searchForImportedSymbol(imported, state); } @@ -1145,7 +1152,7 @@ namespace ts.FindAllReferences.Core { const { symbol } = importOrExport; if (importOrExport.kind === ImportExport.Import) { - if (!state.options.isForRename) { + if (!(isForRenameWithPrefixAndSuffixText(state.options))) { searchForImportedSymbol(symbol, state); } } @@ -1514,16 +1521,16 @@ namespace ts.FindAllReferences.Core { // For certain symbol kinds, we need to include other symbols in the search set. // This is not needed when searching for re-exports. - function populateSearchSymbolSet(symbol: Symbol, location: Node, checker: TypeChecker, isForRename: boolean, implementations: boolean): Symbol[] { + function populateSearchSymbolSet(symbol: Symbol, location: Node, checker: TypeChecker, isForRename: boolean, providePrefixAndSuffixText: boolean, implementations: boolean): Symbol[] { const result: Symbol[] = []; - forEachRelatedSymbol(symbol, location, checker, isForRename, + forEachRelatedSymbol(symbol, location, checker, isForRename, !(isForRename && providePrefixAndSuffixText), (sym, root, base) => { result.push(base || root || sym); }, /*allowBaseTypes*/ () => !implementations); return result; } function forEachRelatedSymbol( - symbol: Symbol, location: Node, checker: TypeChecker, isForRenamePopulateSearchSymbolSet: boolean, + symbol: Symbol, location: Node, checker: TypeChecker, isForRenamePopulateSearchSymbolSet: boolean, onlyIncludeBindingElementAtReferenceLocation: boolean, cbSymbol: (symbol: Symbol, rootSymbol?: Symbol, baseSymbol?: Symbol, kind?: NodeEntryKind) => T | undefined, allowBaseTypes: (rootSymbol: Symbol) => boolean, ): T | undefined { @@ -1577,9 +1584,25 @@ namespace ts.FindAllReferences.Core { } // symbolAtLocation for a binding element is the local symbol. See if the search symbol is the property. - // Don't do this when populating search set for a rename -- just rename the local. + // Don't do this when populating search set for a rename when prefix and suffix text will be provided -- just rename the local. if (!isForRenamePopulateSearchSymbolSet) { - const bindingElementPropertySymbol = isObjectBindingElementWithoutPropertyName(location.parent) ? getPropertySymbolFromBindingElement(checker, location.parent) : undefined; + let bindingElementPropertySymbol: Symbol | undefined; + if (onlyIncludeBindingElementAtReferenceLocation) { + bindingElementPropertySymbol = isObjectBindingElementWithoutPropertyName(location.parent) ? getPropertySymbolFromBindingElement(checker, location.parent) : undefined; + } + else { + bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); + } + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, EntryKind.SearchedPropertyFoundLocal); + } + + Debug.assert(isForRenamePopulateSearchSymbolSet); + // due to the above assert and the arguments at the uses of this function, + // (onlyIncludeBindingElementAtReferenceLocation <=> !providePrefixAndSuffixTextForRename) holds + const includeOriginalSymbolOfBindingElement = onlyIncludeBindingElementAtReferenceLocation; + + if (includeOriginalSymbolOfBindingElement) { + const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, EntryKind.SearchedPropertyFoundLocal); } @@ -1597,6 +1620,13 @@ namespace ts.FindAllReferences.Core { ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, base => cbSymbol(sym, rootSymbol, base, kind)) : undefined)); } + + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol, checker: TypeChecker): Symbol | undefined { + const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); + if (bindingElement && isObjectBindingElementWithoutPropertyName(bindingElement)) { + return getPropertySymbolFromBindingElement(checker, bindingElement); + } + } } interface RelatedSymbol { @@ -1606,6 +1636,7 @@ namespace ts.FindAllReferences.Core { function getRelatedSymbol(search: Search, referenceSymbol: Symbol, referenceLocation: Node, state: State): RelatedSymbol | undefined { const { checker } = state; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, /*isForRenamePopulateSearchSymbolSet*/ false, + /*onlyIncludeBindingElementAtReferenceLocation*/ !state.options.isForRename || !!state.options.providePrefixAndSuffixTextForRename, (sym, rootSymbol, baseSymbol, kind): RelatedSymbol | undefined => search.includes(baseSymbol || rootSymbol || sym) // For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol. ? { symbol: rootSymbol && !(getCheckFlags(sym) & CheckFlags.Synthetic) ? rootSymbol : sym, kind } @@ -1696,4 +1727,8 @@ namespace ts.FindAllReferences.Core { t.symbol && t.symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? t.symbol : undefined); return res.length === 0 ? undefined : res; } + + function isForRenameWithPrefixAndSuffixText(options: Options) { + return options.isForRename && options.providePrefixAndSuffixTextForRename; + } } diff --git a/src/services/services.ts b/src/services/services.ts index 6bf6566da36..6a63497d7e6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1549,7 +1549,7 @@ namespace ts { return DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } - function findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined { + function findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): RenameLocation[] | undefined { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); const node = getTouchingPropertyName(sourceFile, position); @@ -1559,7 +1559,8 @@ namespace ts { ({ fileName: sourceFile.fileName, textSpan: createTextSpanFromNode(node.tagName, sourceFile) })); } else { - return getReferencesWorker(node, position, { findInStrings, findInComments, isForRename: true }, FindAllReferences.toRenameLocation); + return getReferencesWorker(node, position, { findInStrings, findInComments, providePrefixAndSuffixTextForRename, isForRename: true }, + (entry, originalNode, checker) => FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false)); } } diff --git a/src/services/shims.ts b/src/services/shims.ts index 33ea4333e6f..208cf3dbc3c 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -170,7 +170,7 @@ namespace ts { * Returns a JSON-encoded value of the type: * { fileName: string, textSpan: { start: number, length: number } }[] */ - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): string; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): string; /** * Returns a JSON-encoded value of the type: @@ -838,10 +838,10 @@ namespace ts { ); } - public findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): string { + public findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): string { return this.forwardJSONCall( - `findRenameLocations('${fileName}', ${position}, ${findInStrings}, ${findInComments})`, - () => this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments) + `findRenameLocations('${fileName}', ${position}, ${findInStrings}, ${findInComments}, ${providePrefixAndSuffixTextForRename})`, + () => this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename) ); } diff --git a/src/services/types.ts b/src/services/types.ts index b45a816d6e0..3502e3e0671 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -295,7 +295,7 @@ namespace ts { getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ReadonlyArray | undefined; getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; diff --git a/src/testRunner/unittests/tsserver/rename.ts b/src/testRunner/unittests/tsserver/rename.ts index 4e95e79e31f..571db235a6e 100644 --- a/src/testRunner/unittests/tsserver/rename.ts +++ b/src/testRunner/unittests/tsserver/rename.ts @@ -32,13 +32,39 @@ namespace ts.projectSystem { }); }); - it("works with prefixText and suffixText", () => { + it("works with prefixText and suffixText when enabled", () => { const aTs: File = { path: "/a.ts", content: "const x = 0; const o = { x };" }; - const session = createSession(createServerHost([aTs])); + const host = createServerHost([aTs]); + const session = createSession(host); openFilesForSession([aTs], session); - const response = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(aTs, "x")); - assert.deepEqual(response, { + // rename with prefixText and suffixText disabled + const response1 = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(aTs, "x")); + assert.deepEqual(response1, { + info: { + canRename: true, + fileToRename: undefined, + displayName: "x", + fullDisplayName: "x", + kind: ScriptElementKind.constElement, + kindModifiers: ScriptElementKindModifier.none, + triggerSpan: protocolTextSpanFromSubstring(aTs.content, "x"), + }, + locs: [ + { + file: aTs.path, + locs: [ + protocolRenameSpanFromSubstring(aTs.content, "x"), + protocolRenameSpanFromSubstring(aTs.content, "x", { index: 1 }), + ], + }, + ], + }); + + // rename with prefixText and suffixText enabled + session.getProjectService().setHostConfiguration({ preferences: { providePrefixAndSuffixTextForRename: true } }); + const response2 = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(aTs, "x")); + assert.deepEqual(response2, { info: { canRename: true, fileToRename: undefined, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 30effc9e91a..75ddd2765ab 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3013,6 +3013,7 @@ declare namespace ts { /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ readonly importModuleSpecifierEnding?: "minimal" | "index" | "js"; readonly allowTextChangesInNewFiles?: boolean; + readonly providePrefixAndSuffixTextForRename?: boolean; } /** Represents a bigint literal value without requiring bigint support */ interface PseudoBigInt { @@ -4707,7 +4708,7 @@ declare namespace ts { getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ReadonlyArray | undefined; getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; @@ -7926,6 +7927,7 @@ declare namespace ts.server.protocol { readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; readonly lazyConfiguredProjectsFromExternalProject?: boolean; + readonly providePrefixAndSuffixTextForRename?: boolean; readonly allowRenameOfImportPath?: boolean; } interface CompilerOptions { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index cd6d45a1647..3dadfa5965a 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3013,6 +3013,7 @@ declare namespace ts { /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ readonly importModuleSpecifierEnding?: "minimal" | "index" | "js"; readonly allowTextChangesInNewFiles?: boolean; + readonly providePrefixAndSuffixTextForRename?: boolean; } /** Represents a bigint literal value without requiring bigint support */ interface PseudoBigInt { @@ -4707,7 +4708,7 @@ declare namespace ts { getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ReadonlyArray | undefined; getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; diff --git a/tests/cases/fourslash/findAllRefsPrefixSuffixPreference.ts b/tests/cases/fourslash/findAllRefsPrefixSuffixPreference.ts new file mode 100644 index 00000000000..3745eff4e5d --- /dev/null +++ b/tests/cases/fourslash/findAllRefsPrefixSuffixPreference.ts @@ -0,0 +1,56 @@ +/// + +// @Filename: /file1.ts +////declare function log(s: string | number): void; +////const [|{| "isWriteAccess": true, "isDefinition": true |}q|] = 1; +////export { [|{| "isWriteAccess": true, "isDefinition": true |}q|] }; +////const x = { +//// [|{| "isWriteAccess": true, "isDefinition": true |}z|]: 'value' +////} +////const { [|{| "isWriteAccess": true, "isDefinition": true |}z|] } = x; +////log([|z|]); + +// @Filename: /file2.ts +////declare function log(s: string | number): void; +////import { [|{| "isWriteAccess": true, "isDefinition": true |}q|] } from "./file1"; +////log([|q|] + 1); + +verify.noErrors(); + +const [q0, q1, z0, z1, z2, q2, q3] = test.ranges(); +const qFile1Ranges = [q0, q1]; +const qFile2Ranges = [q2, q3]; +const qFile1ReferenceGroup: FourSlashInterface.ReferenceGroup = { + definition: "const q: 1", + ranges: qFile1Ranges +}; +const qFile2ReferenceGroup: FourSlashInterface.ReferenceGroup = { + definition: "(alias) const q: 1\nimport q", + ranges: qFile2Ranges +}; +verify.referenceGroups([q0, q1], [qFile1ReferenceGroup, qFile2ReferenceGroup]); +verify.referenceGroups([q2, q3], [qFile2ReferenceGroup, qFile1ReferenceGroup]); + +verify.renameLocations(q0, { ranges: [q0, { range: q1, suffixText: " as q" }], providePrefixAndSuffixTextForRename: true }); +verify.renameLocations(q1, { ranges: [{ range: q1, prefixText: "q as " }, q2, q3], providePrefixAndSuffixTextForRename: true }); +verify.renameLocations([q2, q3], { ranges: [{ range: q2, prefixText: "q as " }, q3], providePrefixAndSuffixTextForRename: true }); + +verify.renameLocations([q0, q1, q2, q3], { ranges: [q0, q1, q2, q3], providePrefixAndSuffixTextForRename: false }); + +const zReferenceGroup1: FourSlashInterface.ReferenceGroup = { + definition: "(property) z: string", + ranges: [z0] +}; +const zReferenceGroup2: FourSlashInterface.ReferenceGroup = { + definition: "const z: string", + ranges: [z1, z2] +}; + +verify.referenceGroups([z0], [{ ...zReferenceGroup1, ranges: [z0, z1] }]); +verify.referenceGroups([z1], [zReferenceGroup1, zReferenceGroup2]); +verify.referenceGroups([z2], [zReferenceGroup2]); + +verify.renameLocations([z0], { ranges: [z0, { range: z1, suffixText: ": z" }], providePrefixAndSuffixTextForRename: true }); +verify.renameLocations([z1, z2], { ranges: [{ range: z1, prefixText: "z: " }, z2], providePrefixAndSuffixTextForRename: true }); + +verify.renameLocations([z0, z1, z2], { ranges: [z0, z1, z2], providePrefixAndSuffixTextForRename: false }); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index ed71f8893b8..db4f7be009b 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -633,7 +633,8 @@ declare namespace FourSlashInterface { readonly findInStrings?: boolean; readonly findInComments?: boolean; readonly ranges: ReadonlyArray; - } + readonly providePrefixAndSuffixTextForRename?: boolean; + }; type RenameLocationOptions = Range | { readonly range: Range, readonly prefixText?: string, readonly suffixText?: string }; } declare function verifyOperationIsCancelled(f: any): void; From a9c5a0472f83958f4a70f4ce66cc299b4b2c332c Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Wed, 16 Jan 2019 12:05:41 -0800 Subject: [PATCH 44/88] Update user baselines (#29444) --- tests/baselines/reference/user/chrome-devtools-frontend.log | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 268d9e869c4..04d5703e1e1 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -12750,7 +12750,12 @@ node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(339,39): error node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(340,39): error TS2339: Property 'y' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(344,24): error TS2339: Property 'deepElementFromPoint' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(352,24): error TS2694: Namespace 'Common' has no exported member 'Event'. +node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(355,22): error TS2339: Property '_useSoftMenu' does not exist on type 'typeof ContextMenu'. +node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(383,20): error TS2339: Property '_pendingMenu' does not exist on type 'typeof ContextMenu'. +node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(390,26): error TS2339: Property '_pendingMenu' does not exist on type 'typeof ContextMenu'. +node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(392,29): error TS2339: Property '_pendingMenu' does not exist on type 'typeof ContextMenu'. node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(408,17): error TS2339: Property 'consume' does not exist on type 'Event'. +node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(418,45): error TS2339: Property '_useSoftMenu' does not exist on type 'typeof ContextMenu'. node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(420,46): error TS2339: Property 'ownerDocument' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(422,101): error TS2339: Property 'ownerDocument' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(442,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. From 6b32f4edcb3b8e98b6c8fc90e7ee68ec904a2ea8 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 16 Jan 2019 14:56:48 -0800 Subject: [PATCH 45/88] Fix gulp builds not building some targets --- Gulpfile.js | 63 +++++++++++++---------- scripts/build/options.js | 2 +- scripts/build/project.js | 106 ++++++++++++++------------------------- 3 files changed, 76 insertions(+), 95 deletions(-) diff --git a/Gulpfile.js b/Gulpfile.js index df8a832426d..3616e25ee80 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -488,29 +488,28 @@ gulp.task( "Runs 'local'", ["local"]); -gulp.task( - "watch-diagnostics", - /*help*/ false, - [processDiagnosticMessagesJs], - () => gulp.watch([diagnosticMessagesJson], [diagnosticInformationMapTs, builtGeneratedDiagnosticMessagesJson])); - gulp.task( "watch-lib", /*help*/ false, () => gulp.watch(["src/lib/**/*"], ["lib"])); +const watchTscPatterns = [ + "src/tsconfig-base.json", + "src/lib/**/*", + "src/compiler/**/*", + "src/tsc/**/*", +]; gulp.task( "watch-tsc", /*help*/ false, - ["watch-diagnostics", "watch-lib"].concat(useCompilerDeps), - () => project.watch(tscProject, { typescript: useCompiler })); + useCompilerDeps, + () => gulp.watch(watchTscPatterns, ["tsc"])); const watchServicesPatterns = [ "src/compiler/**/*", "src/jsTypings/**/*", "src/services/**/*" ]; - gulp.task( "watch-services", /*help*/ false, @@ -522,39 +521,49 @@ const watchLsslPatterns = [ "src/server/**/*", "src/tsserver/tsconfig.json" ]; - gulp.task( "watch-lssl", /*help*/ false, () => gulp.watch(watchLsslPatterns, ["lssl"])); -gulp.task( - "watch-server", - /*help*/ false, - ["watch-diagnostics", "watch-lib"].concat(useCompilerDeps), - () => project.watch(tsserverProject, { typescript: useCompiler })); - -gulp.task( - "watch-runner", - /*help*/ false, - useCompilerDeps, - () => project.watch(testRunnerProject, { typescript: useCompiler })); - +const watchLocalPatterns = [ + "src/tsconfig-base.json", + "src/lib/**/*", + "src/compiler/**/*", + "src/tsc/**/*", + "src/services/**/*", + "src/jsTyping/**/*", + "src/server/**/*", + "src/tsserver/**/*", + "src/typingsInstallerCore/**/*", + "src/harness/**/*", + "src/testRunner/**/*", +]; gulp.task( "watch-local", "Watches for changes to projects in src/ (but does not execute tests).", - ["watch-lib", "watch-tsc", "watch-services", "watch-server", "watch-runner", "watch-lssl"]); + () => gulp.watch(watchLocalPatterns, "local")); +const watchPatterns = [ + "src/tsconfig-base.json", + "src/lib/**/*", + "src/compiler/**/*", + "src/services/**/*", + "src/jsTyping/**/*", + "src/server/**/*", + "src/tsserver/**/*", + "src/typingsInstallerCore/**/*", + "src/harness/**/*", + "src/testRunner/**/*", +]; gulp.task( "watch", "Watches for changes to the build inputs for built/local/run.js, then runs tests.", - ["build-rules", "watch-runner", "watch-services", "watch-lssl"], + ["build-rules"], () => { const sem = new Semaphore(1); - gulp.watch([runJs, typescriptDts, tsserverlibraryDts], () => { - runTests(); - }); + gulp.watch(watchPatterns, () => { runTests(); }); // NOTE: gulp.watch is far too slow when watching tests/cases/**/* as it first enumerates *every* file const testFilePattern = /(\.ts|[\\/]tsconfig\.json)$/; diff --git a/scripts/build/options.js b/scripts/build/options.js index e9e3bfb7b1b..ba1b669188d 100644 --- a/scripts/build/options.js +++ b/scripts/build/options.js @@ -34,7 +34,7 @@ module.exports = minimist(process.argv.slice(2), { workers: process.env.workerCount || os.cpus().length, failed: false, keepFailed: false, - lkg: false, + lkg: true, dirty: false } }); diff --git a/scripts/build/project.js b/scripts/build/project.js index 6c1ac0f3e04..fb193907bbe 100644 --- a/scripts/build/project.js +++ b/scripts/build/project.js @@ -14,71 +14,14 @@ const ts = require("../../lib/typescript"); const del = require("del"); const needsUpdate = require("./needsUpdate"); const mkdirp = require("./mkdirp"); -const prettyTime = require("pretty-hrtime"); const { reportDiagnostics } = require("./diagnostics"); -const { CountdownEvent, ManualResetEvent } = require("prex"); +const { CountdownEvent, ManualResetEvent, Semaphore } = require("prex"); const workStartedEvent = new ManualResetEvent(); const countdown = new CountdownEvent(0); -class CompilationGulp extends gulp.Gulp { - /** - * @param {boolean} [verbose] - */ - fork(verbose) { - const child = new ForkedGulp(this.tasks); - child.on("task_start", e => { - if (countdown.remainingCount === 0) { - countdown.reset(1); - workStartedEvent.set(); - workStartedEvent.reset(); - } - else { - countdown.add(); - } - if (verbose) { - log('Starting', `'${chalk.cyan(e.task)}' ${chalk.gray(`(${countdown.remainingCount} remaining)`)}...`); - } - }); - child.on("task_stop", e => { - countdown.signal(); - if (verbose) { - log('Finished', `'${chalk.cyan(e.task)}' after ${chalk.magenta(prettyTime(/** @type {*}*/(e).hrDuration))} ${chalk.gray(`(${countdown.remainingCount} remaining)`)}`); - } - }); - child.on("task_err", e => { - countdown.signal(); - if (verbose) { - log(`'${chalk.cyan(e.task)}' ${chalk.red("errored after")} ${chalk.magenta(prettyTime(/** @type {*}*/(e).hrDuration))} ${chalk.gray(`(${countdown.remainingCount} remaining)`)}`); - log(e.err ? e.err.stack : e.message); - } - }); - return child; - } - - // @ts-ignore - start() { - throw new Error("Not supported, use fork."); - } -} - -class ForkedGulp extends gulp.Gulp { - /** - * @param {gulp.Gulp["tasks"]} tasks - */ - constructor(tasks) { - super(); - this.tasks = tasks; - } - - // Do not reset tasks - _resetAllTasks() {} - _resetSpecificTasks() {} - _resetTask() {} -} - // internal `Gulp` instance for compilation artifacts. -const compilationGulp = new CompilationGulp(); +const compilationGulp = new gulp.Gulp(); /** @type {Map} */ const projectGraphCache = new Map(); @@ -86,6 +29,39 @@ const projectGraphCache = new Map(); /** @type {Map} */ const typescriptAliasMap = new Map(); +// TODO: allow concurrent outer builds to be run in parallel +const sem = new Semaphore(1); + +/** + * @param {string|string[]} taskName + * @param {() => any} [cb] + */ +function start(taskName, cb) { + return sem.wait().then(() => new Promise((resolve, reject) => { + compilationGulp.start(taskName, err => { + if (err) { + reject(err); + } + else if (cb) { + try { + resolve(cb()); + } + catch (e) { + reject(err); + } + } + else { + resolve(); + } + }); + })).then(() => { + sem.release() + }, e => { + sem.release(); + throw e; + }); +} + /** * Defines a gulp orchestration for a TypeScript project, returning a callback that can be used to trigger compilation. * @param {string} projectSpec The path to a tsconfig.json file or its containing directory. @@ -98,9 +74,7 @@ function createCompiler(projectSpec, options) { const projectGraph = getOrCreateProjectGraph(resolvedProjectSpec, resolvedOptions.paths); projectGraph.isRoot = true; const taskName = compileTaskName(ensureCompileTask(projectGraph, resolvedOptions), resolvedOptions.typescript); - return () => new Promise((resolve, reject) => compilationGulp - .fork(resolvedOptions.verbose) - .start(taskName, err => err ? reject(err) : resolve())); + return () => start(taskName); } exports.createCompiler = createCompiler; @@ -139,9 +113,7 @@ function createCleaner(projectSpec, options) { const projectGraph = getOrCreateProjectGraph(resolvedProjectSpec, paths); projectGraph.isRoot = true; const taskName = cleanTaskName(ensureCleanTask(projectGraph)); - return () => new Promise((resolve, reject) => compilationGulp - .fork() - .start(taskName, err => err ? reject(err) : resolve())); + return () => start(taskName); } exports.createCleaner = createCleaner; @@ -811,7 +783,7 @@ function possiblyTriggerRecompilation(config, task) { function triggerRecompilation(task, config) { compilationGulp._resetTask(task); if (config.watchers && config.watchers.size) { - compilationGulp.fork().start(task.name, () => { + start(task.name, () => { /** @type {Set} */ const taskNames = new Set(); /** @type {((err?: any) => void)[]} */ @@ -831,7 +803,7 @@ function triggerRecompilation(task, config) { }); } else { - compilationGulp.fork(/*verbose*/ true).start(task.name); + start(task.name); } } From 7102de77d3b62cb7bcf344bc7d5ae3dd4c25d603 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 16 Jan 2019 15:54:08 -0800 Subject: [PATCH 46/88] Consider JSX namespace imports when moving statements between files Each of the old and new files should end up with a JSX namespace import iff it contains JSX. Fixes #27939 --- src/services/refactors/moveToNewFile.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/services/refactors/moveToNewFile.ts b/src/services/refactors/moveToNewFile.ts index 87973226b3c..6d2a4872842 100644 --- a/src/services/refactors/moveToNewFile.ts +++ b/src/services/refactors/moveToNewFile.ts @@ -460,6 +460,12 @@ namespace ts.refactor { const oldImportsNeededByNewFile = new SymbolSet(); const newFileImportsFromOldFile = new SymbolSet(); + const containsJsx = find(toMove, statement => !!(statement.transformFlags & TransformFlags.ContainsJsx)); + const jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx); + if (jsxNamespaceSymbol) { // Might not exist (e.g. in non-compiling code) + oldImportsNeededByNewFile.add(jsxNamespaceSymbol); + } + for (const statement of toMove) { forEachTopLevelDeclaration(statement, decl => { movedSymbols.add(Debug.assertDefined(isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); @@ -485,6 +491,11 @@ namespace ts.refactor { for (const statement of oldFile.statements) { if (contains(toMove, statement)) continue; + // jsxNamespaceSymbol will only be set iff it is in oldImportsNeededByNewFile. + if (jsxNamespaceSymbol && !!(statement.transformFlags & TransformFlags.ContainsJsx)) { + unusedImportsFromOldFile.delete(jsxNamespaceSymbol); + } + forEachReference(statement, checker, symbol => { if (movedSymbols.has(symbol)) oldFileImportsFromNewFile.add(symbol); unusedImportsFromOldFile.delete(symbol); @@ -492,6 +503,18 @@ namespace ts.refactor { } return { movedSymbols, newFileImportsFromOldFile, oldFileImportsFromNewFile, oldImportsNeededByNewFile, unusedImportsFromOldFile }; + + function getJsxNamespaceSymbol(containsJsx: Node | undefined) { + if (containsJsx === undefined) { + return undefined; + } + + const jsxNamespace = checker.getJsxNamespace(containsJsx); + const jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, SymbolFlags.Namespace, /*excludeGlobals*/ true); + return !!jsxNamespaceSymbol && some(jsxNamespaceSymbol.declarations, isInImport) + ? jsxNamespaceSymbol + : undefined; + } } // Below should all be utilities @@ -512,7 +535,7 @@ namespace ts.refactor { } function isVariableDeclarationInImport(decl: VariableDeclaration) { return isSourceFile(decl.parent.parent.parent) && - decl.initializer && isRequireCall(decl.initializer, /*checkArgumentIsStringLiteralLike*/ true); + !!decl.initializer && isRequireCall(decl.initializer, /*checkArgumentIsStringLiteralLike*/ true); } function filterImport(i: SupportedImport, moduleSpecifier: StringLiteralLike, keep: (name: Identifier) => boolean): SupportedImportStatement | undefined { From 3e256e14dcb35665b538722197b0aa3ffddc8d79 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 16 Jan 2019 19:18:25 -0800 Subject: [PATCH 47/88] Add fourslash tests --- src/services/refactors/moveToNewFile.ts | 5 +++++ .../fourslash/moveToNewFile_moveJsxImport1.ts | 21 ++++++++++++++++++ .../fourslash/moveToNewFile_moveJsxImport2.ts | 22 +++++++++++++++++++ .../fourslash/moveToNewFile_moveJsxImport3.ts | 21 ++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 tests/cases/fourslash/moveToNewFile_moveJsxImport1.ts create mode 100644 tests/cases/fourslash/moveToNewFile_moveJsxImport2.ts create mode 100644 tests/cases/fourslash/moveToNewFile_moveJsxImport3.ts diff --git a/src/services/refactors/moveToNewFile.ts b/src/services/refactors/moveToNewFile.ts index 6d2a4872842..ad60a6da5fc 100644 --- a/src/services/refactors/moveToNewFile.ts +++ b/src/services/refactors/moveToNewFile.ts @@ -510,7 +510,12 @@ namespace ts.refactor { } const jsxNamespace = checker.getJsxNamespace(containsJsx); + + // Strictly speaking, this could resolve to a symbol other than the JSX namespace. + // This will produce erroneous output (probably, an incorrectly copied import) but + // is expected to be very rare and easily reversible. const jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, SymbolFlags.Namespace, /*excludeGlobals*/ true); + return !!jsxNamespaceSymbol && some(jsxNamespaceSymbol.declarations, isInImport) ? jsxNamespaceSymbol : undefined; diff --git a/tests/cases/fourslash/moveToNewFile_moveJsxImport1.ts b/tests/cases/fourslash/moveToNewFile_moveJsxImport1.ts new file mode 100644 index 00000000000..c63efb52dac --- /dev/null +++ b/tests/cases/fourslash/moveToNewFile_moveJsxImport1.ts @@ -0,0 +1,21 @@ +/// + +// @jsx: preserve +// @noLib: true +// @libFiles: react.d.ts,lib.d.ts + +// @Filename: file.tsx +//// import React = require('react'); +//// [|
;|] +//// 1; + +verify.moveToNewFile({ + newFileContents: { + "/tests/cases/fourslash/file.tsx": +`1;`, + "/tests/cases/fourslash/newFile.tsx": +`import React = require('react'); +
; +`, + } +}); diff --git a/tests/cases/fourslash/moveToNewFile_moveJsxImport2.ts b/tests/cases/fourslash/moveToNewFile_moveJsxImport2.ts new file mode 100644 index 00000000000..a73fcb2209c --- /dev/null +++ b/tests/cases/fourslash/moveToNewFile_moveJsxImport2.ts @@ -0,0 +1,22 @@ +/// + +// @jsx: preserve +// @noLib: true +// @libFiles: react.d.ts,lib.d.ts + +// @Filename: file.tsx +//// import React = require('react'); +//// [|
;|] +////
; + +verify.moveToNewFile({ + newFileContents: { + "/tests/cases/fourslash/file.tsx": +`import React = require('react'); +
;`, + "/tests/cases/fourslash/newFile.tsx": +`import React = require('react'); +
; +`, + } +}); diff --git a/tests/cases/fourslash/moveToNewFile_moveJsxImport3.ts b/tests/cases/fourslash/moveToNewFile_moveJsxImport3.ts new file mode 100644 index 00000000000..9adfa9fd14a --- /dev/null +++ b/tests/cases/fourslash/moveToNewFile_moveJsxImport3.ts @@ -0,0 +1,21 @@ +/// + +// @jsx: preserve +// @noLib: true +// @libFiles: react.d.ts,lib.d.ts + +// @Filename: file.tsx +//// import React = require('react'); +//// [|1;|] +////
; + +verify.moveToNewFile({ + newFileContents: { + "/tests/cases/fourslash/file.tsx": +`import React = require('react'); +
;`, + "/tests/cases/fourslash/newFile.tsx": +`1; +`, + } +}); From 4029e70c97070a5b8adfe3cc154d3fc35e9dda39 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 16 Jan 2019 19:24:11 -0800 Subject: [PATCH 48/88] Illustrate a case that isn't handled correctly --- .../fourslash/moveToNewFile_moveJsxImport4.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/cases/fourslash/moveToNewFile_moveJsxImport4.ts diff --git a/tests/cases/fourslash/moveToNewFile_moveJsxImport4.ts b/tests/cases/fourslash/moveToNewFile_moveJsxImport4.ts new file mode 100644 index 00000000000..b5179f66a45 --- /dev/null +++ b/tests/cases/fourslash/moveToNewFile_moveJsxImport4.ts @@ -0,0 +1,29 @@ +/// + +// @jsx: preserve +// @noLib: true +// @libFiles: react.d.ts,lib.d.ts,leftpad.d.ts + +// @Filename: file.tsx +//// import React = require('leftpad'); +//// [|function F() { +//// const React = import("react"); +////
; +//// }|] +//// React; + +verify.moveToNewFile({ + newFileContents: { + "/tests/cases/fourslash/file.tsx": +`import React = require('leftpad'); +React;`, + // NB: A perfect implementation would not copy over the import + "/tests/cases/fourslash/F.tsx": +`import React = require('leftpad'); +function F() { + const React = import("react"); +
; +} +`, + } +}); From 9f3b77a8bd2bfd27e380763cce3f80018348ff68 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 17 Jan 2019 09:21:49 -0800 Subject: [PATCH 49/88] PR feedback --- src/compiler/builder.ts | 24 +++++++------ src/compiler/core.ts | 8 ++--- src/compiler/program.ts | 2 +- src/compiler/tsbuild.ts | 8 ++--- src/compiler/types.ts | 1 - src/compiler/watch.ts | 35 ++++++++++--------- .../reference/api/tsserverlibrary.d.ts | 1 - tests/baselines/reference/api/typescript.d.ts | 1 - 8 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 89577cfd68a..e8a2bae0513 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -717,22 +717,26 @@ namespace ts { getState: notImplemented, backupCurrentState: noop, useBackupState: noop, - getProgram: () => Debug.assertDefined(state.program), + getProgram, 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), + getSourceFile: fileName => getProgram().getSourceFile(fileName), + getSourceFiles: () => getProgram().getSourceFiles(), + getOptionsDiagnostics: cancellationToken => getProgram().getOptionsDiagnostics(cancellationToken), + getGlobalDiagnostics: cancellationToken => getProgram().getGlobalDiagnostics(cancellationToken), getConfigFileParsingDiagnostics: () => configFileParsingDiagnostics, - 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), + getSyntacticDiagnostics: (sourceFile, cancellationToken) => getProgram().getSyntacticDiagnostics(sourceFile, cancellationToken), + getDeclarationDiagnostics: (sourceFile, cancellationToken) => getProgram().getDeclarationDiagnostics(sourceFile, cancellationToken), + getSemanticDiagnostics: (sourceFile, cancellationToken) => getProgram().getSemanticDiagnostics(sourceFile, cancellationToken), + emit: (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) => getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers), getAllDependencies: notImplemented, - getCurrentDirectory: () => Debug.assertDefined(state.program).getCurrentDirectory() + getCurrentDirectory: () => getProgram().getCurrentDirectory() }; + + function getProgram() { + return Debug.assertDefined(state.program); + } } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 74ac9e93047..d4f5fe9664a 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1370,10 +1370,6 @@ 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) { @@ -1399,6 +1395,10 @@ namespace ts { } } + export function maybeBind(obj: T, fn: ((this: T, ...args: A) => R) | undefined): ((...args: A) => R) | undefined { + return fn ? fn.bind(obj) : undefined; + } + 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 8b66d82fa81..0eff6998d8d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2187,7 +2187,7 @@ namespace ts { } function createRedirectSourceFile(redirectTarget: SourceFile, unredirected: SourceFile, fileName: string, path: Path, resolvedPath: Path, originalFileName: string): SourceFile { - const redirect = createRedirectObject(redirectTarget); + const redirect = Object.create(redirectTarget); redirect.fileName = fileName; redirect.path = path; redirect.resolvedPath = resolvedPath; diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 4395b302944..61b3c610f5a 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -447,7 +447,7 @@ namespace ts { let nextProjectToBuild = 0; let timerToBuildInvalidatedProject: any; let reportFileChangeDetected = false; - const { watchFile, watchFilePath, watchDirectory } = createWatchFactory(host, options); + const { watchFile, watchFilePath, watchDirectory, writeLog } = createWatchFactory(host, options); // Watches for the solution const allWatchedWildcardDirectories = createFileMap>(toPath); @@ -593,12 +593,12 @@ namespace ts { 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}`); + writeLog(`Project: ${resolved} Detected file add/remove of non supported extension: ${fileOrDirectory}`); return; } if (isOutputFile(fileOrDirectory, parsed)) { - // writeLog(`${fileOrDirectory} is output file`); + writeLog(`${fileOrDirectory} is output file`); return; } @@ -991,7 +991,7 @@ namespace ts { } if (status.type === UpToDateStatusType.UpToDateWithUpstreamTypes) { - // Fake build + // Fake that files have been built by updating output file stamps updateOutputTimestamps(proj); return; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 852437942f1..ceec8d60cf2 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5000,7 +5000,6 @@ namespace ts { getDefaultLibLocation?(): string; writeFile: WriteFileCallback; getCurrentDirectory(): string; - getDirectories(path: string): string[]; getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 6dbed259547..827a3279b3b 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -187,10 +187,10 @@ namespace ts { const onWatchStatusChange = reportWatchStatus || createWatchStatusReporter(system); return { onWatchStatusChange, - watchFile: system.watchFile ? ((path, callback, pollingInterval) => system.watchFile!(path, callback, pollingInterval)) : () => noopFileWatcher, - watchDirectory: system.watchDirectory ? ((path, callback, recursive) => system.watchDirectory!(path, callback, recursive)) : () => noopFileWatcher, - setTimeout: system.setTimeout ? ((callback, ms, ...args: any[]) => system.setTimeout!.call(system, callback, ms, ...args)) : noop, - clearTimeout: system.clearTimeout ? (timeoutId => system.clearTimeout!(timeoutId)) : noop + watchFile: maybeBind(system, system.watchFile) || (() => noopFileWatcher), + watchDirectory: maybeBind(system, system.watchDirectory) || (() => noopFileWatcher), + setTimeout: maybeBind(system, system.setTimeout) || noop, + clearTimeout: maybeBind(system, system.clearTimeout) || noop }; } @@ -217,6 +217,7 @@ namespace ts { export function createCompilerHostFromProgramHost(host: ProgramHost, getCompilerOptions: () => CompilerOptions, directoryStructureHost: DirectoryStructureHost = host): CompilerHost { const useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); + const hostGetNewLine = memoize(() => host.getNewLine()); return { getSourceFile: (fileName, languageVersion, onError) => { let text: string | undefined; @@ -235,22 +236,22 @@ namespace ts { return text !== undefined ? createSourceFile(fileName, text, languageVersion) : undefined; }, - getDefaultLibLocation: host.getDefaultLibLocation && (() => host.getDefaultLibLocation!()), + getDefaultLibLocation: maybeBind(host, host.getDefaultLibLocation), getDefaultLibFileName: options => host.getDefaultLibFileName(options), writeFile, getCurrentDirectory: memoize(() => host.getCurrentDirectory()), useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, getCanonicalFileName: createGetCanonicalFileName(useCaseSensitiveFileNames), - getNewLine: memoize(() => getNewLineCharacter(getCompilerOptions(), () => host.getNewLine())), + getNewLine: () => getNewLineCharacter(getCompilerOptions(), hostGetNewLine), 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), + trace: maybeBind(host, host.trace), + directoryExists: maybeBind(directoryStructureHost, directoryStructureHost.directoryExists), + getDirectories: maybeBind(directoryStructureHost, directoryStructureHost.getDirectories), + realpath: maybeBind(host, host.realpath), + getEnvironmentVariable: maybeBind(host, host.getEnvironmentVariable) || (() => ""), + createHash: maybeBind(host, host.createHash), + readDirectory: maybeBind(host, host.readDirectory), }; function ensureDirectoriesExist(directoryPath: string) { @@ -297,13 +298,13 @@ namespace ts { directoryExists: path => system.directoryExists(path), getDirectories: path => system.getDirectories(path), 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)), + realpath: maybeBind(system, system.realpath), + getEnvironmentVariable: maybeBind(system, system.getEnvironmentVariable), trace: s => system.write(s + system.newLine), 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)), + createHash: maybeBind(system, system.createHash), createProgram }; } @@ -758,7 +759,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.call(compilerHost, fileName, languageVersion, onError); + const sourceFile = getNewSourceFile(fileName, languageVersion, onError); if (hostSourceFile) { if (shouldCreateNewSourceFile) { hostSourceFile.version++; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index aee6b01eaff..4801d83de31 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2689,7 +2689,6 @@ declare namespace ts { getDefaultLibLocation?(): string; writeFile: WriteFileCallback; getCurrentDirectory(): string; - getDirectories(path: string): string[]; getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index ca4177d87cc..2e347d5a53a 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2689,7 +2689,6 @@ declare namespace ts { getDefaultLibLocation?(): string; writeFile: WriteFileCallback; getCurrentDirectory(): string; - getDirectories(path: string): string[]; getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; From dbae2cba478c1acffc45adb517db562d6bc764a4 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 17 Jan 2019 11:54:43 -0800 Subject: [PATCH 50/88] add missing type annotation --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 0eff6998d8d..14042a89e94 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2187,7 +2187,7 @@ namespace ts { } function createRedirectSourceFile(redirectTarget: SourceFile, unredirected: SourceFile, fileName: string, path: Path, resolvedPath: Path, originalFileName: string): SourceFile { - const redirect = Object.create(redirectTarget); + const redirect: SourceFile = Object.create(redirectTarget); redirect.fileName = fileName; redirect.path = path; redirect.resolvedPath = resolvedPath; From 5651789629a652d8bf06a965f94f744b34d10f21 Mon Sep 17 00:00:00 2001 From: Jack Williams Date: Thu, 17 Jan 2019 20:03:46 +0000 Subject: [PATCH 51/88] Fix #29457 Use allTypesAssignableToKind instead of isTypeAssignableToKind to account for union types. --- src/compiler/checker.ts | 2 +- .../reference/inOperatorWithValidOperands.js | 14 +++++ .../inOperatorWithValidOperands.symbols | 58 ++++++++++++++----- .../inOperatorWithValidOperands.types | 22 +++++++ .../inOperator/inOperatorWithValidOperands.ts | 8 +++ 5 files changed, 87 insertions(+), 17 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 20e6310f771..d110dfcf210 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22153,7 +22153,7 @@ namespace ts { if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, TypeFlags.NumberLike | TypeFlags.ESSymbolLike))) { error(left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAssignableToKind(rightType, TypeFlags.NonPrimitive | TypeFlags.InstantiableNonPrimitive)) { + if (!allTypesAssignableToKind(rightType, TypeFlags.NonPrimitive | TypeFlags.InstantiableNonPrimitive)) { error(right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; diff --git a/tests/baselines/reference/inOperatorWithValidOperands.js b/tests/baselines/reference/inOperatorWithValidOperands.js index 561abbe340b..f01380b35dd 100644 --- a/tests/baselines/reference/inOperatorWithValidOperands.js +++ b/tests/baselines/reference/inOperatorWithValidOperands.js @@ -23,6 +23,14 @@ function foo(t: T) { var rb3 = x in t; } +function unionCase(t: T | U) { + var rb4 = x in t; +} + +function unionCase2(t: T | object) { + var rb5 = x in t; +} + interface X { x: number } interface Y { y: number } @@ -53,6 +61,12 @@ var rb2 = x in {}; function foo(t) { var rb3 = x in t; } +function unionCase(t) { + var rb4 = x in t; +} +function unionCase2(t) { + var rb5 = x in t; +} var c1; var c2; var c3; diff --git a/tests/baselines/reference/inOperatorWithValidOperands.symbols b/tests/baselines/reference/inOperatorWithValidOperands.symbols index 75e561989e7..cbe0dbeef4a 100644 --- a/tests/baselines/reference/inOperatorWithValidOperands.symbols +++ b/tests/baselines/reference/inOperatorWithValidOperands.symbols @@ -59,35 +59,61 @@ function foo(t: T) { >t : Symbol(t, Decl(inOperatorWithValidOperands.ts, 20, 16)) } +function unionCase(t: T | U) { +>unionCase : Symbol(unionCase, Decl(inOperatorWithValidOperands.ts, 22, 1)) +>T : Symbol(T, Decl(inOperatorWithValidOperands.ts, 24, 19)) +>U : Symbol(U, Decl(inOperatorWithValidOperands.ts, 24, 21)) +>t : Symbol(t, Decl(inOperatorWithValidOperands.ts, 24, 25)) +>T : Symbol(T, Decl(inOperatorWithValidOperands.ts, 24, 19)) +>U : Symbol(U, Decl(inOperatorWithValidOperands.ts, 24, 21)) + + var rb4 = x in t; +>rb4 : Symbol(rb4, Decl(inOperatorWithValidOperands.ts, 25, 7)) +>x : Symbol(x, Decl(inOperatorWithValidOperands.ts, 0, 3)) +>t : Symbol(t, Decl(inOperatorWithValidOperands.ts, 24, 25)) +} + +function unionCase2(t: T | object) { +>unionCase2 : Symbol(unionCase2, Decl(inOperatorWithValidOperands.ts, 26, 1)) +>T : Symbol(T, Decl(inOperatorWithValidOperands.ts, 28, 20)) +>t : Symbol(t, Decl(inOperatorWithValidOperands.ts, 28, 23)) +>T : Symbol(T, Decl(inOperatorWithValidOperands.ts, 28, 20)) + + var rb5 = x in t; +>rb5 : Symbol(rb5, Decl(inOperatorWithValidOperands.ts, 29, 7)) +>x : Symbol(x, Decl(inOperatorWithValidOperands.ts, 0, 3)) +>t : Symbol(t, Decl(inOperatorWithValidOperands.ts, 28, 23)) +} + interface X { x: number } ->X : Symbol(X, Decl(inOperatorWithValidOperands.ts, 22, 1)) ->x : Symbol(X.x, Decl(inOperatorWithValidOperands.ts, 24, 13)) +>X : Symbol(X, Decl(inOperatorWithValidOperands.ts, 30, 1)) +>x : Symbol(X.x, Decl(inOperatorWithValidOperands.ts, 32, 13)) interface Y { y: number } ->Y : Symbol(Y, Decl(inOperatorWithValidOperands.ts, 24, 25)) ->y : Symbol(Y.y, Decl(inOperatorWithValidOperands.ts, 25, 13)) +>Y : Symbol(Y, Decl(inOperatorWithValidOperands.ts, 32, 25)) +>y : Symbol(Y.y, Decl(inOperatorWithValidOperands.ts, 33, 13)) var c1: X | Y; ->c1 : Symbol(c1, Decl(inOperatorWithValidOperands.ts, 27, 3)) ->X : Symbol(X, Decl(inOperatorWithValidOperands.ts, 22, 1)) ->Y : Symbol(Y, Decl(inOperatorWithValidOperands.ts, 24, 25)) +>c1 : Symbol(c1, Decl(inOperatorWithValidOperands.ts, 35, 3)) +>X : Symbol(X, Decl(inOperatorWithValidOperands.ts, 30, 1)) +>Y : Symbol(Y, Decl(inOperatorWithValidOperands.ts, 32, 25)) var c2: X; ->c2 : Symbol(c2, Decl(inOperatorWithValidOperands.ts, 28, 3)) ->X : Symbol(X, Decl(inOperatorWithValidOperands.ts, 22, 1)) +>c2 : Symbol(c2, Decl(inOperatorWithValidOperands.ts, 36, 3)) +>X : Symbol(X, Decl(inOperatorWithValidOperands.ts, 30, 1)) var c3: Y; ->c3 : Symbol(c3, Decl(inOperatorWithValidOperands.ts, 29, 3)) ->Y : Symbol(Y, Decl(inOperatorWithValidOperands.ts, 24, 25)) +>c3 : Symbol(c3, Decl(inOperatorWithValidOperands.ts, 37, 3)) +>Y : Symbol(Y, Decl(inOperatorWithValidOperands.ts, 32, 25)) var rc1 = x in c1; ->rc1 : Symbol(rc1, Decl(inOperatorWithValidOperands.ts, 31, 3)) +>rc1 : Symbol(rc1, Decl(inOperatorWithValidOperands.ts, 39, 3)) >x : Symbol(x, Decl(inOperatorWithValidOperands.ts, 0, 3)) ->c1 : Symbol(c1, Decl(inOperatorWithValidOperands.ts, 27, 3)) +>c1 : Symbol(c1, Decl(inOperatorWithValidOperands.ts, 35, 3)) var rc2 = x in (c2 || c3); ->rc2 : Symbol(rc2, Decl(inOperatorWithValidOperands.ts, 32, 3)) +>rc2 : Symbol(rc2, Decl(inOperatorWithValidOperands.ts, 40, 3)) >x : Symbol(x, Decl(inOperatorWithValidOperands.ts, 0, 3)) ->c2 : Symbol(c2, Decl(inOperatorWithValidOperands.ts, 28, 3)) ->c3 : Symbol(c3, Decl(inOperatorWithValidOperands.ts, 29, 3)) +>c2 : Symbol(c2, Decl(inOperatorWithValidOperands.ts, 36, 3)) +>c3 : Symbol(c3, Decl(inOperatorWithValidOperands.ts, 37, 3)) diff --git a/tests/baselines/reference/inOperatorWithValidOperands.types b/tests/baselines/reference/inOperatorWithValidOperands.types index 01d6c78b1f6..597454605c4 100644 --- a/tests/baselines/reference/inOperatorWithValidOperands.types +++ b/tests/baselines/reference/inOperatorWithValidOperands.types @@ -68,6 +68,28 @@ function foo(t: T) { >t : T } +function unionCase(t: T | U) { +>unionCase : (t: T | U) => void +>t : T | U + + var rb4 = x in t; +>rb4 : boolean +>x in t : boolean +>x : any +>t : T | U +} + +function unionCase2(t: T | object) { +>unionCase2 : (t: object | T) => void +>t : object | T + + var rb5 = x in t; +>rb5 : boolean +>x in t : boolean +>x : any +>t : object | T +} + interface X { x: number } >x : number diff --git a/tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithValidOperands.ts b/tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithValidOperands.ts index a4cdfd00a6b..738edca2bc3 100644 --- a/tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithValidOperands.ts +++ b/tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithValidOperands.ts @@ -22,6 +22,14 @@ function foo(t: T) { var rb3 = x in t; } +function unionCase(t: T | U) { + var rb4 = x in t; +} + +function unionCase2(t: T | object) { + var rb5 = x in t; +} + interface X { x: number } interface Y { y: number } From 900d6f7c9042a686cebc2c50343bfa50ca66b04f Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 17 Jan 2019 12:29:23 -0800 Subject: [PATCH 52/88] renames --- src/compiler/builder.ts | 12 ++++++------ src/compiler/tsbuild.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index e8a2bae0513..44ae6a299d8 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -516,11 +516,11 @@ namespace ts { const result = createRedirectedBuilderProgram(state, configFileParsingDiagnostics); result.getState = () => state; - result.backupCurrentState = () => { + result.backupState = () => { Debug.assert(backupState === undefined); backupState = cloneBuilderProgramState(state); }; - result.useBackupState = () => { + result.restoreState = () => { state = Debug.assertDefined(backupState); backupState = undefined; }; @@ -715,8 +715,8 @@ namespace ts { export function createRedirectedBuilderProgram(state: { program: Program | undefined; compilerOptions: CompilerOptions; }, configFileParsingDiagnostics: ReadonlyArray): BuilderProgram { return { getState: notImplemented, - backupCurrentState: noop, - useBackupState: noop, + backupState: noop, + restoreState: noop, getProgram, getProgramOrUndefined: () => state.program, releaseProgram: () => state.program = undefined, @@ -766,9 +766,9 @@ namespace ts { /*@internal*/ getState(): BuilderProgramState; /*@internal*/ - backupCurrentState(): void; + backupState(): void; /*@internal*/ - useBackupState(): void; + restoreState(): void; /** * Returns current program */ diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 61b3c610f5a..01c4801b106 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -1129,7 +1129,7 @@ namespace ts { } // 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(); + program.backupState(); let newestDeclarationFileContentChangedTime = minimumDate; let anyDtsChanged = false; let declDiagnostics: Diagnostic[] | undefined; @@ -1138,7 +1138,7 @@ namespace ts { 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(); + program.restoreState(); return buildErrors(declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"); } From b6ae492009a5a97ef2d24efe910be6fd77f788a1 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 17 Jan 2019 15:21:17 -0800 Subject: [PATCH 53/88] Add missing arity check on second inference pass (#29386) --- src/compiler/checker.ts | 6 +++ ...romGeneratorMakesRequiredParams.errors.txt | 15 +++++++ ...fParamsFromGeneratorMakesRequiredParams.js | 39 +++++++++++++++++++ ...msFromGeneratorMakesRequiredParams.symbols | 21 ++++++++++ ...ramsFromGeneratorMakesRequiredParams.types | 19 +++++++++ ...fParamsFromGeneratorMakesRequiredParams.ts | 6 +++ 6 files changed, 106 insertions(+) create mode 100644 tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt create mode 100644 tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.js create mode 100644 tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.symbols create mode 100644 tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.types create mode 100644 tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 282765dcc7b..a4e372a1b84 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20422,6 +20422,12 @@ namespace ts { if (inferenceContext) { const typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration)); + // If the original signature has a generic rest type, instantiation may produce a + // signature with different arity and we need to perform another arity check. + if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) { + candidateForArgumentArityError = checkCandidate; + continue; + } } if (!checkApplicableSignature(node, args, checkCandidate, relation, excludeArgument, /*reportErrors*/ false)) { // Give preference to error candidates that have no rest parameters (as they are more specific) diff --git a/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt new file mode 100644 index 00000000000..393e21edb6c --- /dev/null +++ b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt @@ -0,0 +1,15 @@ +error TS2318: Cannot find global type 'IterableIterator'. +tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts(6,1): error TS2554: Expected 2 arguments, but got 1. + + +!!! error TS2318: Cannot find global type 'IterableIterator'. +==== tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts (1 errors) ==== + declare function call any>( + fn: Fn, + ...args: Parameters + ): any; + + call(function* (a: 'a') { }); // error, 2nd argument required + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2554: Expected 2 arguments, but got 1. +!!! related TS6210 tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts:3:5: An argument for 'args' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.js b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.js new file mode 100644 index 00000000000..f1bcf13697d --- /dev/null +++ b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.js @@ -0,0 +1,39 @@ +//// [spreadOfParamsFromGeneratorMakesRequiredParams.ts] +declare function call any>( + fn: Fn, + ...args: Parameters +): any; + +call(function* (a: 'a') { }); // error, 2nd argument required + +//// [spreadOfParamsFromGeneratorMakesRequiredParams.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +call(function (a) { return __generator(this, function (_a) { + return [2 /*return*/]; +}); }); // error, 2nd argument required diff --git a/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.symbols b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.symbols new file mode 100644 index 00000000000..9b23288cc7e --- /dev/null +++ b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts === +declare function call any>( +>call : Symbol(call, Decl(spreadOfParamsFromGeneratorMakesRequiredParams.ts, 0, 0)) +>Fn : Symbol(Fn, Decl(spreadOfParamsFromGeneratorMakesRequiredParams.ts, 0, 22)) +>args : Symbol(args, Decl(spreadOfParamsFromGeneratorMakesRequiredParams.ts, 0, 34)) + + fn: Fn, +>fn : Symbol(fn, Decl(spreadOfParamsFromGeneratorMakesRequiredParams.ts, 0, 58)) +>Fn : Symbol(Fn, Decl(spreadOfParamsFromGeneratorMakesRequiredParams.ts, 0, 22)) + + ...args: Parameters +>args : Symbol(args, Decl(spreadOfParamsFromGeneratorMakesRequiredParams.ts, 1, 11)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>Fn : Symbol(Fn, Decl(spreadOfParamsFromGeneratorMakesRequiredParams.ts, 0, 22)) + +): any; + +call(function* (a: 'a') { }); // error, 2nd argument required +>call : Symbol(call, Decl(spreadOfParamsFromGeneratorMakesRequiredParams.ts, 0, 0)) +>a : Symbol(a, Decl(spreadOfParamsFromGeneratorMakesRequiredParams.ts, 5, 16)) + diff --git a/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.types b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.types new file mode 100644 index 00000000000..18c3d0b0e75 --- /dev/null +++ b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts === +declare function call any>( +>call : any>(fn: Fn, ...args: Parameters) => any +>args : any[] + + fn: Fn, +>fn : Fn + + ...args: Parameters +>args : Parameters + +): any; + +call(function* (a: 'a') { }); // error, 2nd argument required +>call(function* (a: 'a') { }) : any +>call : any>(fn: Fn, ...args: Parameters) => any +>function* (a: 'a') { } : (a: "a") => {} +>a : "a" + diff --git a/tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts b/tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts new file mode 100644 index 00000000000..3008be5210d --- /dev/null +++ b/tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts @@ -0,0 +1,6 @@ +declare function call any>( + fn: Fn, + ...args: Parameters +): any; + +call(function* (a: 'a') { }); // error, 2nd argument required \ No newline at end of file From addeff325b2c5ed024f96ff1a50e843ede5cbe44 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 17 Jan 2019 15:42:58 -0800 Subject: [PATCH 54/88] Make the relationship between partial mapped types and the empty object not apply for subtype relationship (#29384) --- src/compiler/checker.ts | 2 +- .../partialTypeNarrowedToByTypeGuard.js | 42 +++++++++++++++ .../partialTypeNarrowedToByTypeGuard.symbols | 52 +++++++++++++++++++ .../partialTypeNarrowedToByTypeGuard.types | 49 +++++++++++++++++ .../partialTypeNarrowedToByTypeGuard.ts | 26 ++++++++++ 5 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/partialTypeNarrowedToByTypeGuard.js create mode 100644 tests/baselines/reference/partialTypeNarrowedToByTypeGuard.symbols create mode 100644 tests/baselines/reference/partialTypeNarrowedToByTypeGuard.types create mode 100644 tests/cases/compiler/partialTypeNarrowedToByTypeGuard.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a4e372a1b84..7c5884a324c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12677,7 +12677,7 @@ namespace ts { } else { // An empty object type is related to any mapped type that includes a '?' modifier. - if (isPartialMappedType(target) && isEmptyObjectType(source)) { + if (relation !== subtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) { return Ternary.True; } if (isGenericMappedType(target)) { diff --git a/tests/baselines/reference/partialTypeNarrowedToByTypeGuard.js b/tests/baselines/reference/partialTypeNarrowedToByTypeGuard.js new file mode 100644 index 00000000000..82696f59a90 --- /dev/null +++ b/tests/baselines/reference/partialTypeNarrowedToByTypeGuard.js @@ -0,0 +1,42 @@ +//// [partialTypeNarrowedToByTypeGuard.ts] +type Obj = {} | undefined; + +type User = { + email: string; + name: string; +}; + +type PartialUser = Partial; + +// type PartialUser = { +// email?: string; +// name?: string; +// }; + +function isUser(obj: Obj): obj is PartialUser { + return true; +} + +function getUserName(obj: Obj) { + if (isUser(obj)) { + return obj.name; + } + + return ''; +} + +//// [partialTypeNarrowedToByTypeGuard.js] +"use strict"; +// type PartialUser = { +// email?: string; +// name?: string; +// }; +function isUser(obj) { + return true; +} +function getUserName(obj) { + if (isUser(obj)) { + return obj.name; + } + return ''; +} diff --git a/tests/baselines/reference/partialTypeNarrowedToByTypeGuard.symbols b/tests/baselines/reference/partialTypeNarrowedToByTypeGuard.symbols new file mode 100644 index 00000000000..b810e1c4501 --- /dev/null +++ b/tests/baselines/reference/partialTypeNarrowedToByTypeGuard.symbols @@ -0,0 +1,52 @@ +=== tests/cases/compiler/partialTypeNarrowedToByTypeGuard.ts === +type Obj = {} | undefined; +>Obj : Symbol(Obj, Decl(partialTypeNarrowedToByTypeGuard.ts, 0, 0)) + +type User = { +>User : Symbol(User, Decl(partialTypeNarrowedToByTypeGuard.ts, 0, 26)) + + email: string; +>email : Symbol(email, Decl(partialTypeNarrowedToByTypeGuard.ts, 2, 13)) + + name: string; +>name : Symbol(name, Decl(partialTypeNarrowedToByTypeGuard.ts, 3, 18)) + +}; + +type PartialUser = Partial; +>PartialUser : Symbol(PartialUser, Decl(partialTypeNarrowedToByTypeGuard.ts, 5, 2)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>User : Symbol(User, Decl(partialTypeNarrowedToByTypeGuard.ts, 0, 26)) + +// type PartialUser = { +// email?: string; +// name?: string; +// }; + +function isUser(obj: Obj): obj is PartialUser { +>isUser : Symbol(isUser, Decl(partialTypeNarrowedToByTypeGuard.ts, 7, 33)) +>obj : Symbol(obj, Decl(partialTypeNarrowedToByTypeGuard.ts, 14, 16)) +>Obj : Symbol(Obj, Decl(partialTypeNarrowedToByTypeGuard.ts, 0, 0)) +>obj : Symbol(obj, Decl(partialTypeNarrowedToByTypeGuard.ts, 14, 16)) +>PartialUser : Symbol(PartialUser, Decl(partialTypeNarrowedToByTypeGuard.ts, 5, 2)) + + return true; +} + +function getUserName(obj: Obj) { +>getUserName : Symbol(getUserName, Decl(partialTypeNarrowedToByTypeGuard.ts, 16, 1)) +>obj : Symbol(obj, Decl(partialTypeNarrowedToByTypeGuard.ts, 18, 21)) +>Obj : Symbol(Obj, Decl(partialTypeNarrowedToByTypeGuard.ts, 0, 0)) + + if (isUser(obj)) { +>isUser : Symbol(isUser, Decl(partialTypeNarrowedToByTypeGuard.ts, 7, 33)) +>obj : Symbol(obj, Decl(partialTypeNarrowedToByTypeGuard.ts, 18, 21)) + + return obj.name; +>obj.name : Symbol(name, Decl(partialTypeNarrowedToByTypeGuard.ts, 3, 18)) +>obj : Symbol(obj, Decl(partialTypeNarrowedToByTypeGuard.ts, 18, 21)) +>name : Symbol(name, Decl(partialTypeNarrowedToByTypeGuard.ts, 3, 18)) + } + + return ''; +} diff --git a/tests/baselines/reference/partialTypeNarrowedToByTypeGuard.types b/tests/baselines/reference/partialTypeNarrowedToByTypeGuard.types new file mode 100644 index 00000000000..bbf8f96904b --- /dev/null +++ b/tests/baselines/reference/partialTypeNarrowedToByTypeGuard.types @@ -0,0 +1,49 @@ +=== tests/cases/compiler/partialTypeNarrowedToByTypeGuard.ts === +type Obj = {} | undefined; +>Obj : Obj + +type User = { +>User : User + + email: string; +>email : string + + name: string; +>name : string + +}; + +type PartialUser = Partial; +>PartialUser : Partial + +// type PartialUser = { +// email?: string; +// name?: string; +// }; + +function isUser(obj: Obj): obj is PartialUser { +>isUser : (obj: Obj) => obj is Partial +>obj : Obj + + return true; +>true : true +} + +function getUserName(obj: Obj) { +>getUserName : (obj: Obj) => string | undefined +>obj : Obj + + if (isUser(obj)) { +>isUser(obj) : boolean +>isUser : (obj: Obj) => obj is Partial +>obj : Obj + + return obj.name; +>obj.name : string | undefined +>obj : Partial +>name : string | undefined + } + + return ''; +>'' : "" +} diff --git a/tests/cases/compiler/partialTypeNarrowedToByTypeGuard.ts b/tests/cases/compiler/partialTypeNarrowedToByTypeGuard.ts new file mode 100644 index 00000000000..9d43723bab9 --- /dev/null +++ b/tests/cases/compiler/partialTypeNarrowedToByTypeGuard.ts @@ -0,0 +1,26 @@ +// @strict: true +type Obj = {} | undefined; + +type User = { + email: string; + name: string; +}; + +type PartialUser = Partial; + +// type PartialUser = { +// email?: string; +// name?: string; +// }; + +function isUser(obj: Obj): obj is PartialUser { + return true; +} + +function getUserName(obj: Obj) { + if (isUser(obj)) { + return obj.name; + } + + return ''; +} \ No newline at end of file From 737fda928c8ec41efda4496d2adbc104a75bdd7d Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 17 Jan 2019 14:45:40 -0800 Subject: [PATCH 55/88] Don't treat interfaces as implementations ...even if they're in ambient contexts. Same for type aliases. --- src/services/findAllReferences.ts | 3 ++- .../fourslash/goToImplementationInterface_09.ts | 12 ++++++++++++ .../fourslash/goToImplementationTypeAlias_00.ts | 12 ++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/goToImplementationInterface_09.ts create mode 100644 tests/cases/fourslash/goToImplementationTypeAlias_00.ts diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index bac1811f429..54202322260 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1682,7 +1682,8 @@ namespace ts.FindAllReferences.Core { function isImplementation(node: Node): boolean { return !!(node.flags & NodeFlags.Ambient) - || (isVariableLike(node) ? hasInitializer(node) + ? !(isInterfaceDeclaration(node) || isTypeAliasDeclaration(node)) + : (isVariableLike(node) ? hasInitializer(node) : isFunctionLikeDeclaration(node) ? !!node.body : isClassLike(node) || isModuleOrEnumDeclaration(node)); } diff --git a/tests/cases/fourslash/goToImplementationInterface_09.ts b/tests/cases/fourslash/goToImplementationInterface_09.ts new file mode 100644 index 00000000000..5706dea5bb6 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_09.ts @@ -0,0 +1,12 @@ +/// + +// Should go to object literals within cast expressions when invoked on interface + +// @Filename: def.d.ts +//// export interface Interface { P: number } + +// @Filename: ref.ts +//// import { Interface } from "./def"; +//// const c: I/*ref*/nterface = [|{ P: 2 }|]; + +verify.allRangesAppearInImplementationList("ref"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationTypeAlias_00.ts b/tests/cases/fourslash/goToImplementationTypeAlias_00.ts new file mode 100644 index 00000000000..6eb997c2a8a --- /dev/null +++ b/tests/cases/fourslash/goToImplementationTypeAlias_00.ts @@ -0,0 +1,12 @@ +/// + +// Should go to object literals within cast expressions when invoked on interface + +// @Filename: def.d.ts +//// export type TypeAlias = { P: number } + +// @Filename: ref.ts +//// import { TypeAlias } from "./def"; +//// const c: T/*ref*/ypeAlias = [|{ P: 2 }|]; + +verify.allRangesAppearInImplementationList("ref"); \ No newline at end of file From 20285e66e9dc426d3c1c250fa78d70971dc1d397 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 18 Jan 2019 14:43:31 -0800 Subject: [PATCH 56/88] Include all flow nodes made within `try` blocks as antecedents for `catch` or `finally` blocks (#29466) * Include all flow nodes made within `try` blocks as antecedents for `catch` or `finally` blocks * Fix typo --- src/compiler/binder.ts | 45 +++++- .../controlFlowForCatchAndFinally.js | 142 ++++++++++++++++++ .../controlFlowForCatchAndFinally.symbols | 135 +++++++++++++++++ .../controlFlowForCatchAndFinally.types | 142 ++++++++++++++++++ .../compiler/controlFlowForCatchAndFinally.ts | 42 ++++++ 5 files changed, 500 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/controlFlowForCatchAndFinally.js create mode 100644 tests/baselines/reference/controlFlowForCatchAndFinally.symbols create mode 100644 tests/baselines/reference/controlFlowForCatchAndFinally.types create mode 100644 tests/cases/compiler/controlFlowForCatchAndFinally.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index f0e17261810..27f85896a3b 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -100,6 +100,8 @@ namespace ts { IsObjectLiteralOrClassExpressionMethod = 1 << 7, } + let flowNodeCreated: (node: T) => T = identity; + const binder = createBinder(); export function bindSourceFile(file: SourceFile, options: CompilerOptions) { @@ -530,6 +532,7 @@ namespace ts { blockScopeContainer.locals = undefined; } if (containerFlags & ContainerFlags.IsControlFlowContainer) { + const saveFlowNodeCreated = flowNodeCreated; const saveCurrentFlow = currentFlow; const saveBreakTarget = currentBreakTarget; const saveContinueTarget = currentContinueTarget; @@ -553,6 +556,7 @@ namespace ts { currentContinueTarget = undefined; activeLabels = undefined; hasExplicitReturn = false; + flowNodeCreated = identity; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) node.flags &= ~NodeFlags.ReachabilityAndEmitFlags; @@ -579,6 +583,7 @@ namespace ts { currentReturnTarget = saveReturnTarget; activeLabels = saveActiveLabels; hasExplicitReturn = saveHasExplicitReturn; + flowNodeCreated = saveFlowNodeCreated; } else if (containerFlags & ContainerFlags.IsInterface) { seenThisKeyword = false; @@ -858,7 +863,7 @@ namespace ts { return antecedent; } setFlowNodeReferenced(antecedent); - return { flags, expression, antecedent }; + return flowNodeCreated({ flags, expression, antecedent }); } function createFlowSwitchClause(antecedent: FlowNode, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number): FlowNode { @@ -866,17 +871,17 @@ namespace ts { return antecedent; } setFlowNodeReferenced(antecedent); - return { flags: FlowFlags.SwitchClause, switchStatement, clauseStart, clauseEnd, antecedent }; + return flowNodeCreated({ flags: FlowFlags.SwitchClause, switchStatement, clauseStart, clauseEnd, antecedent }); } function createFlowAssignment(antecedent: FlowNode, node: Expression | VariableDeclaration | BindingElement): FlowNode { setFlowNodeReferenced(antecedent); - return { flags: FlowFlags.Assignment, antecedent, node }; + return flowNodeCreated({ flags: FlowFlags.Assignment, antecedent, node }); } function createFlowArrayMutation(antecedent: FlowNode, node: CallExpression | BinaryExpression): FlowNode { setFlowNodeReferenced(antecedent); - const res: FlowArrayMutation = { flags: FlowFlags.ArrayMutation, antecedent, node }; + const res: FlowArrayMutation = flowNodeCreated({ flags: FlowFlags.ArrayMutation, antecedent, node }); return res; } @@ -1080,8 +1085,16 @@ namespace ts { function bindTryStatement(node: TryStatement): void { const preFinallyLabel = createBranchLabel(); const preTryFlow = currentFlow; - // TODO: Every statement in try block is potentially an exit point! + const tryPriors: FlowNode[] = []; + const oldFlowNodeCreated = flowNodeCreated; + // We hook the creation of all flow nodes within the `try` scope and store them so we can add _all_ of them + // as possible antecedents of the start of the `catch` or `finally` blocks. + // Don't bother intercepting the call if there's no finally or catch block that needs the information + if (node.catchClause || node.finallyBlock) { + flowNodeCreated = node => (tryPriors.push(node), node); + } bind(node.tryBlock); + flowNodeCreated = oldFlowNodeCreated; addAntecedent(preFinallyLabel, currentFlow); const flowAfterTry = currentFlow; @@ -1089,12 +1102,32 @@ namespace ts { if (node.catchClause) { currentFlow = preTryFlow; + if (tryPriors.length) { + const preCatchFlow = createBranchLabel(); + addAntecedent(preCatchFlow, currentFlow); + for (const p of tryPriors) { + addAntecedent(preCatchFlow, p); + } + currentFlow = finishFlowLabel(preCatchFlow); + } + bind(node.catchClause); addAntecedent(preFinallyLabel, currentFlow); flowAfterCatch = currentFlow; } if (node.finallyBlock) { + // We add the nodes within the `try` block to the `finally`'s antecedents if there's no catch block + // (If there is a `catch` block, it will have all these antecedents instead, and the `finally` will + // have the end of the `try` block and the end of the `catch` block) + if (!node.catchClause) { + if (tryPriors.length) { + for (const p of tryPriors) { + addAntecedent(preFinallyLabel, p); + } + } + } + // in finally flow is combined from pre-try/flow from try/flow from catch // pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable @@ -1142,7 +1175,7 @@ namespace ts { } } if (!(currentFlow.flags & FlowFlags.Unreachable)) { - const afterFinallyFlow: AfterFinallyFlow = { flags: FlowFlags.AfterFinally, antecedent: currentFlow }; + const afterFinallyFlow: AfterFinallyFlow = flowNodeCreated({ flags: FlowFlags.AfterFinally, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } diff --git a/tests/baselines/reference/controlFlowForCatchAndFinally.js b/tests/baselines/reference/controlFlowForCatchAndFinally.js new file mode 100644 index 00000000000..b3dfc4e7bb8 --- /dev/null +++ b/tests/baselines/reference/controlFlowForCatchAndFinally.js @@ -0,0 +1,142 @@ +//// [controlFlowForCatchAndFinally.ts] +type Page = {close(): Promise; content(): Promise}; +type Browser = {close(): Promise}; +declare function test1(): Promise; +declare function test2(obj: Browser): Promise; +async function test(): Promise { + let browser: Browser | undefined = undefined; + let page: Page | undefined = undefined; + try { + browser = await test1(); + page = await test2(browser); + return await page.content();; + } finally { + if (page) { + await page.close(); // ok + } + + if (browser) { + await browser.close(); // ok + } + } +} + +declare class Aborter { abort(): void }; +class Foo { + abortController: Aborter | undefined = undefined; + + async operation() { + if (this.abortController !== undefined) { + this.abortController.abort(); + this.abortController = undefined; + } + try { + this.abortController = new Aborter(); + } catch (error) { + if (this.abortController !== undefined) { + this.abortController.abort(); // ok + } + } + } +} + +//// [controlFlowForCatchAndFinally.js] +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +function test() { + return __awaiter(this, void 0, void 0, function () { + var browser, page; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + browser = undefined; + page = undefined; + _a.label = 1; + case 1: + _a.trys.push([1, , 5, 10]); + return [4 /*yield*/, test1()]; + case 2: + browser = _a.sent(); + return [4 /*yield*/, test2(browser)]; + case 3: + page = _a.sent(); + return [4 /*yield*/, page.content()]; + case 4: return [2 /*return*/, _a.sent()]; + case 5: + if (!page) return [3 /*break*/, 7]; + return [4 /*yield*/, page.close()]; + case 6: + _a.sent(); // ok + _a.label = 7; + case 7: + if (!browser) return [3 /*break*/, 9]; + return [4 /*yield*/, browser.close()]; + case 8: + _a.sent(); // ok + _a.label = 9; + case 9: return [7 /*endfinally*/]; + case 10: return [2 /*return*/]; + } + }); + }); +} +; +var Foo = /** @class */ (function () { + function Foo() { + this.abortController = undefined; + } + Foo.prototype.operation = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + if (this.abortController !== undefined) { + this.abortController.abort(); + this.abortController = undefined; + } + try { + this.abortController = new Aborter(); + } + catch (error) { + if (this.abortController !== undefined) { + this.abortController.abort(); // ok + } + } + return [2 /*return*/]; + }); + }); + }; + return Foo; +}()); diff --git a/tests/baselines/reference/controlFlowForCatchAndFinally.symbols b/tests/baselines/reference/controlFlowForCatchAndFinally.symbols new file mode 100644 index 00000000000..f6a6574f368 --- /dev/null +++ b/tests/baselines/reference/controlFlowForCatchAndFinally.symbols @@ -0,0 +1,135 @@ +=== tests/cases/compiler/controlFlowForCatchAndFinally.ts === +type Page = {close(): Promise; content(): Promise}; +>Page : Symbol(Page, Decl(controlFlowForCatchAndFinally.ts, 0, 0)) +>close : Symbol(close, Decl(controlFlowForCatchAndFinally.ts, 0, 13)) +>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, --, --)) +>content : Symbol(content, Decl(controlFlowForCatchAndFinally.ts, 0, 36)) +>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, --, --)) + +type Browser = {close(): Promise}; +>Browser : Symbol(Browser, Decl(controlFlowForCatchAndFinally.ts, 0, 65)) +>close : Symbol(close, Decl(controlFlowForCatchAndFinally.ts, 1, 16)) +>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, --, --)) + +declare function test1(): Promise; +>test1 : Symbol(test1, Decl(controlFlowForCatchAndFinally.ts, 1, 40)) +>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, --, --)) +>Browser : Symbol(Browser, Decl(controlFlowForCatchAndFinally.ts, 0, 65)) + +declare function test2(obj: Browser): Promise; +>test2 : Symbol(test2, Decl(controlFlowForCatchAndFinally.ts, 2, 43)) +>obj : Symbol(obj, Decl(controlFlowForCatchAndFinally.ts, 3, 23)) +>Browser : Symbol(Browser, Decl(controlFlowForCatchAndFinally.ts, 0, 65)) +>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, --, --)) +>Page : Symbol(Page, Decl(controlFlowForCatchAndFinally.ts, 0, 0)) + +async function test(): Promise { +>test : Symbol(test, Decl(controlFlowForCatchAndFinally.ts, 3, 52)) +>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, --, --)) + + let browser: Browser | undefined = undefined; +>browser : Symbol(browser, Decl(controlFlowForCatchAndFinally.ts, 5, 7)) +>Browser : Symbol(Browser, Decl(controlFlowForCatchAndFinally.ts, 0, 65)) +>undefined : Symbol(undefined) + + let page: Page | undefined = undefined; +>page : Symbol(page, Decl(controlFlowForCatchAndFinally.ts, 6, 7)) +>Page : Symbol(Page, Decl(controlFlowForCatchAndFinally.ts, 0, 0)) +>undefined : Symbol(undefined) + + try { + browser = await test1(); +>browser : Symbol(browser, Decl(controlFlowForCatchAndFinally.ts, 5, 7)) +>test1 : Symbol(test1, Decl(controlFlowForCatchAndFinally.ts, 1, 40)) + + page = await test2(browser); +>page : Symbol(page, Decl(controlFlowForCatchAndFinally.ts, 6, 7)) +>test2 : Symbol(test2, Decl(controlFlowForCatchAndFinally.ts, 2, 43)) +>browser : Symbol(browser, Decl(controlFlowForCatchAndFinally.ts, 5, 7)) + + return await page.content();; +>page.content : Symbol(content, Decl(controlFlowForCatchAndFinally.ts, 0, 36)) +>page : Symbol(page, Decl(controlFlowForCatchAndFinally.ts, 6, 7)) +>content : Symbol(content, Decl(controlFlowForCatchAndFinally.ts, 0, 36)) + + } finally { + if (page) { +>page : Symbol(page, Decl(controlFlowForCatchAndFinally.ts, 6, 7)) + + await page.close(); // ok +>page.close : Symbol(close, Decl(controlFlowForCatchAndFinally.ts, 0, 13)) +>page : Symbol(page, Decl(controlFlowForCatchAndFinally.ts, 6, 7)) +>close : Symbol(close, Decl(controlFlowForCatchAndFinally.ts, 0, 13)) + } + + if (browser) { +>browser : Symbol(browser, Decl(controlFlowForCatchAndFinally.ts, 5, 7)) + + await browser.close(); // ok +>browser.close : Symbol(close, Decl(controlFlowForCatchAndFinally.ts, 1, 16)) +>browser : Symbol(browser, Decl(controlFlowForCatchAndFinally.ts, 5, 7)) +>close : Symbol(close, Decl(controlFlowForCatchAndFinally.ts, 1, 16)) + } + } +} + +declare class Aborter { abort(): void }; +>Aborter : Symbol(Aborter, Decl(controlFlowForCatchAndFinally.ts, 20, 1)) +>abort : Symbol(Aborter.abort, Decl(controlFlowForCatchAndFinally.ts, 22, 23)) + +class Foo { +>Foo : Symbol(Foo, Decl(controlFlowForCatchAndFinally.ts, 22, 40)) + + abortController: Aborter | undefined = undefined; +>abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>Aborter : Symbol(Aborter, Decl(controlFlowForCatchAndFinally.ts, 20, 1)) +>undefined : Symbol(undefined) + + async operation() { +>operation : Symbol(Foo.operation, Decl(controlFlowForCatchAndFinally.ts, 24, 53)) + + if (this.abortController !== undefined) { +>this.abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>this : Symbol(Foo, Decl(controlFlowForCatchAndFinally.ts, 22, 40)) +>abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>undefined : Symbol(undefined) + + this.abortController.abort(); +>this.abortController.abort : Symbol(Aborter.abort, Decl(controlFlowForCatchAndFinally.ts, 22, 23)) +>this.abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>this : Symbol(Foo, Decl(controlFlowForCatchAndFinally.ts, 22, 40)) +>abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>abort : Symbol(Aborter.abort, Decl(controlFlowForCatchAndFinally.ts, 22, 23)) + + this.abortController = undefined; +>this.abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>this : Symbol(Foo, Decl(controlFlowForCatchAndFinally.ts, 22, 40)) +>abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>undefined : Symbol(undefined) + } + try { + this.abortController = new Aborter(); +>this.abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>this : Symbol(Foo, Decl(controlFlowForCatchAndFinally.ts, 22, 40)) +>abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>Aborter : Symbol(Aborter, Decl(controlFlowForCatchAndFinally.ts, 20, 1)) + + } catch (error) { +>error : Symbol(error, Decl(controlFlowForCatchAndFinally.ts, 33, 17)) + + if (this.abortController !== undefined) { +>this.abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>this : Symbol(Foo, Decl(controlFlowForCatchAndFinally.ts, 22, 40)) +>abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>undefined : Symbol(undefined) + + this.abortController.abort(); // ok +>this.abortController.abort : Symbol(Aborter.abort, Decl(controlFlowForCatchAndFinally.ts, 22, 23)) +>this.abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>this : Symbol(Foo, Decl(controlFlowForCatchAndFinally.ts, 22, 40)) +>abortController : Symbol(Foo.abortController, Decl(controlFlowForCatchAndFinally.ts, 23, 11)) +>abort : Symbol(Aborter.abort, Decl(controlFlowForCatchAndFinally.ts, 22, 23)) + } + } + } +} diff --git a/tests/baselines/reference/controlFlowForCatchAndFinally.types b/tests/baselines/reference/controlFlowForCatchAndFinally.types new file mode 100644 index 00000000000..a041cac8ce0 --- /dev/null +++ b/tests/baselines/reference/controlFlowForCatchAndFinally.types @@ -0,0 +1,142 @@ +=== tests/cases/compiler/controlFlowForCatchAndFinally.ts === +type Page = {close(): Promise; content(): Promise}; +>Page : Page +>close : () => Promise +>content : () => Promise + +type Browser = {close(): Promise}; +>Browser : Browser +>close : () => Promise + +declare function test1(): Promise; +>test1 : () => Promise + +declare function test2(obj: Browser): Promise; +>test2 : (obj: Browser) => Promise +>obj : Browser + +async function test(): Promise { +>test : () => Promise + + let browser: Browser | undefined = undefined; +>browser : Browser | undefined +>undefined : undefined + + let page: Page | undefined = undefined; +>page : Page | undefined +>undefined : undefined + + try { + browser = await test1(); +>browser = await test1() : Browser +>browser : Browser | undefined +>await test1() : Browser +>test1() : Promise +>test1 : () => Promise + + page = await test2(browser); +>page = await test2(browser) : Page +>page : Page | undefined +>await test2(browser) : Page +>test2(browser) : Promise +>test2 : (obj: Browser) => Promise +>browser : Browser + + return await page.content();; +>await page.content() : string +>page.content() : Promise +>page.content : () => Promise +>page : Page +>content : () => Promise + + } finally { + if (page) { +>page : Page | undefined + + await page.close(); // ok +>await page.close() : void +>page.close() : Promise +>page.close : () => Promise +>page : Page +>close : () => Promise + } + + if (browser) { +>browser : Browser | undefined + + await browser.close(); // ok +>await browser.close() : void +>browser.close() : Promise +>browser.close : () => Promise +>browser : Browser +>close : () => Promise + } + } +} + +declare class Aborter { abort(): void }; +>Aborter : Aborter +>abort : () => void + +class Foo { +>Foo : Foo + + abortController: Aborter | undefined = undefined; +>abortController : Aborter | undefined +>undefined : undefined + + async operation() { +>operation : () => Promise + + if (this.abortController !== undefined) { +>this.abortController !== undefined : boolean +>this.abortController : Aborter | undefined +>this : this +>abortController : Aborter | undefined +>undefined : undefined + + this.abortController.abort(); +>this.abortController.abort() : void +>this.abortController.abort : () => void +>this.abortController : Aborter +>this : this +>abortController : Aborter +>abort : () => void + + this.abortController = undefined; +>this.abortController = undefined : undefined +>this.abortController : Aborter | undefined +>this : this +>abortController : Aborter | undefined +>undefined : undefined + } + try { + this.abortController = new Aborter(); +>this.abortController = new Aborter() : Aborter +>this.abortController : Aborter | undefined +>this : this +>abortController : Aborter | undefined +>new Aborter() : Aborter +>Aborter : typeof Aborter + + } catch (error) { +>error : any + + if (this.abortController !== undefined) { +>this.abortController !== undefined : boolean +>this.abortController : Aborter | undefined +>this : this +>abortController : Aborter | undefined +>undefined : undefined + + this.abortController.abort(); // ok +>this.abortController.abort() : void +>this.abortController.abort : () => void +>this.abortController : Aborter +>this : this +>abortController : Aborter +>abort : () => void + } + } + } +} diff --git a/tests/cases/compiler/controlFlowForCatchAndFinally.ts b/tests/cases/compiler/controlFlowForCatchAndFinally.ts new file mode 100644 index 00000000000..b9a3facbf10 --- /dev/null +++ b/tests/cases/compiler/controlFlowForCatchAndFinally.ts @@ -0,0 +1,42 @@ +// @strict: true +// @lib: es6 +type Page = {close(): Promise; content(): Promise}; +type Browser = {close(): Promise}; +declare function test1(): Promise; +declare function test2(obj: Browser): Promise; +async function test(): Promise { + let browser: Browser | undefined = undefined; + let page: Page | undefined = undefined; + try { + browser = await test1(); + page = await test2(browser); + return await page.content();; + } finally { + if (page) { + await page.close(); // ok + } + + if (browser) { + await browser.close(); // ok + } + } +} + +declare class Aborter { abort(): void }; +class Foo { + abortController: Aborter | undefined = undefined; + + async operation() { + if (this.abortController !== undefined) { + this.abortController.abort(); + this.abortController = undefined; + } + try { + this.abortController = new Aborter(); + } catch (error) { + if (this.abortController !== undefined) { + this.abortController.abort(); // ok + } + } + } +} \ No newline at end of file From d38c616e297d068bb63c28936c6a25406fcb6bfa Mon Sep 17 00:00:00 2001 From: Pranav Senthilnathan Date: Fri, 18 Jan 2019 16:00:18 -0800 Subject: [PATCH 57/88] Fix resolution of properties from prototype assignment in JS (#29302) * fix type derived from prototype assignment * accept new baselines * remove direct intersection with object literal assigned to prototype * add tests * change webpack submodule commit * fix submodule commits * comment and simplify getJSDocTypeReference * remove circularity guards that aren't hit anymore --- src/compiler/checker.ts | 64 ++++++------------- .../classCanExtendConstructorFunction.types | 6 +- .../jsContainerMergeJsContainer.types | 12 ++-- .../typeFromPropertyAssignment14.types | 16 ++--- .../typeFromPropertyAssignment16.types | 16 ++--- .../typeFromPrototypeAssignment3.errors.txt | 26 ++++++++ .../typeFromPrototypeAssignment3.symbols | 40 ++++++++++++ .../typeFromPrototypeAssignment3.types | 53 +++++++++++++++ ...rReferenceOnConstructorFunction.errors.txt | 5 +- .../salsa/typeFromPrototypeAssignment3.ts | 23 +++++++ 10 files changed, 189 insertions(+), 72 deletions(-) create mode 100644 tests/baselines/reference/typeFromPrototypeAssignment3.errors.txt create mode 100644 tests/baselines/reference/typeFromPrototypeAssignment3.symbols create mode 100644 tests/baselines/reference/typeFromPrototypeAssignment3.types create mode 100644 tests/cases/conformance/salsa/typeFromPrototypeAssignment3.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7c5884a324c..ac069d95fac 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8704,21 +8704,17 @@ namespace ts { * the type of this reference is just the type of the value we resolved to. */ function getJSDocTypeReference(node: NodeWithTypeArguments, symbol: Symbol, typeArguments: Type[] | undefined): Type | undefined { - if (!pushTypeResolution(symbol, TypeSystemPropertyName.JSDocTypeReference)) { - return errorType; - } - const assignedType = getAssignedClassType(symbol); - const valueType = getTypeOfSymbol(symbol); - const referenceType = valueType.symbol && valueType.symbol !== symbol && !isInferredClassType(valueType) && getTypeReferenceTypeWorker(node, valueType.symbol, typeArguments); - if (!popTypeResolution()) { - getSymbolLinks(symbol).resolvedJSDocType = errorType; - error(node, Diagnostics.JSDoc_type_0_circularly_references_itself, symbolToString(symbol)); - return errorType; - } - if (referenceType || assignedType) { - // TODO: GH#18217 (should the `|| assignedType` be at a lower precedence?) - const type = (referenceType && assignedType ? getIntersectionType([assignedType, referenceType]) : referenceType || assignedType)!; - return getSymbolLinks(symbol).resolvedJSDocType = type; + // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the + // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: + // var foo = function() {} + // We will find the static type of the assigned anonymous function. + const staticType = getTypeOfSymbol(symbol); + const instanceType = + staticType.symbol && + staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. + getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. + if (instanceType) { + return getSymbolLinks(symbol).resolvedJSDocType = instanceType; } } @@ -8739,8 +8735,11 @@ namespace ts { if (symbol.flags & SymbolFlags.Function && isJSDocTypeReference(node) && - (symbol.members || getJSDocClassTag(symbol.valueDeclaration))) { - return getInferredClassType(symbol); + isJSConstructor(symbol.valueDeclaration)) { + const resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); + if (resolved.callSignatures.length === 1) { + return getReturnTypeOfSignature(resolved.callSignatures[0]); + } } } @@ -16877,7 +16876,7 @@ namespace ts { else if (isInJS && (container.kind === SyntaxKind.FunctionExpression || container.kind === SyntaxKind.FunctionDeclaration) && getJSDocClassTag(container)) { - const classType = getJSClassType(container.symbol); + const classType = getJSClassType(getMergedSymbol(container.symbol)); if (classType) { return getFlowTypeOfReference(node, classType); } @@ -21057,7 +21056,7 @@ namespace ts { // If the symbol of the node has members, treat it like a constructor. const symbol = getSymbolOfNode(func); - return !!symbol && symbol.members !== undefined; + return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype" as __String) !== undefined); } return false; } @@ -21076,10 +21075,6 @@ namespace ts { inferred = getInferredClassType(symbol); } const assigned = getAssignedClassType(symbol); - const valueType = getTypeOfSymbol(symbol); - if (valueType.symbol && !isInferredClassType(valueType) && isJSConstructor(valueType.symbol.valueDeclaration)) { - inferred = getInferredClassType(valueType.symbol); - } return assigned && inferred ? getIntersectionType([inferred, assigned]) : assigned || inferred; @@ -21119,12 +21114,6 @@ namespace ts { return links.inferredClassType; } - function isInferredClassType(type: Type) { - return type.symbol - && getObjectFlags(type) & ObjectFlags.Anonymous - && getSymbolLinks(type.symbol).inferredClassType === type; - } - /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -21146,21 +21135,10 @@ namespace ts { declaration.kind !== SyntaxKind.Constructor && declaration.kind !== SyntaxKind.ConstructSignature && declaration.kind !== SyntaxKind.ConstructorType && - !isJSDocConstructSignature(declaration)) { + !isJSDocConstructSignature(declaration) && + !isJSConstructor(declaration)) { - // When resolved signature is a call signature (and not a construct signature) the result type is any, unless - // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations - // in a JS file - // Note:JS inferred classes might come from a variable declaration instead of a function declaration. - // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. - let funcSymbol = checkExpression(node.expression).symbol; - if (!funcSymbol && node.expression.kind === SyntaxKind.Identifier) { - funcSymbol = getResolvedSymbol(node.expression as Identifier); - } - const type = funcSymbol && getJSClassType(funcSymbol); - if (type) { - return signature.target ? instantiateType(type, signature.mapper) : type; - } + // When resolved signature is a call signature (and not a construct signature) the result type is any if (noImplicitAny) { error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } diff --git a/tests/baselines/reference/classCanExtendConstructorFunction.types b/tests/baselines/reference/classCanExtendConstructorFunction.types index f42366976fc..c9ac9c76ebf 100644 --- a/tests/baselines/reference/classCanExtendConstructorFunction.types +++ b/tests/baselines/reference/classCanExtendConstructorFunction.types @@ -269,8 +269,8 @@ soup.flavour >flavour : number var chowder = new Chowder({ claim: "ignorant" }); ->chowder : any ->new Chowder({ claim: "ignorant" }) : any +>chowder : Chowder +>new Chowder({ claim: "ignorant" }) : Chowder >Chowder : typeof Chowder >{ claim: "ignorant" } : { claim: "ignorant"; } >claim : "ignorant" @@ -279,7 +279,7 @@ var chowder = new Chowder({ claim: "ignorant" }); chowder.flavour.claim >chowder.flavour.claim : any >chowder.flavour : any ->chowder : any +>chowder : Chowder >flavour : any >claim : any diff --git a/tests/baselines/reference/jsContainerMergeJsContainer.types b/tests/baselines/reference/jsContainerMergeJsContainer.types index 73e61aded0d..56cb598269d 100644 --- a/tests/baselines/reference/jsContainerMergeJsContainer.types +++ b/tests/baselines/reference/jsContainerMergeJsContainer.types @@ -5,19 +5,19 @@ const a = {}; >{} : {} a.d = function() {}; ->a.d = function() {} : { (): void; prototype: {}; } ->a.d : { (): void; prototype: {}; } +>a.d = function() {} : typeof d +>a.d : typeof d >a : typeof a ->d : { (): void; prototype: {}; } ->function() {} : { (): void; prototype: {}; } +>d : typeof d +>function() {} : typeof d === tests/cases/conformance/salsa/b.js === a.d.prototype = {}; >a.d.prototype = {} : {} >a.d.prototype : {} ->a.d : { (): void; prototype: {}; } +>a.d : typeof d >a : typeof a ->d : { (): void; prototype: {}; } +>d : typeof d >prototype : {} >{} : {} diff --git a/tests/baselines/reference/typeFromPropertyAssignment14.types b/tests/baselines/reference/typeFromPropertyAssignment14.types index bc1b2a69be9..bb8169db359 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment14.types +++ b/tests/baselines/reference/typeFromPropertyAssignment14.types @@ -5,18 +5,18 @@ var Outer = {}; === tests/cases/conformance/salsa/work.js === Outer.Inner = function () {} ->Outer.Inner = function () {} : { (): void; prototype: { x: number; m(): void; }; } ->Outer.Inner : { (): void; prototype: { x: number; m(): void; }; } +>Outer.Inner = function () {} : typeof Inner +>Outer.Inner : typeof Inner >Outer : typeof Outer ->Inner : { (): void; prototype: { x: number; m(): void; }; } ->function () {} : { (): void; prototype: { x: number; m(): void; }; } +>Inner : typeof Inner +>function () {} : typeof Inner Outer.Inner.prototype = { >Outer.Inner.prototype = { x: 1, m() { }} : { x: number; m(): void; } >Outer.Inner.prototype : { x: number; m(): void; } ->Outer.Inner : { (): void; prototype: { x: number; m(): void; }; } +>Outer.Inner : typeof Inner >Outer : typeof Outer ->Inner : { (): void; prototype: { x: number; m(): void; }; } +>Inner : typeof Inner >prototype : { x: number; m(): void; } >{ x: 1, m() { }} : { x: number; m(): void; } @@ -47,9 +47,9 @@ inner.m() var inno = new Outer.Inner() >inno : { x: number; m(): void; } >new Outer.Inner() : { x: number; m(): void; } ->Outer.Inner : { (): void; prototype: { x: number; m(): void; }; } +>Outer.Inner : typeof Inner >Outer : typeof Outer ->Inner : { (): void; prototype: { x: number; m(): void; }; } +>Inner : typeof Inner inno.x >inno.x : number diff --git a/tests/baselines/reference/typeFromPropertyAssignment16.types b/tests/baselines/reference/typeFromPropertyAssignment16.types index f2cb476e5fa..1d94d096ea0 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment16.types +++ b/tests/baselines/reference/typeFromPropertyAssignment16.types @@ -4,18 +4,18 @@ var Outer = {}; >{} : {} Outer.Inner = function () {} ->Outer.Inner = function () {} : { (): void; prototype: { x: number; m(): void; }; } ->Outer.Inner : { (): void; prototype: { x: number; m(): void; }; } +>Outer.Inner = function () {} : typeof Inner +>Outer.Inner : typeof Inner >Outer : typeof Outer ->Inner : { (): void; prototype: { x: number; m(): void; }; } ->function () {} : { (): void; prototype: { x: number; m(): void; }; } +>Inner : typeof Inner +>function () {} : typeof Inner Outer.Inner.prototype = { >Outer.Inner.prototype = { x: 1, m() { }} : { x: number; m(): void; } >Outer.Inner.prototype : { x: number; m(): void; } ->Outer.Inner : { (): void; prototype: { x: number; m(): void; }; } +>Outer.Inner : typeof Inner >Outer : typeof Outer ->Inner : { (): void; prototype: { x: number; m(): void; }; } +>Inner : typeof Inner >prototype : { x: number; m(): void; } >{ x: 1, m() { }} : { x: number; m(): void; } @@ -45,9 +45,9 @@ inner.m() var inno = new Outer.Inner() >inno : { x: number; m(): void; } >new Outer.Inner() : { x: number; m(): void; } ->Outer.Inner : { (): void; prototype: { x: number; m(): void; }; } +>Outer.Inner : typeof Inner >Outer : typeof Outer ->Inner : { (): void; prototype: { x: number; m(): void; }; } +>Inner : typeof Inner inno.x >inno.x : number diff --git a/tests/baselines/reference/typeFromPrototypeAssignment3.errors.txt b/tests/baselines/reference/typeFromPrototypeAssignment3.errors.txt new file mode 100644 index 00000000000..579c3efac72 --- /dev/null +++ b/tests/baselines/reference/typeFromPrototypeAssignment3.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/salsa/bug26885.js(2,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +tests/cases/conformance/salsa/bug26885.js(11,16): error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. + + +==== tests/cases/conformance/salsa/bug26885.js (2 errors) ==== + function Multimap3() { + this._map = {}; + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + }; + + Multimap3.prototype = { + /** + * @param {string} key + * @returns {number} the value ok + */ + get(key) { + return this._map[key + '']; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. + } + } + + /** @type {Multimap3} */ + const map = new Multimap3(); + const n = map.get('hi') \ No newline at end of file diff --git a/tests/baselines/reference/typeFromPrototypeAssignment3.symbols b/tests/baselines/reference/typeFromPrototypeAssignment3.symbols new file mode 100644 index 00000000000..65b72e9441b --- /dev/null +++ b/tests/baselines/reference/typeFromPrototypeAssignment3.symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/salsa/bug26885.js === +function Multimap3() { +>Multimap3 : Symbol(Multimap3, Decl(bug26885.js, 0, 0), Decl(bug26885.js, 2, 2)) + + this._map = {}; +>_map : Symbol(Multimap3._map, Decl(bug26885.js, 0, 22)) + +}; + +Multimap3.prototype = { +>Multimap3.prototype : Symbol(Multimap3.prototype, Decl(bug26885.js, 2, 2)) +>Multimap3 : Symbol(Multimap3, Decl(bug26885.js, 0, 0), Decl(bug26885.js, 2, 2)) +>prototype : Symbol(Multimap3.prototype, Decl(bug26885.js, 2, 2)) + + /** + * @param {string} key + * @returns {number} the value ok + */ + get(key) { +>get : Symbol(get, Decl(bug26885.js, 4, 23)) +>key : Symbol(key, Decl(bug26885.js, 9, 8)) + + return this._map[key + '']; +>this._map : Symbol(Multimap3._map, Decl(bug26885.js, 0, 22)) +>_map : Symbol(Multimap3._map, Decl(bug26885.js, 0, 22)) +>key : Symbol(key, Decl(bug26885.js, 9, 8)) + } +} + +/** @type {Multimap3} */ +const map = new Multimap3(); +>map : Symbol(map, Decl(bug26885.js, 15, 5)) +>Multimap3 : Symbol(Multimap3, Decl(bug26885.js, 0, 0), Decl(bug26885.js, 2, 2)) + +const n = map.get('hi') +>n : Symbol(n, Decl(bug26885.js, 16, 5)) +>map.get : Symbol(get, Decl(bug26885.js, 4, 23)) +>map : Symbol(map, Decl(bug26885.js, 15, 5)) +>get : Symbol(get, Decl(bug26885.js, 4, 23)) + diff --git a/tests/baselines/reference/typeFromPrototypeAssignment3.types b/tests/baselines/reference/typeFromPrototypeAssignment3.types new file mode 100644 index 00000000000..82fef59c42a --- /dev/null +++ b/tests/baselines/reference/typeFromPrototypeAssignment3.types @@ -0,0 +1,53 @@ +=== tests/cases/conformance/salsa/bug26885.js === +function Multimap3() { +>Multimap3 : typeof Multimap3 + + this._map = {}; +>this._map = {} : {} +>this._map : any +>this : any +>_map : any +>{} : {} + +}; + +Multimap3.prototype = { +>Multimap3.prototype = { /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: string): number; } +>Multimap3.prototype : { get(key: string): number; } +>Multimap3 : typeof Multimap3 +>prototype : { get(key: string): number; } +>{ /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: string): number; } + + /** + * @param {string} key + * @returns {number} the value ok + */ + get(key) { +>get : (key: string) => number +>key : string + + return this._map[key + '']; +>this._map[key + ''] : any +>this._map : {} +>this : Multimap3 & { get(key: string): number; } +>_map : {} +>key + '' : string +>key : string +>'' : "" + } +} + +/** @type {Multimap3} */ +const map = new Multimap3(); +>map : Multimap3 & { get(key: string): number; } +>new Multimap3() : Multimap3 & { get(key: string): number; } +>Multimap3 : typeof Multimap3 + +const n = map.get('hi') +>n : number +>map.get('hi') : number +>map.get : (key: string) => number +>map : Multimap3 & { get(key: string): number; } +>get : (key: string) => number +>'hi' : "hi" + diff --git a/tests/baselines/reference/typeTagCircularReferenceOnConstructorFunction.errors.txt b/tests/baselines/reference/typeTagCircularReferenceOnConstructorFunction.errors.txt index 2469e647685..d98cb9297dc 100644 --- a/tests/baselines/reference/typeTagCircularReferenceOnConstructorFunction.errors.txt +++ b/tests/baselines/reference/typeTagCircularReferenceOnConstructorFunction.errors.txt @@ -1,14 +1,11 @@ tests/cases/conformance/jsdoc/bug27346.js(2,4): error TS8030: The type of a function declaration must match the function's signature. -tests/cases/conformance/jsdoc/bug27346.js(2,11): error TS2587: JSDoc type 'MyClass' circularly references itself. -==== tests/cases/conformance/jsdoc/bug27346.js (2 errors) ==== +==== tests/cases/conformance/jsdoc/bug27346.js (1 errors) ==== /** * @type {MyClass} ~~~~~~~~~~~~~~~ !!! error TS8030: The type of a function declaration must match the function's signature. - ~~~~~~~ -!!! error TS2587: JSDoc type 'MyClass' circularly references itself. */ function MyClass() { } MyClass.prototype = {}; diff --git a/tests/cases/conformance/salsa/typeFromPrototypeAssignment3.ts b/tests/cases/conformance/salsa/typeFromPrototypeAssignment3.ts new file mode 100644 index 00000000000..00475db6cc1 --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromPrototypeAssignment3.ts @@ -0,0 +1,23 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: bug26885.js +// @strict: true + +function Multimap3() { + this._map = {}; +}; + +Multimap3.prototype = { + /** + * @param {string} key + * @returns {number} the value ok + */ + get(key) { + return this._map[key + '']; + } +} + +/** @type {Multimap3} */ +const map = new Multimap3(); +const n = map.get('hi') \ No newline at end of file From e38ac0d5a4178f3a3d93e86bd1fef4f53f6e2ecf Mon Sep 17 00:00:00 2001 From: kingwl Date: Sun, 20 Jan 2019 02:17:09 +0800 Subject: [PATCH 58/88] fix api --- 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 6d3061f15b2..4353bbcd8fa 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3097,7 +3097,7 @@ declare namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; - reScanLesserToken(): SyntaxKind; + 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 377355210aa..d8deb32c0ef 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3097,7 +3097,7 @@ declare namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; - reScanLesserToken(): SyntaxKind; + reScanLessThanToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJSDocToken(): JsDocSyntaxKind; scan(): SyntaxKind; From 60639ce5a80c8a651ea98ec5c30842e434a54bbc Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 22 Jan 2019 14:24:21 -0800 Subject: [PATCH 59/88] Replace most instances of getTextOfPropertyName in checker --- src/compiler/checker.ts | 92 +++++++++---------- src/compiler/types.ts | 1 + .../reference/api/tsserverlibrary.d.ts | 1 + tests/baselines/reference/api/typescript.d.ts | 1 + ...InGetTextOfComputedPropertyName.errors.txt | 36 ++++++++ ...crashInGetTextOfComputedPropertyName.types | 6 +- .../destructureComputedProperty.errors.txt | 5 +- ...redLateBoundNameHasCorrectTypes.errors.txt | 11 ++- ...ructuredLateBoundNameHasCorrectTypes.types | 2 +- ...destructuringAssignment_private.errors.txt | 14 ++- .../destructuringAssignment_private.js | 11 +++ .../destructuringAssignment_private.symbols | 21 +++++ .../destructuringAssignment_private.types | 37 ++++++++ .../destructuringAssignment_private.ts | 6 ++ 14 files changed, 188 insertions(+), 56 deletions(-) create mode 100644 tests/baselines/reference/crashInGetTextOfComputedPropertyName.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 48232a2e026..d38111efa1e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5280,17 +5280,18 @@ namespace ts { let objectFlags = ObjectFlags.ObjectLiteral; forEach(pattern.elements, e => { const name = e.propertyName || e.name; - if (isComputedNonLiteralName(name)) { - // do not include computed properties in the implied type - objectFlags |= ObjectFlags.ObjectLiteralPatternWithComputedProperties; - return; - } if (e.dotDotDotToken) { stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); return; } - const text = getTextOfPropertyName(name); + const exprType = getLiteralTypeFromPropertyName(name); + if (!isTypeUsableAsPropertyName(exprType)) { + // do not include computed properties in the implied type + objectFlags |= ObjectFlags.ObjectLiteralPatternWithComputedProperties; + return; + } + const text = getPropertyNameFromType(exprType); const flags = SymbolFlags.Property | (e.initializer ? SymbolFlags.Optional : 0); const symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); @@ -6399,9 +6400,9 @@ namespace ts { } /** - * Indicates whether a type can be used as a late-bound name. + * Indicates whether a type can be used as a property name. */ - function isTypeUsableAsLateBoundName(type: Type): type is LiteralType | UniqueESSymbolType { + function isTypeUsableAsPropertyName(type: Type): type is StringLiteralType | NumberLiteralType | UniqueESSymbolType { return !!(type.flags & TypeFlags.StringOrNumberLiteralOrUnique); } @@ -6416,7 +6417,7 @@ namespace ts { function isLateBindableName(node: DeclarationName): node is LateBoundName { return isComputedPropertyName(node) && isEntityNameExpression(node.expression) - && isTypeUsableAsLateBoundName(checkComputedPropertyName(node)); + && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); } function isLateBoundName(name: __String): boolean { @@ -6448,21 +6449,14 @@ namespace ts { } /** - * Gets the late-bound name for a computed property name. + * Gets the symbolic name for a member from its type. */ - function getLateBoundName(node: LateBoundName) { - return getLateBoundNameFromType(checkComputedPropertyName(node)); - } - - /** - * Gets the symbolic name for a late-bound member from its type. - */ - function getLateBoundNameFromType(type: LiteralType | UniqueESSymbolType): __String { + function getPropertyNameFromType(type: StringLiteralType | NumberLiteralType | UniqueESSymbolType): __String { if (type.flags & TypeFlags.UniqueESSymbol) { - return `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}` as __String; + return (type).escapedName; } if (type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral)) { - return escapeLeadingUnderscores("" + (type).value); + return escapeLeadingUnderscores("" + (type).value); } return Debug.fail(); } @@ -6525,8 +6519,8 @@ namespace ts { // fall back to the early-bound name of this member. links.resolvedSymbol = decl.symbol; const type = checkComputedPropertyName(decl.name); - if (isTypeUsableAsLateBoundName(type)) { - const memberName = getLateBoundNameFromType(type); + if (isTypeUsableAsPropertyName(type)) { + const memberName = getPropertyNameFromType(type); const symbolFlags = decl.symbol.flags; // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. @@ -7175,8 +7169,8 @@ namespace ts { const propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. // Otherwise, for type string create a string index signature. - if (t.flags & TypeFlags.StringOrNumberLiteralOrUnique) { - const propName = getLateBoundNameFromType(t as LiteralType); + if (isTypeUsableAsPropertyName(t)) { + const propName = getPropertyNameFromType(t); const modifiersProp = getPropertyOfType(modifiersType, propName); const isOptional = !!(templateModifiers & MappedTypeModifiers.IncludeOptional || !(templateModifiers & MappedTypeModifiers.ExcludeOptional) && modifiersProp && modifiersProp.flags & SymbolFlags.Optional); @@ -7361,7 +7355,8 @@ namespace ts { function isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression | JsxAttributes): boolean { const list = obj.properties as NodeArray; return list.some(property => { - const name = property.name && !isComputedNonLiteralName(property.name) ? getTextOfPropertyName(property.name) : undefined; + const nameType = property.name && getLiteralTypeFromPropertyName(property.name); + const name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined; const expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); return !!expected && isLiteralType(expected) && !isTypeIdenticalTo(getTypeOfNode(property), expected); }); @@ -9724,8 +9719,8 @@ namespace ts { function getPropertyTypeForIndexType(objectType: Type, indexType: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode | PropertyName | BindingName | SyntheticExpression | undefined, cacheSymbol: boolean, missingType: Type) { const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode : undefined; - const propName = isTypeUsableAsLateBoundName(indexType) ? - getLateBoundNameFromType(indexType) : + const propName = isTypeUsableAsPropertyName(indexType) ? + getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? getPropertyNameForKnownSymbolName(idText((accessExpression.argumentExpression).name)) : accessNode && isPropertyName(accessNode) ? @@ -10415,6 +10410,7 @@ namespace ts { function createUniqueESSymbolType(symbol: Symbol) { const type = createType(TypeFlags.UniqueESSymbol); type.symbol = symbol; + type.escapedName = `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}` as __String; return type; } @@ -11302,7 +11298,7 @@ namespace ts { } if (resultObj.error) { const reportedDiag = resultObj.error; - const propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined; + const propertyName = isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined; const targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; let issuedElaboration = false; @@ -15066,10 +15062,9 @@ namespace ts { } function getTypeOfDestructuredProperty(type: Type, name: PropertyName) { - const text = !isComputedNonLiteralName(name) ? getTextOfPropertyName(name) : - isLateBindableName(name) ? getLateBoundName(name) : - undefined; - if (text === undefined) return errorType; + const nameType = getLiteralTypeFromPropertyName(name); + if (!isTypeUsableAsPropertyName(nameType)) return errorType; + const text = getPropertyNameFromType(nameType); return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || isNumericLiteralName(text) && getIndexTypeOfType(type, IndexKind.Number) || getIndexTypeOfType(type, IndexKind.String) || @@ -17202,8 +17197,11 @@ namespace ts { const name = declaration.propertyName || declaration.name; const parentType = getContextualTypeForVariableLikeDeclaration(parentDeclaration); if (parentType && !isBindingPattern(name) && !isComputedNonLiteralName(name)) { - const text = getTextOfPropertyName(name); - return getTypeOfPropertyOfType(parentType, text); + const nameType = getLiteralTypeFromPropertyName(name); + if (isTypeUsableAsPropertyName(nameType)) { + const text = getPropertyNameFromType(nameType); + return getTypeOfPropertyOfType(parentType, text); + } } } @@ -18146,10 +18144,9 @@ namespace ts { } } typeFlags |= type.flags; - const nameType = computedNameType && computedNameType.flags & TypeFlags.StringOrNumberLiteralOrUnique ? - computedNameType : undefined; + const nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; const prop = nameType ? - createSymbol(SymbolFlags.Property | member.flags, getLateBoundNameFromType(nameType), CheckFlags.Late) : + createSymbol(SymbolFlags.Property | member.flags, getPropertyNameFromType(nameType), CheckFlags.Late) : createSymbol(SymbolFlags.Property | member.flags, member.escapedName); if (nameType) { prop.nameType = nameType; @@ -22209,15 +22206,15 @@ 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; - if (!isComputedNonLiteralName(name)) { - const text = getTextOfPropertyName(name); + const exprType = getLiteralTypeFromPropertyName(name); + if (isTypeUsableAsPropertyName(exprType)) { + const text = getPropertyNameFromType(exprType); const prop = getPropertyOfType(objectLiteralType, text); if (prop) { markPropertyAsReferenced(prop, property, rightIsThis); checkPropertyAccessibility(property, /*isSuper*/ false, objectLiteralType, prop); } } - const exprType = getLiteralTypeFromPropertyName(name); const elementType = getIndexedAccessType(objectLiteralType, exprType, name); const type = getFlowTypeOfDestructuring(property, elementType); return checkDestructuringAssignment(property.kind === SyntaxKind.ShorthandPropertyAssignment ? property : property.initializer, type); @@ -25532,12 +25529,15 @@ namespace ts { const parent = node.parent.parent; const parentType = getTypeForBindingElementParent(parent); const name = node.propertyName || node.name; - if (!isBindingPattern(name) && !isComputedNonLiteralName(name)) { - const nameText = getTextOfPropertyName(name); - 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); + if (!isBindingPattern(name) && parentType) { + const exprType = getLiteralTypeFromPropertyName(name); + if (isTypeUsableAsPropertyName(exprType)) { + const nameText = getPropertyNameFromType(exprType); + const property = getPropertyOfType(parentType, nameText); + 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/types.ts b/src/compiler/types.ts index 125c3297863..8b4be87d925 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3952,6 +3952,7 @@ namespace ts { // Unique symbol types (TypeFlags.UniqueESSymbol) export interface UniqueESSymbolType extends Type { symbol: Symbol; + escapedName: __String; } export interface StringLiteralType extends LiteralType { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 91f492ddd1d..152ffe33a10 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2214,6 +2214,7 @@ declare namespace ts { } interface UniqueESSymbolType extends Type { symbol: Symbol; + escapedName: __String; } interface StringLiteralType extends LiteralType { value: string; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 0e693f698f2..077bd9646d0 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2214,6 +2214,7 @@ declare namespace ts { } interface UniqueESSymbolType extends Type { symbol: Symbol; + escapedName: __String; } interface StringLiteralType extends LiteralType { value: string; diff --git a/tests/baselines/reference/crashInGetTextOfComputedPropertyName.errors.txt b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.errors.txt new file mode 100644 index 00000000000..4997400674c --- /dev/null +++ b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.errors.txt @@ -0,0 +1,36 @@ +tests/cases/compiler/crashInGetTextOfComputedPropertyName.ts(23,24): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + + +==== tests/cases/compiler/crashInGetTextOfComputedPropertyName.ts (1 errors) ==== + // 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*/ + ~~~~~~~~~~~~~~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + } = 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 diff --git a/tests/baselines/reference/crashInGetTextOfComputedPropertyName.types b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.types index 7d9ce4aa34b..4eeb487bdfb 100644 --- a/tests/baselines/reference/crashInGetTextOfComputedPropertyName.types +++ b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.types @@ -56,8 +56,8 @@ const { items: { [itemId]: itemWithTSError } = {} /*happens when default value is provided*/ >items : any >itemId : "some-id" ->itemWithTSError : AB ->{} : {} +>itemWithTSError : any +>{} : { some-id: any; } } = objWithItems >objWithItems : ObjWithItems @@ -65,7 +65,7 @@ const { // in order to re-produce the error, uncomment next line: typeof itemWithTSError // :( >typeof itemWithTSError : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" ->itemWithTSError : AB +>itemWithTSError : any // 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/destructureComputedProperty.errors.txt b/tests/baselines/reference/destructureComputedProperty.errors.txt index 5b39820988a..ad6e8042f87 100644 --- a/tests/baselines/reference/destructureComputedProperty.errors.txt +++ b/tests/baselines/reference/destructureComputedProperty.errors.txt @@ -1,9 +1,10 @@ tests/cases/compiler/destructureComputedProperty.ts(7,7): error TS2341: Property 'p' is private and only accessible within class 'C'. tests/cases/compiler/destructureComputedProperty.ts(8,7): error TS2341: Property 'p' is private and only accessible within class 'C'. +tests/cases/compiler/destructureComputedProperty.ts(9,7): error TS2341: Property 'p' is private and only accessible within class 'C'. tests/cases/compiler/destructureComputedProperty.ts(10,7): error TS2341: Property 'p' is private and only accessible within class 'C'. -==== tests/cases/compiler/destructureComputedProperty.ts (3 errors) ==== +==== tests/cases/compiler/destructureComputedProperty.ts (4 errors) ==== declare const ab: { n: number } | { n: string }; const nameN = "n"; const { [nameN]: n } = ab; @@ -17,6 +18,8 @@ tests/cases/compiler/destructureComputedProperty.ts(10,7): error TS2341: Propert ~~~~~~~~~~~~~ !!! error TS2341: Property 'p' is private and only accessible within class 'C'. const { [nameP]: p2 } = new C(); + ~~~~~~~~~~~~~~~ +!!! error TS2341: Property 'p' is private and only accessible within class 'C'. const { p: p3 } = new C(); ~~~~~~~~~ !!! error TS2341: Property 'p' is private and only accessible within class 'C'. diff --git a/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.errors.txt b/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.errors.txt index 100ce2d9a08..6d3d288af74 100644 --- a/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.errors.txt +++ b/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.errors.txt @@ -1,7 +1,8 @@ -tests/cases/compiler/destructuredLateBoundNameHasCorrectTypes.ts(11,8): error TS2339: Property 'prop2' does not exist on type '{ prop: string; }'. +tests/cases/compiler/destructuredLateBoundNameHasCorrectTypes.ts(11,21): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/compiler/destructuredLateBoundNameHasCorrectTypes.ts(11,37): error TS2353: Object literal may only specify known properties, and 'prop' does not exist in type '{ prop2: any; }'. -==== tests/cases/compiler/destructuredLateBoundNameHasCorrectTypes.ts (1 errors) ==== +==== tests/cases/compiler/destructuredLateBoundNameHasCorrectTypes.ts (2 errors) ==== let { [Symbol.iterator]: destructured } = []; void destructured; @@ -13,6 +14,8 @@ tests/cases/compiler/destructuredLateBoundNameHasCorrectTypes.ts(11,8): error TS const notPresent = "prop2"; let { [notPresent]: computed2 } = { prop: "b" }; - ~~~~~~~~~~ -!!! error TS2339: Property 'prop2' does not exist on type '{ prop: string; }'. + ~~~~~~~~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~~~~ +!!! error TS2353: Object literal may only specify known properties, and 'prop' does not exist in type '{ prop2: any; }'. \ No newline at end of file diff --git a/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.types b/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.types index 8d24b45e0ec..8342017958a 100644 --- a/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.types +++ b/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.types @@ -32,7 +32,7 @@ const notPresent = "prop2"; let { [notPresent]: computed2 } = { prop: "b" }; >notPresent : "prop2" >computed2 : any ->{ prop: "b" } : { prop: string; } +>{ prop: "b" } : { prop: string; prop2: any; } >prop : string >"b" : "b" diff --git a/tests/baselines/reference/destructuringAssignment_private.errors.txt b/tests/baselines/reference/destructuringAssignment_private.errors.txt index f17f1610d0a..2afd1606ebb 100644 --- a/tests/baselines/reference/destructuringAssignment_private.errors.txt +++ b/tests/baselines/reference/destructuringAssignment_private.errors.txt @@ -1,8 +1,10 @@ tests/cases/compiler/destructuringAssignment_private.ts(6,10): error TS2341: Property 'x' is private and only accessible within class 'C'. tests/cases/compiler/destructuringAssignment_private.ts(7,4): error TS2341: Property 'o' is private and only accessible within class 'C'. +tests/cases/compiler/destructuringAssignment_private.ts(10,10): error TS2341: Property 'x' is private and only accessible within class 'C'. +tests/cases/compiler/destructuringAssignment_private.ts(13,4): error TS2341: Property 'o' is private and only accessible within class 'C'. -==== tests/cases/compiler/destructuringAssignment_private.ts (2 errors) ==== +==== tests/cases/compiler/destructuringAssignment_private.ts (4 errors) ==== class C { private x = 0; private o = [{ a: 1 }]; @@ -14,4 +16,14 @@ tests/cases/compiler/destructuringAssignment_private.ts(7,4): error TS2341: Prop ({ o: [{ a: x }]} = new C()); ~ !!! error TS2341: Property 'o' is private and only accessible within class 'C'. + + const nameX = "x"; + ([{ a: { [nameX]: x } }] = [{ a: new C() }]); + ~~~~~~~ +!!! error TS2341: Property 'x' is private and only accessible within class 'C'. + + const nameO = "o"; + ({ [nameO]: [{ a: x }]} = new C()); + ~~~~~~~ +!!! error TS2341: Property 'o' is private and only accessible within class 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/destructuringAssignment_private.js b/tests/baselines/reference/destructuringAssignment_private.js index 6201ad3578e..b8f4130761b 100644 --- a/tests/baselines/reference/destructuringAssignment_private.js +++ b/tests/baselines/reference/destructuringAssignment_private.js @@ -6,9 +6,16 @@ class C { let x: number; ([{ a: { x } }] = [{ a: new C() }]); ({ o: [{ a: x }]} = new C()); + +const nameX = "x"; +([{ a: { [nameX]: x } }] = [{ a: new C() }]); + +const nameO = "o"; +({ [nameO]: [{ a: x }]} = new C()); //// [destructuringAssignment_private.js] +var _a, _b; var C = /** @class */ (function () { function C() { this.x = 0; @@ -19,3 +26,7 @@ var C = /** @class */ (function () { var x; (x = [{ a: new C() }][0].a.x); (x = new C().o[0].a); +var nameX = "x"; +(_a = nameX, x = [{ a: new C() }][0].a[_a]); +var nameO = "o"; +(_b = nameO, x = new C()[_b][0].a); diff --git a/tests/baselines/reference/destructuringAssignment_private.symbols b/tests/baselines/reference/destructuringAssignment_private.symbols index b3a7abce5bf..be325bda639 100644 --- a/tests/baselines/reference/destructuringAssignment_private.symbols +++ b/tests/baselines/reference/destructuringAssignment_private.symbols @@ -24,3 +24,24 @@ let x: number; >x : Symbol(x, Decl(destructuringAssignment_private.ts, 4, 3)) >C : Symbol(C, Decl(destructuringAssignment_private.ts, 0, 0)) +const nameX = "x"; +>nameX : Symbol(nameX, Decl(destructuringAssignment_private.ts, 8, 5)) + +([{ a: { [nameX]: x } }] = [{ a: new C() }]); +>a : Symbol(a, Decl(destructuringAssignment_private.ts, 9, 3)) +>[nameX] : Symbol([nameX], Decl(destructuringAssignment_private.ts, 9, 8)) +>nameX : Symbol(nameX, Decl(destructuringAssignment_private.ts, 8, 5)) +>x : Symbol(x, Decl(destructuringAssignment_private.ts, 4, 3)) +>a : Symbol(a, Decl(destructuringAssignment_private.ts, 9, 29)) +>C : Symbol(C, Decl(destructuringAssignment_private.ts, 0, 0)) + +const nameO = "o"; +>nameO : Symbol(nameO, Decl(destructuringAssignment_private.ts, 11, 5)) + +({ [nameO]: [{ a: x }]} = new C()); +>[nameO] : Symbol([nameO], Decl(destructuringAssignment_private.ts, 12, 2)) +>nameO : Symbol(nameO, Decl(destructuringAssignment_private.ts, 11, 5)) +>a : Symbol(a, Decl(destructuringAssignment_private.ts, 12, 14)) +>x : Symbol(x, Decl(destructuringAssignment_private.ts, 4, 3)) +>C : Symbol(C, Decl(destructuringAssignment_private.ts, 0, 0)) + diff --git a/tests/baselines/reference/destructuringAssignment_private.types b/tests/baselines/reference/destructuringAssignment_private.types index f126a973f1d..0615429cef5 100644 --- a/tests/baselines/reference/destructuringAssignment_private.types +++ b/tests/baselines/reference/destructuringAssignment_private.types @@ -42,3 +42,40 @@ let x: number; >new C() : C >C : typeof C +const nameX = "x"; +>nameX : "x" +>"x" : "x" + +([{ a: { [nameX]: x } }] = [{ a: new C() }]); +>([{ a: { [nameX]: x } }] = [{ a: new C() }]) : [{ a: C; }] +>[{ a: { [nameX]: x } }] = [{ a: new C() }] : [{ a: C; }] +>[{ a: { [nameX]: x } }] : [{ a: { [nameX]: number; }; }] +>{ a: { [nameX]: x } } : { a: { [nameX]: number; }; } +>a : { [nameX]: number; } +>{ [nameX]: x } : { [nameX]: number; } +>[nameX] : number +>nameX : "x" +>x : number +>[{ a: new C() }] : [{ a: C; }] +>{ a: new C() } : { a: C; } +>a : C +>new C() : C +>C : typeof C + +const nameO = "o"; +>nameO : "o" +>"o" : "o" + +({ [nameO]: [{ a: x }]} = new C()); +>({ [nameO]: [{ a: x }]} = new C()) : C +>{ [nameO]: [{ a: x }]} = new C() : C +>{ [nameO]: [{ a: x }]} : { [nameO]: [{ a: number; }]; } +>[nameO] : [{ a: number; }] +>nameO : "o" +>[{ a: x }] : [{ a: number; }] +>{ a: x } : { a: number; } +>a : number +>x : number +>new C() : C +>C : typeof C + diff --git a/tests/cases/compiler/destructuringAssignment_private.ts b/tests/cases/compiler/destructuringAssignment_private.ts index bdc057851ae..62f4101838d 100644 --- a/tests/cases/compiler/destructuringAssignment_private.ts +++ b/tests/cases/compiler/destructuringAssignment_private.ts @@ -5,3 +5,9 @@ class C { let x: number; ([{ a: { x } }] = [{ a: new C() }]); ({ o: [{ a: x }]} = new C()); + +const nameX = "x"; +([{ a: { [nameX]: x } }] = [{ a: new C() }]); + +const nameO = "o"; +({ [nameO]: [{ a: x }]} = new C()); From f0227ecb2cc07623efeec08258637169fba847f2 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 15 Jan 2019 12:34:36 -0800 Subject: [PATCH 60/88] Handle find all references for symbol merged with UMD module and global var Fixes #29093 --- src/harness/fourslash.ts | 4 +- src/services/findAllReferences.ts | 127 +++++++++++++++--- ...findAllReferencesUmdModuleAsGlobalConst.ts | 43 ++++++ 3 files changed, 153 insertions(+), 21 deletions(-) create mode 100644 tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 2b04b4bd8cd..b0bb35d5db3 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -939,8 +939,8 @@ namespace FourSlash { const startFile = this.activeFile.fileName; for (const fileName of files) { const searchFileNames = startFile === fileName ? [startFile] : [startFile, fileName]; - const highlights = this.getDocumentHighlightsAtCurrentPosition(searchFileNames)!; - if (!highlights.every(dh => ts.contains(searchFileNames, dh.fileName))) { + const highlights = this.getDocumentHighlightsAtCurrentPosition(searchFileNames); + if (highlights && !highlights.every(dh => ts.contains(searchFileNames, dh.fileName))) { this.raiseError(`When asking for document highlights only in files ${searchFileNames}, got document highlights in ${unique(highlights, dh => dh.fileName)}`); } } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 54202322260..b3c62c2085c 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -111,7 +111,7 @@ namespace ts.FindAllReferences { return flattenEntries(Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options, sourceFilesSet)); } - function flattenEntries(referenceSymbols: SymbolAndEntries[] | undefined): ReadonlyArray | undefined { + function flattenEntries(referenceSymbols: ReadonlyArray | undefined): ReadonlyArray | undefined { return referenceSymbols && flatMap(referenceSymbols, r => r.references); } @@ -282,6 +282,11 @@ namespace ts.FindAllReferences { return createTextSpanFromBounds(start, end); } + export function getTextSpanOfEntry(entry: Entry) { + return entry.kind === EntryKind.Span ? entry.textSpan : + getTextSpan(entry.node, entry.node.getSourceFile()); + } + /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node: Node): boolean { const decl = getDeclarationFromName(node); @@ -353,7 +358,7 @@ namespace ts.FindAllReferences { /* @internal */ namespace ts.FindAllReferences.Core { /** Core find-all-references algorithm. Handles special cases before delegating to `getReferencedSymbolsForSymbol`. */ - export function getReferencedSymbolsForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options: Options = {}, sourceFilesSet: ReadonlyMap = arrayToSet(sourceFiles, f => f.fileName)): SymbolAndEntries[] | undefined { + export function getReferencedSymbolsForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options: Options = {}, sourceFilesSet: ReadonlyMap = arrayToSet(sourceFiles, f => f.fileName)): ReadonlyArray | undefined { if (isSourceFile(node)) { const reference = GoToDefinition.getReferenceAtPosition(node, position, program); const moduleSymbol = reference && program.getTypeChecker().getMergedSymbol(reference.file.symbol); @@ -368,7 +373,7 @@ namespace ts.FindAllReferences.Core { } const checker = program.getTypeChecker(); - let symbol = checker.getSymbolAtLocation(node); + const symbol = checker.getSymbolAtLocation(node); // Could not find a symbol e.g. unknown identifier if (!symbol) { @@ -380,23 +385,92 @@ namespace ts.FindAllReferences.Core { return getReferencedSymbolsForModule(program, symbol.parent!, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); } - let moduleReferences: SymbolAndEntries[] = emptyArray; - const moduleSourceFile = isModuleSymbol(symbol); - let referencedNode: Node | undefined = node; - if (moduleSourceFile) { - const exportEquals = symbol.exports!.get(InternalSymbolName.ExportEquals); - // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. - moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet); - if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) return moduleReferences; - // Continue to get references to 'export ='. - symbol = skipAlias(exportEquals, checker); - referencedNode = undefined; + const moduleReferences = getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet); + if (moduleReferences && !(symbol.flags & SymbolFlags.Transient)) { + return moduleReferences; } - return concatenate(moduleReferences, getReferencedSymbolsForSymbol(symbol, referencedNode, sourceFiles, sourceFilesSet, checker, cancellationToken, options)); + + const aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(node, symbol, checker); + const moduleReferencesOfExportTarget = aliasedSymbol && + getReferencedSymbolsForModuleIfDeclaredBySourceFile(aliasedSymbol, program, sourceFiles, cancellationToken, options, sourceFilesSet); + + const references = getReferencedSymbolsForSymbol(symbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options); + return mergeReferences(program, moduleReferences, references, moduleReferencesOfExportTarget); } - function isModuleSymbol(symbol: Symbol): SourceFile | undefined { - return symbol.flags & SymbolFlags.Module ? find(symbol.declarations, isSourceFile) : undefined; + function getMergedAliasedSymbolOfNamespaceExportDeclaration(node: Node, symbol: Symbol, checker: TypeChecker) { + if (node.parent && isNamespaceExportDeclaration(node.parent)) { + const aliasedSymbol = checker.getAliasedSymbol(symbol); + const targetSymbol = checker.getMergedSymbol(aliasedSymbol); + if (aliasedSymbol !== targetSymbol) { + return targetSymbol; + } + } + return undefined; + } + + function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol: Symbol, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options: Options, sourceFilesSet: ReadonlyMap) { + const moduleSourceFile = symbol.flags & SymbolFlags.Module ? find(symbol.declarations, isSourceFile) : undefined; + if (!moduleSourceFile) return undefined; + const exportEquals = symbol.exports!.get(InternalSymbolName.ExportEquals); + // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. + const moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet); + if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) return moduleReferences; + // Continue to get references to 'export ='. + const checker = program.getTypeChecker(); + symbol = skipAlias(exportEquals, checker); + return mergeReferences(program, moduleReferences, getReferencedSymbolsForSymbol(symbol, /*node*/ undefined, sourceFiles, sourceFilesSet, checker, cancellationToken, options)); + } + + function mergeReferences(program: Program, ...referencesToMerge: (SymbolAndEntries[] | undefined)[]): SymbolAndEntries[] | undefined { + let result: SymbolAndEntries[] | undefined; + for (const references of referencesToMerge) { + if (!references || !references.length) continue; + if (!result) { + result = references; + continue; + } + for (const entry of references) { + if (!entry.definition || entry.definition.type !== DefinitionKind.Symbol) { + result.push(entry); + continue; + } + const symbol = entry.definition.symbol; + const refIndex = findIndex(result, ref => !!ref.definition && + ref.definition.type === DefinitionKind.Symbol && + ref.definition.symbol === symbol); + if (refIndex === -1) { + result.push(entry); + continue; + } + + const reference = result[refIndex]; + result[refIndex] = { + definition: reference.definition, + references: reference.references.concat(entry.references).sort((entry1, entry2) => { + const entry1File = getSourceFileIndexOfEntry(program, entry1); + const entry2File = getSourceFileIndexOfEntry(program, entry2); + if (entry1File !== entry2File) { + return compareValues(entry1File, entry2File); + } + + const entry1Span = getTextSpanOfEntry(entry1); + const entry2Span = getTextSpanOfEntry(entry2); + return entry1Span.start !== entry2Span.start ? + compareValues(entry1Span.start, entry2Span.start) : + compareValues(entry1Span.length, entry2Span.length); + }) + }; + } + } + return result; + } + + function getSourceFileIndexOfEntry(program: Program, entry: Entry) { + const sourceFile = entry.kind === EntryKind.Span ? + program.getSourceFile(entry.fileName)! : + entry.node.getSourceFile(); + return program.getSourceFiles().indexOf(sourceFile); } function getReferencedSymbolsForModule(program: Program, symbol: Symbol, excludeImportTypeOfExportEquals: boolean, sourceFiles: ReadonlyArray, sourceFilesSet: ReadonlyMap): SymbolAndEntries[] { @@ -435,7 +509,7 @@ namespace ts.FindAllReferences.Core { break; default: // This may be merged with something. - Debug.fail("Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); + Debug.assert(!!(symbol.flags & SymbolFlags.Transient), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } @@ -551,6 +625,8 @@ namespace ts.FindAllReferences.Core { // If the symbol is declared as part of a declaration like `{ type: "a" } | { type: "b" }`, use the property on the union type to get more references. return firstDefined(symbol.declarations, decl => { if (!decl.parent) { + // Ignore UMD module and global merge + if (symbol.flags & SymbolFlags.Transient) return undefined; // Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here. Debug.fail(`Unexpected symbol at ${Debug.showSyntaxKind(node)}: ${Debug.showSymbol(symbol)}`); } @@ -588,6 +664,12 @@ namespace ts.FindAllReferences.Core { Class, } + function getNonModuleSymbolOfMergedModuleSymbol(symbol: Symbol) { + if (!(symbol.flags & (SymbolFlags.Module | SymbolFlags.Transient))) return undefined; + const decl = symbol.declarations && find(symbol.declarations, d => !isSourceFile(d) && !isModuleDeclaration(d)); + return decl && decl.symbol; + } + /** * Holds all state needed for the finding references. * Unlike `Search`, there is only one `State`. @@ -648,7 +730,7 @@ namespace ts.FindAllReferences.Core { // The other two forms seem to be handled downstream (e.g. in `skipPastExportOrImportSpecifier`), so special-casing the first form // here appears to be intentional). const { - text = stripQuotes(unescapeLeadingUnderscores((getLocalSymbolForExportDefault(symbol) || symbol).escapedName)), + text = stripQuotes(unescapeLeadingUnderscores((getLocalSymbolForExportDefault(symbol) || getNonModuleSymbolOfMergedModuleSymbol(symbol) || symbol).escapedName)), allSearchSymbols = [symbol], } = searchOptions; const escapedText = escapeLeadingUnderscores(text); @@ -1573,6 +1655,13 @@ namespace ts.FindAllReferences.Core { if (res2) return res2; } + const aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(location, symbol, checker); + if (aliasedSymbol) { + // In case of UMD module and global merging, search for global as well + const res = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, EntryKind.Node); + if (res) return res; + } + const res = fromRoot(symbol); if (res) return res; diff --git a/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts b/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts new file mode 100644 index 00000000000..0964188f939 --- /dev/null +++ b/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts @@ -0,0 +1,43 @@ +/// + +// @Filename: /node_modules/@types/three/three-core.d.ts +////export class Vector3 { +//// constructor(x?: number, y?: number, z?: number); +//// x: number; +//// y: number; +////} + +// @Filename: /node_modules/@types/three/index.d.ts +////export * from "./three-core"; +////export as namespace [|{| "isWriteAccess": true, "isDefinition": true |}THREE|]; + +// @Filename: /typings/global.d.ts +////import * as _THREE from '[|three|]'; +////declare global { +//// const [|{| "isWriteAccess": true, "isDefinition": true |}THREE|]: typeof _THREE; +////} + +// @Filename: /src/index.ts +////export const a = {}; +////let v = new [|THREE|].Vector2(); + +// @Filename: /tsconfig.json +////{ +//// "compilerOptions": { +//// "esModuleInterop": true, +//// "outDir": "./build/js/", +//// "noImplicitAny": true, +//// "module": "es6", +//// "target": "es6", +//// "allowJs": true, +//// "skipLibCheck": true, +//// "lib": ["es2016", "dom"], +//// "typeRoots": ["node_modules/@types/"], +//// "types": ["three"] +//// }, +//// "files": ["/src/index.ts", "typings/global.d.ts"] +////} + +// TODO:: this should be var THREE: typeof import instead of module name as var but thats existing issue and repros with quickInfo too. +verify.singleReferenceGroup(`module "/node_modules/@types/three/index" +var "/node_modules/@types/three/index": typeof import("/node_modules/@types/three/index")`); \ No newline at end of file From 76b78a4df5058708bf47ce33c57d0721ef6ce46e Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 22 Jan 2019 15:02:30 -0800 Subject: [PATCH 61/88] Fix crash in signatureHelp --- src/services/signatureHelp.ts | 2 +- src/tsserver/server.ts | 4 ++++ tests/cases/fourslash/signatureHelpAtEOF2.ts | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/signatureHelpAtEOF2.ts diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index d63e16ce801..27ed0b6dc24 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -452,7 +452,7 @@ namespace ts.SignatureHelp { } function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile, checker: TypeChecker, isManuallyInvoked: boolean): ArgumentListInfo | undefined { - for (let n = node; isManuallyInvoked || (!isBlock(n) && !isSourceFile(n)); n = n.parent) { + for (let n = node; !isSourceFile(n) && (isManuallyInvoked || !isBlock(n)); n = n.parent) { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. Debug.assert(rangeContainsRange(n.parent, n), "Not a subspan", () => `Child: ${Debug.showSyntaxKind(n)}, parent: ${Debug.showSyntaxKind(n.parent)}`); diff --git a/src/tsserver/server.ts b/src/tsserver/server.ts index e5820260d5f..ccc681cd96e 100644 --- a/src/tsserver/server.ts +++ b/src/tsserver/server.ts @@ -967,4 +967,8 @@ namespace ts.server { (process as any).noAsar = true; // Start listening ioSession.listen(); + + if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) { + ts.sys.tryEnableSourceMapsForHost(); + } } diff --git a/tests/cases/fourslash/signatureHelpAtEOF2.ts b/tests/cases/fourslash/signatureHelpAtEOF2.ts new file mode 100644 index 00000000000..676ad2d0db6 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpAtEOF2.ts @@ -0,0 +1,6 @@ +/// + +////console.log() +/////**/ + +verify.noSignatureHelpForTriggerReason({ kind: "invoked" }, ""); From 60487dc7cb2f2d3425e686f9d934b1e2bbbfc04e Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 22 Jan 2019 15:25:14 -0800 Subject: [PATCH 62/88] Enable debug info by default when debugging the language server --- src/tsserver/server.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tsserver/server.ts b/src/tsserver/server.ts index ccc681cd96e..21146958748 100644 --- a/src/tsserver/server.ts +++ b/src/tsserver/server.ts @@ -968,6 +968,10 @@ namespace ts.server { // Start listening ioSession.listen(); + if (Debug.isDebugging) { + Debug.enableDebugInfo(); + } + if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) { ts.sys.tryEnableSourceMapsForHost(); } From e1477b41b7b82bb456fb94f878fba44233f213d1 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 22 Jan 2019 16:28:00 -0800 Subject: [PATCH 63/88] Fix lint error --- 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 d38111efa1e..d0d9a2b0766 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25536,7 +25536,7 @@ namespace ts { const property = getPropertyOfType(parentType, nameText); 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); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === SyntaxKind.SuperKeyword, parentType, property); } } } From d42185373aed23049f2efb64843c13c74e92ab9e Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 23 Jan 2019 10:45:20 -0800 Subject: [PATCH 64/88] PR feedback --- src/services/findAllReferences.ts | 3 +++ .../cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index b3c62c2085c..52f3277574e 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -422,6 +422,9 @@ namespace ts.FindAllReferences.Core { return mergeReferences(program, moduleReferences, getReferencedSymbolsForSymbol(symbol, /*node*/ undefined, sourceFiles, sourceFilesSet, checker, cancellationToken, options)); } + /** + * Merges the references by sorting them (by file index in sourceFiles and their location in it) that point to same definition symbol + */ function mergeReferences(program: Program, ...referencesToMerge: (SymbolAndEntries[] | undefined)[]): SymbolAndEntries[] | undefined { let result: SymbolAndEntries[] | undefined; for (const references of referencesToMerge) { diff --git a/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts b/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts index 0964188f939..464dcef1548 100644 --- a/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts +++ b/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts @@ -38,6 +38,7 @@ //// "files": ["/src/index.ts", "typings/global.d.ts"] ////} +// GH#29533 // TODO:: this should be var THREE: typeof import instead of module name as var but thats existing issue and repros with quickInfo too. verify.singleReferenceGroup(`module "/node_modules/@types/three/index" var "/node_modules/@types/three/index": typeof import("/node_modules/@types/three/index")`); \ No newline at end of file From 41568ba7c6ddaf492ba9b927cb6f206fd8a59d59 Mon Sep 17 00:00:00 2001 From: Chris Patterson Date: Wed, 23 Jan 2019 14:16:23 -0500 Subject: [PATCH 65/88] Updating badge url Updating the badge url to use the new url format. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a7222668ada..57c2a54385d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Build Status](https://travis-ci.org/Microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/Microsoft/TypeScript) -[![VSTS Build Status](https://typescript.visualstudio.com/_apis/public/build/definitions/cf7ac146-d525-443c-b23c-0d58337efebc/4/badge)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=4&view=logs) +[![VSTS Build Status](https://dev.azure.com/typescript/TypeScript/_apis/build/status/Typescript/node10)](https://https://dev.azure.com/typescript/TypeScript/_build/latest?definitionId=4&view=logs) [![npm version](https://badge.fury.io/js/typescript.svg)](https://www.npmjs.com/package/typescript) [![Downloads](https://img.shields.io/npm/dm/typescript.svg)](https://www.npmjs.com/package/typescript) From d7601b755f7f988c75aee371f4319dc8bdf337ef Mon Sep 17 00:00:00 2001 From: xiaofa Date: Thu, 24 Jan 2019 18:16:34 +0800 Subject: [PATCH 66/88] fix trailing comma should not allowed in dynamic import argument --- src/compiler/checker.ts | 2 +- .../reference/dynamicImportTrailingComma.errors.txt | 8 ++++++++ tests/baselines/reference/dynamicImportTrailingComma.js | 7 +++++++ .../reference/dynamicImportTrailingComma.symbols | 7 +++++++ .../baselines/reference/dynamicImportTrailingComma.types | 9 +++++++++ tests/cases/compiler/dynamicImportTrailingComma.ts | 4 ++++ 6 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/dynamicImportTrailingComma.errors.txt create mode 100644 tests/baselines/reference/dynamicImportTrailingComma.js create mode 100644 tests/baselines/reference/dynamicImportTrailingComma.symbols create mode 100644 tests/baselines/reference/dynamicImportTrailingComma.types create mode 100644 tests/cases/compiler/dynamicImportTrailingComma.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac069d95fac..3a6d58db31c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -31178,7 +31178,7 @@ namespace ts { if (nodeArguments.length !== 1) { return grammarErrorOnNode(node, Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument); } - + checkGrammarForDisallowedTrailingComma(nodeArguments); // see: parseArgumentOrArrayLiteralElement...we use this function which parse arguments of callExpression to parse specifier for dynamic import. // parseArgumentOrArrayLiteralElement allows spread element to be in an argument list which is not allowed as specifier in dynamic import. if (isSpreadElement(nodeArguments[0])) { diff --git a/tests/baselines/reference/dynamicImportTrailingComma.errors.txt b/tests/baselines/reference/dynamicImportTrailingComma.errors.txt new file mode 100644 index 00000000000..fbae6f2c6ba --- /dev/null +++ b/tests/baselines/reference/dynamicImportTrailingComma.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/dynamicImportTrailingComma.ts(2,12): error TS1009: Trailing comma not allowed. + + +==== tests/cases/compiler/dynamicImportTrailingComma.ts (1 errors) ==== + const path = './foo'; + import(path,); + ~ +!!! error TS1009: Trailing comma not allowed. \ No newline at end of file diff --git a/tests/baselines/reference/dynamicImportTrailingComma.js b/tests/baselines/reference/dynamicImportTrailingComma.js new file mode 100644 index 00000000000..bbbc9794af7 --- /dev/null +++ b/tests/baselines/reference/dynamicImportTrailingComma.js @@ -0,0 +1,7 @@ +//// [dynamicImportTrailingComma.ts] +const path = './foo'; +import(path,); + +//// [dynamicImportTrailingComma.js] +var path = './foo'; +Promise.resolve().then(function () { return require(path); }); diff --git a/tests/baselines/reference/dynamicImportTrailingComma.symbols b/tests/baselines/reference/dynamicImportTrailingComma.symbols new file mode 100644 index 00000000000..082c026613a --- /dev/null +++ b/tests/baselines/reference/dynamicImportTrailingComma.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/dynamicImportTrailingComma.ts === +const path = './foo'; +>path : Symbol(path, Decl(dynamicImportTrailingComma.ts, 0, 5)) + +import(path,); +>path : Symbol(path, Decl(dynamicImportTrailingComma.ts, 0, 5)) + diff --git a/tests/baselines/reference/dynamicImportTrailingComma.types b/tests/baselines/reference/dynamicImportTrailingComma.types new file mode 100644 index 00000000000..bb6c3966619 --- /dev/null +++ b/tests/baselines/reference/dynamicImportTrailingComma.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/dynamicImportTrailingComma.ts === +const path = './foo'; +>path : "./foo" +>'./foo' : "./foo" + +import(path,); +>import(path,) : Promise +>path : "./foo" + diff --git a/tests/cases/compiler/dynamicImportTrailingComma.ts b/tests/cases/compiler/dynamicImportTrailingComma.ts new file mode 100644 index 00000000000..de6aa6010b5 --- /dev/null +++ b/tests/cases/compiler/dynamicImportTrailingComma.ts @@ -0,0 +1,4 @@ +// @skipLibCheck: true +// @lib: es6 +const path = './foo'; +import(path,); \ No newline at end of file From 331b9bcfde86453d0e3d68126fc5c9fc46160591 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Thu, 24 Jan 2019 10:20:17 +0000 Subject: [PATCH 67/88] Use the correct source when skipping trivia A custom `SourceMapSource` can optionally provide its own `skipTrivia` function. If this is not provided then the compiler will use the default function designed for TypeScript source files. Previously, when calling this default function we were passing the current `sourceMapSource` rather than the specified `source` whose trivia needs to be skipped. This resulted in the `pos` being incorrectly calculated for external source files that need mapping. **Side note:** There are actually two possible constructors available for creating `SourceMapSource` objects. One of them defaults to an identity function for the `skipTrivia` function if it is not provided (see https://github.com/Microsoft/TypeScript/blob/49689894d747714d6b2b8461b9033020efec9625/src/compiler/utilities.ts#L6972-L6976) and the other one leaves the `skipTrivia` field `undefined` (see https://github.com/Microsoft/TypeScript/blob/5fc8f1dd801dbacfe7e2d624f80b7a6a3868d180/src/services/services.ts#L776-L797) Unfortunately, it appears that the second of these two constructors is the one available when importing the "typescript" module in node.js code. --- src/compiler/emitter.ts | 4 +-- src/testRunner/unittests/customTransforms.ts | 29 +++++++++++++++++++ .../skipTriviaExternalSourceFiles.js | 6 ++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/customTransforms/skipTriviaExternalSourceFiles.js diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 395f6448890..afc2a025da5 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4372,10 +4372,10 @@ namespace ts { } /** - * Skips trivia such as comments and white-space that can optionally overriden by the source map source + * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source */ function skipSourceTrivia(source: SourceMapSource, pos: number): number { - return source.skipTrivia ? source.skipTrivia(pos) : skipTrivia(sourceMapSource.text, pos); + return source.skipTrivia ? source.skipTrivia(pos) : skipTrivia(source.text, pos); } /** diff --git a/src/testRunner/unittests/customTransforms.ts b/src/testRunner/unittests/customTransforms.ts index aef9ed745ec..0ac14341342 100644 --- a/src/testRunner/unittests/customTransforms.ts +++ b/src/testRunner/unittests/customTransforms.ts @@ -129,5 +129,34 @@ namespace ts { }, { sourceMap: true } ); + + emitsCorrectly("skipTriviaExternalSourceFiles", + [ + { + file: "source.ts", + // The source file contains preceding trivia (e.g. whitespace) to try to confuse the `skipSourceTrivia` function. + text: " original;" + }, + ], + { + before: [ + context => node => visitNode(node, function visitor(node: Node): Node { + if (isIdentifier(node) && node.text === "original") { + const newNode = createIdentifier("changed"); + setSourceMapRange(newNode, { + pos: 0, + end: 7, + // Do not provide a custom skipTrivia function for `source`. + source: createSourceMapSource("another.html", "changed;") + }); + return newNode; + } + return visitEachChild(node, visitor, context); + }) + ] + }, + { sourceMap: true } + ); + }); } diff --git a/tests/baselines/reference/customTransforms/skipTriviaExternalSourceFiles.js b/tests/baselines/reference/customTransforms/skipTriviaExternalSourceFiles.js new file mode 100644 index 00000000000..8c7fecf97f0 --- /dev/null +++ b/tests/baselines/reference/customTransforms/skipTriviaExternalSourceFiles.js @@ -0,0 +1,6 @@ +// [source.js.map] +{"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts","another.html"],"names":[],"mappings":"ACAA,OAAO,CDAW"} + +// [source.js] +changed; +//# sourceMappingURL=source.js.map \ No newline at end of file From 387201cda07a791c6df6b9768f455d49553886cd Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Thu, 24 Jan 2019 09:27:32 -0800 Subject: [PATCH 68/88] Update user baselines (#29560) --- tests/baselines/reference/user/antd.log | 13 + tests/baselines/reference/user/bluebird.log | 1 + .../user/chrome-devtools-frontend.log | 361 +++++++----------- tests/baselines/reference/user/lodash.log | 1 - 4 files changed, 153 insertions(+), 223 deletions(-) create mode 100644 tests/baselines/reference/user/antd.log diff --git a/tests/baselines/reference/user/antd.log b/tests/baselines/reference/user/antd.log new file mode 100644 index 00000000000..48db08868d6 --- /dev/null +++ b/tests/baselines/reference/user/antd.log @@ -0,0 +1,13 @@ +Exit Code: 1 +Standard output: +node_modules/antd/lib/tree-select/interface.d.ts(26,18): error TS2430: Interface 'TreeSelectProps' incorrectly extends interface 'AbstractSelectProps'. + Types of property 'getPopupContainer' are incompatible. + Type '((triggerNode: Element) => HTMLElement) | undefined' is not assignable to type '((triggerNode?: Element | undefined) => HTMLElement) | undefined'. + Type '(triggerNode: Element) => HTMLElement' is not assignable to type '(triggerNode?: Element | undefined) => HTMLElement'. + Types of parameters 'triggerNode' and 'triggerNode' are incompatible. + Type 'Element | undefined' is not assignable to type 'Element'. + Type 'undefined' is not assignable to type 'Element'. + + + +Standard error: diff --git a/tests/baselines/reference/user/bluebird.log b/tests/baselines/reference/user/bluebird.log index a9ad6492545..b4b251e188c 100644 --- a/tests/baselines/reference/user/bluebird.log +++ b/tests/baselines/reference/user/bluebird.log @@ -161,6 +161,7 @@ node_modules/bluebird/js/release/some.js(133,23): error TS2339: Property 'promis node_modules/bluebird/js/release/using.js(78,20): error TS2339: Property 'doDispose' does not exist on type 'Disposer'. node_modules/bluebird/js/release/using.js(97,23): error TS2339: Property 'data' does not exist on type 'FunctionDisposer'. node_modules/bluebird/js/release/using.js(223,15): error TS2350: Only a void function can be called with the 'new' keyword. +node_modules/bluebird/js/release/util.js(200,32): error TS2339: Property 'foo' does not exist on type 'FakeConstructor'. node_modules/bluebird/js/release/util.js(279,45): error TS2345: Argument of type 'PropertyDescriptor | { value: any; } | undefined' is not assignable to parameter of type 'PropertyDescriptor & ThisType'. Type 'undefined' is not assignable to type 'PropertyDescriptor & ThisType'. Type 'undefined' is not assignable to type 'PropertyDescriptor'. diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 04d5703e1e1..96c4eb1ff6d 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -3107,13 +3107,12 @@ node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(60 Type '(debuggerModel: DebuggerModel) => void' is not assignable to type '(model: T) => void'. Types of parameters 'debuggerModel' and 'model' are incompatible. Type 'T' is not assignable to type 'DebuggerModel'. -node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(97,52): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(120,52): error TS2339: Property 'valuesArray' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(123,34): error TS2339: Property 'clear' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(153,34): error TS2339: Property 'deleteAll' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(97,56): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(122,22): error TS2339: Property 'remove' does not exist on type 'V'. +node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(153,44): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(158,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(166,22): error TS2694: Namespace 'Common' has no exported member 'Event'. -node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(181,38): error TS2339: Property 'set' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(181,42): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(183,45): error TS2339: Property 'remove' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(237,46): error TS2339: Property 'valuesArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(300,73): error TS2339: Property 'valuesArray' does not exist on type 'Map>'. @@ -3122,7 +3121,7 @@ node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(32 node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(330,43): error TS2339: Property 'keysArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(350,58): error TS2339: Property 'keysArray' does not exist on type 'Map>>'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(396,17): error TS2339: Property 'remove' does not exist on type 'Breakpoint[]'. -node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(399,34): error TS2339: Property 'delete' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(399,41): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(442,23): error TS2339: Property 'remove' does not exist on type 'Breakpoint[]'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(444,23): error TS2339: Property 'remove' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(446,19): error TS2339: Property 'remove' does not exist on type 'Map>'. @@ -3158,19 +3157,18 @@ node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js( node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(126,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(132,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(160,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(169,23): error TS2339: Property 'set' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(172,30): error TS2339: Property 'set' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(182,23): error TS2339: Property 'delete' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(184,30): error TS2339: Property 'delete' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(191,42): error TS2339: Property 'get' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(169,27): error TS2345: Argument of type 'CSSStyleSheetHeader' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(172,34): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(182,48): error TS2345: Argument of type 'LiveLocation' is not assignable to parameter of type 'V'. +node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(184,37): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(191,46): error TS2345: Argument of type 'CSSStyleSheetHeader' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(196,22): error TS2694: Namespace 'Common' has no exported member 'Event'. -node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(203,49): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(205,23): error TS2339: Property 'set' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(208,28): error TS2339: Property 'deleteAll' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(204,16): error TS2339: Property '_header' does not exist on type 'V'. +node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(205,27): error TS2345: Argument of type 'CSSStyleSheetHeader' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(206,16): error TS2339: Property 'update' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(212,22): error TS2694: Namespace 'Common' has no exported member 'Event'. -node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(216,42): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(218,30): error TS2339: Property 'set' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(221,21): error TS2339: Property 'deleteAll' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(216,46): error TS2345: Argument of type 'CSSStyleSheetHeader' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(221,31): error TS2345: Argument of type 'CSSStyleSheetHeader' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(261,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/bindings/CompilerScriptMapping.js(184,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/bindings/CompilerScriptMapping.js(194,22): error TS2694: Namespace 'Common' has no exported member 'Event'. @@ -3197,9 +3195,9 @@ node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBindin node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(207,34): error TS2339: Property 'valuesArray' does not exist on type 'Set'. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(230,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(267,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(276,21): error TS2339: Property 'set' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(285,21): error TS2339: Property 'delete' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(292,42): error TS2339: Property 'get' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(276,25): error TS2345: Argument of type 'Script' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(285,28): error TS2345: Argument of type 'Script' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(292,46): error TS2345: Argument of type 'Script' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(349,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(389,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(452,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. @@ -3326,7 +3324,7 @@ node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(14 node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(155,44): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(156,45): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(162,53): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. -node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(181,28): error TS2339: Property 'DiffState' does not exist on type '(config: any, parserConfig: { diffRows: any[]; baselineLines: string[]; currentLines: string[]; mimeType: string; }) => { startState: () => any; token: (arg0: { backUp: (n: any) => void; column: () => void; current: () => void; ... 10 more ...; sol: () => void; } & StringStream, arg1: any) => string; blankLine: (arg...'. +node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(181,28): error TS2339: Property 'DiffState' does not exist on type '(config: any, parserConfig: { diffRows: any[]; baselineLines: string[]; currentLines: string[]; mimeType: string; }) => { startState: () => any; token: (arg0: StringStream & { backUp: (n: any) => void; column: () => void; ... 11 more ...; sol: () => void; }, arg1: any) => string; blankLine: (arg0: any) => string; co...'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesSidebar.js(30,90): error TS2339: Property 'uiSourceCode' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesSidebar.js(38,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesView.js(26,44): error TS2694: Namespace 'Changes.ChangesView' has no exported member 'Row'. @@ -3727,7 +3725,7 @@ node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(20,29): error TS2694: Namespace 'Common.Renderer' has no exported member 'Options'. node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(27,15): error TS2339: Property 'runtime' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(40,17): error TS2300: Duplicate identifier 'Options'. -node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(40,17): error TS2339: Property 'Options' does not exist on type '{ (): void; prototype: { render(object: any, options: any): Promise; }; renderPromise(object: any, options?: any): Promise; }'. +node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(40,17): error TS2339: Property 'Options' does not exist on type 'typeof Renderer'. node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(63,15): error TS2339: Property 'runtime' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(81,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(105,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. @@ -3744,12 +3742,10 @@ node_modules/chrome-devtools-frontend/front_end/common/Object.js(122,76): error node_modules/chrome-devtools-frontend/front_end/common/Object.js(124,15): error TS2339: Property '_listenerCallbackTuple' does not exist on type 'typeof Object'. node_modules/chrome-devtools-frontend/front_end/common/Object.js(132,112): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/common/Object.js(132,129): error TS2694: Namespace 'Common' has no exported member 'Event'. -node_modules/chrome-devtools-frontend/front_end/common/Object.js(134,20): error TS2339: Property 'EventDescriptor' does not exist on type '{ (): void; removeEventListeners(eventList: any[]): void; prototype: { addEventListener(eventType: symbol, listener: (arg0: any) => any, thisObject?: any): any; once(eventType: symbol): Promise<...>; removeEventListener(eventType: symbol, listener: (arg0: any) => any, thisObject?: any): void; hasEventListeners(event...'. +node_modules/chrome-devtools-frontend/front_end/common/Object.js(134,20): error TS2339: Property 'EventDescriptor' does not exist on type 'typeof EventTarget'. node_modules/chrome-devtools-frontend/front_end/common/Object.js(137,39): error TS2694: Namespace 'Common.EventTarget' has no exported member 'EventDescriptor'. -node_modules/chrome-devtools-frontend/front_end/common/Object.js(151,31): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/common/Object.js(153,35): error TS2694: Namespace 'Common.EventTarget' has no exported member 'EventDescriptor'. node_modules/chrome-devtools-frontend/front_end/common/Object.js(159,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -node_modules/chrome-devtools-frontend/front_end/common/Object.js(165,31): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/common/Object.js(172,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/common/OutputStream.js(13,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(122,26): error TS2339: Property '_urlRegexInstance' does not exist on type 'typeof ParsedURL'. @@ -4435,8 +4431,8 @@ node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(416 node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(461,42): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(470,51): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(489,49): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(50,68): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(115,45): error TS2339: Property 'set' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(50,72): error TS2345: Argument of type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(115,72): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'V'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(135,32): error TS2694: Namespace 'Coverage' has no exported member 'RawLocation'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(169,16): error TS2403: Subsequent variable declarations must have the same type. Variable 'location' must be of type 'Location', but here has type 'CSSLocation'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(170,31): error TS2339: Property 'header' does not exist on type 'Location'. @@ -6126,17 +6122,12 @@ node_modules/chrome-devtools-frontend/front_end/event_listeners/EventListenersVi node_modules/chrome-devtools-frontend/front_end/event_listeners/EventListenersView.js(321,13): error TS2339: Property 'consume' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(93,12): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(149,19): error TS1110: Type expected. -node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(186,12): error TS2339: Property '_fire' does not exist on type 'EventSinkImpl'. -node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(298,14): error TS2339: Property '_fire' does not exist on type 'EventSinkImpl'. -node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(300,14): error TS2339: Property '_fire' does not exist on type 'EventSinkImpl'. +node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(300,9): error TS2555: Expected at least 1 arguments, but got 0. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(314,12): error TS8022: JSDoc '@extends' is not attached to a class. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(371,12): error TS8022: JSDoc '@extends' is not attached to a class. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(381,12): error TS8022: JSDoc '@extends' is not attached to a class. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(391,12): error TS8022: JSDoc '@extends' is not attached to a class. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(429,12): error TS8022: JSDoc '@extends' is not attached to a class. -node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(529,12): error TS2339: Property '_fire' does not exist on type 'EventSinkImpl'. -node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(544,12): error TS2339: Property '_fire' does not exist on type 'EventSinkImpl'. -node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(551,12): error TS2339: Property '_fire' does not exist on type 'EventSinkImpl'. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(789,21): error TS2339: Property 'exposeWebInspectorNamespace' does not exist on type 'ExtensionDescriptor'. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(790,12): error TS2339: Property 'webInspector' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(798,12): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. @@ -6537,8 +6528,6 @@ node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapsho node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(918,34): error TS2345: Argument of type 'Uint32Array' is not assignable to parameter of type 'number[]'. Type 'Uint32Array' is missing the following properties from type 'number[]': pop, push, concat, shift, and 5 more. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(920,34): error TS2345: Argument of type 'Uint32Array' is not assignable to parameter of type 'number[]'. -node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1020,16): error TS2587: JSDoc type 'JSHeapSnapshotEdge' circularly references itself. -node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1028,16): error TS2587: JSDoc type 'JSHeapSnapshotRetainerEdge' circularly references itself. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1045,5): error TS2322: Type 'void' is not assignable to type 'HeapSnapshotNode'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1083,14): error TS2339: Property 'key' does not exist on type '(arg0: HeapSnapshotNode) => boolean'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1086,14): error TS2339: Property 'key' does not exist on type '(arg0: HeapSnapshotNode) => boolean'. @@ -6602,7 +6591,6 @@ node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapsho Types of property 'item' are incompatible. Type '() => HeapSnapshotEdge' is not assignable to type '() => { itemIndex(): number; serialize(): any; }'. Type 'HeapSnapshotEdge' is not assignable to type '{ itemIndex(): number; serialize(): any; }'. - Property '_snapshot' does not exist on type '{ itemIndex(): number; serialize(): any; }'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2283,13): error TS2339: Property 'nodeIndex' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2287,13): error TS2339: Property 'nodeIndex' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2322,28): error TS2339: Property 'sortRange' does not exist on type 'number[]'. @@ -6879,7 +6867,6 @@ node_modules/chrome-devtools-frontend/front_end/layer_viewer/LayerTreeOutline.js node_modules/chrome-devtools-frontend/front_end/layer_viewer/LayerTreeOutline.js(199,80): error TS2339: Property '_layer' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/LayerTreeOutline.js(222,11): error TS2339: Property 'createTextChild' does not exist on type 'DocumentFragment'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/LayerTreeOutline.js(223,25): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. -node_modules/chrome-devtools-frontend/front_end/layer_viewer/LayerViewHost.js(110,15): error TS2587: JSDoc type 'Layer' circularly references itself. node_modules/chrome-devtools-frontend/front_end/layer_viewer/LayerViewHost.js(125,84): error TS2339: Property 'scrollRectIndex' does not exist on type 'Selection'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/LayerViewHost.js(135,19): error TS2694: Namespace 'SDK' has no exported member 'SnapshotWithRect'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/LayerViewHost.js(149,34): error TS2339: Property '_snapshot' does not exist on type 'Selection'. @@ -8229,11 +8216,11 @@ node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(62,5) node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(176,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(218,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(323,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(326,43): error TS2339: Property 'set' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(326,47): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(331,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(334,43): error TS2339: Property 'delete' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(341,48): error TS2339: Property 'has' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(343,70): error TS2339: Property 'get' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(334,50): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(341,52): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(343,74): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/persistence/PersistenceActions.js(30,44): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/persistence/PersistenceActions.js(34,9): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/persistence/PersistenceActions.js(39,44): error TS2555: Expected at least 2 arguments, but got 1. @@ -8356,7 +8343,7 @@ node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry.js(28,41): error TS2694: Namespace 'ProductRegistry.Registry' has no exported member 'ProductEntry'. node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry.js(34,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry.js(55,41): error TS2694: Namespace 'ProductRegistry.Registry' has no exported member 'ProductEntry'. -node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry.js(72,26): error TS2339: Property 'ProductEntry' does not exist on type '{ (): void; prototype: { nameForUrl: (parsedUrl: ParsedURL) => string; entryForUrl: (parsedUrl: ParsedURL) => any; typeForUrl: (parsedUrl: ParsedURL) => number; }; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry.js(72,26): error TS2339: Property 'ProductEntry' does not exist on type 'typeof Registry'. node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1559,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1563,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1604,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. @@ -8752,7 +8739,6 @@ node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.j Type 'HeapSnapshotProviderProxy' is not assignable to type '{ dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. Property '_worker' does not exist on type '{ dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(804,15): error TS2577: Return type annotation circularly references itself. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(804,16): error TS2587: JSDoc type 'HeapSnapshotRetainingObjectNode' circularly references itself. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(871,36): error TS2339: Property 'withThousandsSeparator' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(874,34): error TS2339: Property 'withThousandsSeparator' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(892,3): error TS2416: Property 'createProvider' in type 'HeapSnapshotInstanceNode' is not assignable to the same property in base type 'HeapSnapshotGenericObjectNode'. @@ -9070,9 +9056,9 @@ node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(170 node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(194,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(201,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(202,20): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(205,38): error TS2339: Property 'Params' does not exist on type '{ (): void; prototype: { sendMessage(message: string): void; disconnect(): Promise; }; }'. +node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(205,38): error TS2339: Property 'Params' does not exist on type 'typeof Connection'. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(208,61): error TS2694: Namespace 'Protocol.InspectorBackend.Connection' has no exported member 'Params'. -node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(210,38): error TS2339: Property 'Factory' does not exist on type '{ (): void; prototype: { sendMessage(message: string): void; disconnect(): Promise; }; }'. +node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(210,38): error TS2339: Property 'Factory' does not exist on type 'typeof Connection'. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(217,53): error TS2694: Namespace 'Protocol.InspectorBackend.Connection' has no exported member 'Factory'. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(229,36): error TS2339: Property 'deprecatedRunAfterPendingDispatches' does not exist on type 'typeof InspectorBackend'. node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(230,33): error TS2339: Property 'deprecatedRunAfterPendingDispatches' does not exist on type 'typeof InspectorBackend'. @@ -9688,7 +9674,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/CSSStyleDeclaration.js(41,47 node_modules/chrome-devtools-frontend/front_end/sdk/CSSStyleDeclaration.js(50,24): error TS2694: Namespace 'Protocol' has no exported member 'CSS'. node_modules/chrome-devtools-frontend/front_end/sdk/CSSStyleSheetHeader.js(11,24): error TS2694: Namespace 'Protocol' has no exported member 'CSS'. node_modules/chrome-devtools-frontend/front_end/sdk/CSSStyleSheetHeader.js(40,5): error TS2322: Type 'StaticContentProvider' is not assignable to type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. - Property '_contentURL' does not exist on type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/sdk/Connections.js(10,52): error TS2694: Namespace 'Protocol.InspectorBackend.Connection' has no exported member 'Params'. node_modules/chrome-devtools-frontend/front_end/sdk/Connections.js(34,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sdk/Connections.js(41,22): error TS2694: Namespace 'Common' has no exported member 'Event'. @@ -9848,7 +9833,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(250,43): er node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(281,43): error TS2694: Namespace 'SDK.DebuggerModel' has no exported member 'SetBreakpointResult'. node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(304,43): error TS2694: Namespace 'SDK.DebuggerModel' has no exported member 'SetBreakpointResult'. node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(319,24): error TS2694: Namespace 'Protocol' has no exported member 'Debugger'. -node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(332,32): error TS2587: JSDoc type 'BreakLocation' circularly references itself. node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(346,24): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(347,34): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(355,24): error TS2694: Namespace 'Protocol' has no exported member 'Debugger'. @@ -9936,7 +9920,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/HeapProfilerModel.js(44,34): node_modules/chrome-devtools-frontend/front_end/sdk/LayerTreeBase.js(5,25): error TS2694: Namespace 'Protocol' has no exported member 'DOM'. node_modules/chrome-devtools-frontend/front_end/sdk/LayerTreeBase.js(18,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/sdk/LayerTreeBase.js(23,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -node_modules/chrome-devtools-frontend/front_end/sdk/LayerTreeBase.js(28,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/sdk/LayerTreeBase.js(33,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/sdk/LayerTreeBase.js(38,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/sdk/LayerTreeBase.js(45,12): error TS2502: 'child' is referenced directly or indirectly in its own type annotation. @@ -10067,7 +10050,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(812,57): e node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(812,108): error TS2694: Namespace 'SDK.MultitargetNetworkManager' has no exported member 'InterceptionPattern'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(827,21): error TS2339: Property 'sprintf' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(836,31): error TS2339: Property 'networkAgent' does not exist on type 'Target'. -node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(844,75): error TS2339: Property 'valuesArray' does not exist on type 'Multimap'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(855,32): error TS2339: Property 'networkAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(874,34): error TS2694: Namespace 'SDK.NetworkManager' has no exported member 'Conditions'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(884,35): error TS2694: Namespace 'SDK.NetworkManager' has no exported member 'Conditions'. @@ -10075,13 +10057,9 @@ node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(891,24): e node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(905,24): error TS2694: Namespace 'Protocol' has no exported member 'Network'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(955,42): error TS2694: Namespace 'SDK.NetworkManager' has no exported member 'BlockedPattern'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(976,41): error TS2694: Namespace 'SDK.NetworkManager' has no exported member 'BlockedPattern'. -node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(1015,46): error TS2339: Property 'size' does not exist on type 'Multimap'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(1019,52): error TS2694: Namespace 'SDK.MultitargetNetworkManager' has no exported member 'InterceptionPattern'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(1020,45): error TS2694: Namespace 'SDK.MultitargetNetworkManager' has no exported member 'RequestInterceptor'. -node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(1025,37): error TS2339: Property 'deleteAll' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(1027,39): error TS2339: Property 'set' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(1050,82): error TS2339: Property 'valuesArray' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(1059,68): error TS2339: Property 'keysArray' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(1060,13): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(1084,19): error TS2339: Property 'networkAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(1089,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(1101,35): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ [x: string]: string; }'. @@ -10433,7 +10411,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/ScreenCaptureModel.js(160,24 node_modules/chrome-devtools-frontend/front_end/sdk/Script.js(39,24): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/Script.js(143,52): error TS2339: Property 'debuggerAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/sdk/Script.js(159,5): error TS2322: Type 'StaticContentProvider' is not assignable to type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. - Property '_contentURL' does not exist on type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/sdk/Script.js(174,43): error TS2339: Property 'debuggerAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/sdk/Script.js(190,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/sdk/Script.js(190,50): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. @@ -10499,7 +10476,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(198,25): error node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(200,27): error TS2339: Property '_base64Map' does not exist on type 'typeof TextSourceMap'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(272,30): error TS2339: Property 'keysArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(284,7): error TS2322: Type 'StaticContentProvider' is not assignable to type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. - Property '_contentURL' does not exist on type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(285,5): error TS2322: Type 'CompilerSourceMappingContentProvider' is not assignable to type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. Property '_sourceURL' does not exist on type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(325,26): error TS2339: Property 'upperBound' does not exist on type 'SourceMapEntry[]'. @@ -10516,24 +10492,24 @@ node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(527,37): error node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(558,18): error TS2339: Property 'lowerBound' does not exist on type 'SourceMapEntry[]'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(559,29): error TS2339: Property 'upperBound' does not exist on type 'SourceMapEntry[]'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(52,22): error TS2694: Namespace 'Common' has no exported member 'Event'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(85,37): error TS2339: Property 'has' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(86,42): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(87,47): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(141,45): error TS2339: Property 'has' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(146,40): error TS2339: Property 'set' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(85,41): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(86,46): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(87,51): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(141,49): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(146,44): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(159,36): error TS2352: Conversion of type 'TextSourceMap' to type '{ compiledURL(): string; url(): string; sourceURLs(): string[]; sourceContentProvider(sourceURL: string, contentType: ResourceType): { contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise<...>; requestContent(): Promise<...>; searchInContent(query: string, caseSensitive: boolean, isRegex: boo...' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(159,36): error TS2352: Conversion of type 'TextSourceMap' to type '{ compiledURL(): string; url(): string; sourceURLs(): string[]; sourceContentProvider(sourceURL: string, contentType: ResourceType): { contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise<...>; requestContent(): Promise<...>; searchInContent(query: string, caseSensitive: boolean, isRegex: boo...' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property '_json' does not exist on type '{ compiledURL(): string; url(): string; sourceURLs(): string[]; sourceContentProvider(sourceURL: string, contentType: ResourceType): { contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise<...>; requestContent(): Promise<...>; searchInContent(query: string, caseSensitive: boolean, isRegex: boo...'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(163,12): error TS2339: Property 'catchException' does not exist on type 'Promise'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(173,56): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(174,42): error TS2339: Property 'deleteAll' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(193,35): error TS2339: Property 'set' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(173,60): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(174,52): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(193,39): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(208,39): error TS2339: Property 'runtime' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(210,31): error TS2339: Property 'containsAll' does not exist on type 'Set'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(227,38): error TS2339: Property 'hasValue' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(228,46): error TS2339: Property 'delete' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(232,33): error TS2339: Property 'delete' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(234,38): error TS2339: Property 'has' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(227,47): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(228,53): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(232,40): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(234,42): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/sdk/Target.js(16,52): error TS2694: Namespace 'Protocol.InspectorBackend.Connection' has no exported member 'Factory'. node_modules/chrome-devtools-frontend/front_end/sdk/Target.js(148,48): error TS2339: Property 'valuesArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/sdk/Target.js(159,53): error TS2345: Argument of type 'new (arg1: Target) => T' is not assignable to parameter of type 'new (arg1: Target) => SDKModel'. @@ -10621,7 +10597,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/TracingModel.js(576,43): err node_modules/chrome-devtools-frontend/front_end/sdk/TracingModel.js(576,55): error TS2339: Property 'ordinal' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/sdk/TracingModel.js(647,34): error TS2694: Namespace 'SDK.TracingManager' has no exported member 'EventPayload'. node_modules/chrome-devtools-frontend/front_end/sdk/TracingModel.js(649,15): error TS2577: Return type annotation circularly references itself. -node_modules/chrome-devtools-frontend/front_end/sdk/TracingModel.js(649,16): error TS2587: JSDoc type 'ObjectSnapshot' circularly references itself. node_modules/chrome-devtools-frontend/front_end/sdk/TracingModel.js(666,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/sdk/TracingModel.js(859,34): error TS2694: Namespace 'SDK.TracingManager' has no exported member 'EventPayload'. node_modules/chrome-devtools-frontend/front_end/sdk/TracingModel.js(870,5): error TS2322: Type 'NamedObject[]' is not assignable to type 'Thread[]'. @@ -10895,7 +10870,6 @@ node_modules/chrome-devtools-frontend/front_end/source_frame/JSONView.js(170,23) node_modules/chrome-devtools-frontend/front_end/source_frame/PreviewFactory.js(14,33): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/source_frame/ResourceSourceFrame.js(51,35): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/source_frame/SourceCodeDiff.js(15,22): error TS2339: Property 'installGutter' does not exist on type 'CodeMirrorTextEditor'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourceCodeDiff.js(18,24): error TS2587: JSDoc type 'TextEditorPositionHandle' circularly references itself. node_modules/chrome-devtools-frontend/front_end/source_frame/SourceCodeDiff.js(89,28): error TS2339: Property 'toggleLineClass' does not exist on type 'CodeMirrorTextEditor'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourceCodeDiff.js(110,25): error TS2694: Namespace 'Diff.Diff' has no exported member 'DiffArray'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourceCodeDiff.js(177,25): error TS2694: Namespace 'Diff.Diff' has no exported member 'DiffArray'. @@ -10911,54 +10885,16 @@ node_modules/chrome-devtools-frontend/front_end/source_frame/SourceFrame.js(435, node_modules/chrome-devtools-frontend/front_end/source_frame/SourceFrame.js(459,15): error TS2339: Property '__fromRegExpQuery' does not exist on type 'RegExp'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourceFrame.js(472,36): error TS2339: Property 'lowerBound' does not exist on type 'TextRange[]'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourceFrame.js(475,46): error TS2339: Property 'computeLineEndings' does not exist on type 'string'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(19,23): error TS2339: Property 'addKeyMap' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(23,23): error TS2339: Property 'on' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(24,23): error TS2339: Property 'on' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(25,23): error TS2339: Property 'on' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(26,23): error TS2339: Property 'on' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(27,23): error TS2339: Property 'on' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(28,23): error TS2339: Property 'on' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(31,23): error TS2339: Property 'addKeyMap' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(36,23): error TS2339: Property 'setOption' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(38,23): error TS2339: Property 'setOption' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(39,23): error TS2339: Property 'setOption' does not exist on type 'CodeMirror'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(45,12): error TS2339: Property '_isHandlingMouseDownEvent' does not exist on type 'SourcesTextEditor'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(54,20): error TS2694: Namespace 'UI' has no exported member 'AutocompleteConfig'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(90,14): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'number', but here has type 'string'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(93,29): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(134,12): error TS2339: Property '_tokenHighlighter' does not exist on type 'CodeMirrorTextEditor'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(140,23): error TS2339: Property 'operation' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(144,23): error TS2339: Property 'operation' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(168,30): error TS2339: Property 'markText' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(185,23): error TS2339: Property 'setOption' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(196,23): error TS2339: Property 'clearGutter' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(198,23): error TS2339: Property 'setOption' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(209,23): error TS2339: Property 'setGutterMarker' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(219,45): error TS2339: Property 'getLineHandle' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(224,23): error TS2339: Property 'addLineClass' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(228,44): error TS2339: Property 'getLine' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(237,37): error TS2339: Property 'getLine' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(239,55): error TS2339: Property 'markText' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(245,25): error TS2339: Property 'addLineClass' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(250,25): error TS2339: Property 'removeLineClass' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(258,25): error TS2339: Property 'removeLineClass' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(276,40): error TS2339: Property 'getLineHandle' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(281,25): error TS2339: Property 'addLineClass' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(282,25): error TS2339: Property 'addLineClass' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(284,25): error TS2339: Property 'removeLineClass' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(285,25): error TS2339: Property 'removeLineClass' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(295,38): error TS2339: Property 'lineInfo' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(360,25): error TS2339: Property 'setOption' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(361,25): error TS2339: Property 'setOption' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(363,25): error TS2339: Property 'setOption' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(364,25): error TS2339: Property 'setOption' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(373,23): error TS2339: Property 'setOption' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(393,27): error TS2339: Property 'replaceRange' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(409,25): error TS2339: Property 'operation' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(411,35): error TS2339: Property 'getCursor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(412,33): error TS2339: Property 'getCursor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(428,47): error TS2339: Property 'lineAtHeight' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(428,78): error TS2339: Property 'getScrollInfo' does not exist on type 'CodeMirror'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(237,57): error TS2339: Property 'length' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(262,9): error TS1345: An expression of type 'void' cannot be tested for truthiness +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(263,37): error TS2339: Property 'clear' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(296,30): error TS2339: Property 'wrapClass' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(414,99): error TS2345: Argument of type 'void' is not assignable to parameter of type 'Pos'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(445,15): error TS2339: Property '_isHandlingMouseDownEvent' does not exist on type 'SourcesTextEditor'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(561,13): error TS2339: Property '_codeMirrorWhitespaceStyleInjected' does not exist on type 'Document'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(563,9): error TS2339: Property '_codeMirrorWhitespaceStyleInjected' does not exist on type 'Document'. @@ -10966,17 +10902,22 @@ node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.j node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(594,31): error TS2339: Property 'GutterClickEventData' does not exist on type 'typeof SourcesTextEditor'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(614,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(622,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(631,14): error TS2339: Property 'operation' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(764,24): error TS2339: Property 'removeLineClass' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(769,24): error TS2339: Property 'addLineClass' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(780,51): error TS2339: Property 'markText' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(795,24): error TS2339: Property 'removeLineClass' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(797,43): error TS2339: Property 'getCursor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(798,41): error TS2339: Property 'getCursor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(803,39): error TS2339: Property 'getSelections' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(809,26): error TS2339: Property 'addLineClass' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(821,33): error TS2339: Property 'getLine' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(829,24): error TS2339: Property 'removeOverlay' does not exist on type 'CodeMirror'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(759,9): error TS1345: An expression of type 'void' cannot be tested for truthiness +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(760,32): error TS2339: Property 'clear' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(799,24): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(799,46): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(801,24): error TS2339: Property 'ch' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(801,44): error TS2339: Property 'ch' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(804,20): error TS2339: Property 'length' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(807,51): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(807,72): error TS2339: Property 'ch' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(807,89): error TS2339: Property 'ch' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(808,11): error TS1345: An expression of type 'void' cannot be tested for truthiness +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(809,54): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(810,93): error TS2345: Argument of type 'void' is not assignable to parameter of type 'Pos'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(822,79): error TS2339: Property 'charAt' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(823,41): error TS2339: Property 'length' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(823,88): error TS2339: Property 'charAt' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(839,9): error TS2367: This condition will always return 'false' since the types 'void' and 'number' have no overlap. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(854,9): error TS1345: An expression of type 'void' cannot be tested for truthiness node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(862,12): error TS1345: An expression of type 'void' cannot be tested for truthiness @@ -10989,7 +10930,6 @@ node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.j node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(878,12): error TS1345: An expression of type 'void' cannot be tested for truthiness node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(878,71): error TS2367: This condition will always return 'true' since the types 'void' and 'string' have no overlap. node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(882,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(887,22): error TS2339: Property 'addOverlay' does not exist on type 'CodeMirror'. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(39,35): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(42,53): error TS2345: Argument of type '0' is not assignable to parameter of type 'string'. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(54,59): error TS2345: Argument of type 'string' is not assignable to parameter of type 'SupportedType'. @@ -11119,12 +11059,13 @@ node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSid node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(34,34): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(41,27): error TS2339: Property 'removeChildren' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(42,47): error TS2339: Property 'createChild' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(53,24): error TS2339: Property 'set' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(64,45): error TS2339: Property 'keysArray' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(53,28): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(66,35): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(73,36): error TS2339: Property 'createChild' does not exist on type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(77,51): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(78,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'uiLocation' must be of type 'UILocation', but here has type 'any'. +node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(78,37): error TS2339: Property 'uiLocation' does not exist on type 'V'. +node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(80,71): error TS2339: Property 'uiLocation' does not exist on type 'V'. +node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(81,60): error TS2339: Property 'breakpoint' does not exist on type 'V'. +node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(82,62): error TS2339: Property 'breakpoint' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(87,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(92,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(119,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. @@ -11192,8 +11133,6 @@ node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(969,32): error TS2339: Property '__nameToToken' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(969,65): error TS2339: Property '__nameToToken' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(974,49): error TS2339: Property '__nameToToken' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1036,67): error TS2339: Property 'lineNumber' does not exist on type '{ lineNumber: number; columnNumber: number; } | {}'. - Property 'lineNumber' does not exist on type '{}'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1150,11): error TS2339: Property 'consume' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1152,17): error TS2339: Property 'shiftKey' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1169,11): error TS2339: Property 'consume' does not exist on type 'Event'. @@ -11203,7 +11142,7 @@ node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1190,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1201,56): error TS2339: Property 'valuesArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1210,22): error TS2694: Namespace 'Common' has no exported member 'Event'. -node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1270,16): error TS2403: Subsequent variable declarations must have the same type. Variable 'location' must be of type '{ lineNumber: number; columnNumber: number; }', but here has type 'UILocation'. +node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1270,16): error TS2403: Subsequent variable declarations must have the same type. Variable 'location' must be of type 'any', but here has type 'UILocation'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1286,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1326,60): error TS2339: Property 'valuesArray' does not exist on type 'Set'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1400,31): error TS2555: Expected at least 2 arguments, but got 1. @@ -11225,28 +11164,31 @@ node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(145,21) node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(167,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(175,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(183,22): error TS2694: Namespace 'Common' has no exported member 'Event'. -node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(189,48): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(192,51): error TS2339: Property 'get' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(189,52): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(191,19): error TS2339: Property 'updateTitle' does not exist on type 'V'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(192,55): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(194,22): error TS2339: Property 'updateTitle' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(212,22): error TS2339: Property 'updateTitle' does not exist on type 'NavigatorTreeNode'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(262,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(275,22): error TS2694: Namespace 'Common' has no exported member 'Event'. -node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(283,51): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(336,29): error TS2339: Property 'set' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(283,55): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(336,33): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(346,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(354,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(388,58): error TS2339: Property 'reverse' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(499,29): error TS2339: Property '_boostOrder' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(527,28): error TS2339: Property '_boostOrder' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(578,14): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(592,41): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(623,41): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(633,29): error TS2339: Property 'delete' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(592,45): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(593,22): error TS2339: Property 'firstValue' does not exist on type 'Set'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(623,45): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(625,36): error TS2345: Argument of type 'V' is not assignable to parameter of type 'NavigatorUISourceCodeTreeNode'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(633,36): error TS2345: Argument of type 'UISourceCode' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(638,27): error TS2339: Property 'parent' does not exist on type 'NavigatorUISourceCodeTreeNode'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(643,25): error TS2339: Property 'parent' does not exist on type 'NavigatorUISourceCodeTreeNode'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(655,93): error TS2339: Property '_folderPath' does not exist on type '(NavigatorUISourceCodeTreeNode & NavigatorGroupTreeNode) | (NavigatorUISourceCodeTreeNode & NavigatorFolderTreeNode)'. Property '_folderPath' does not exist on type 'NavigatorUISourceCodeTreeNode & NavigatorGroupTreeNode'. -node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(663,46): error TS2339: Property 'valuesArray' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(667,29): error TS2339: Property 'clear' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(664,12): error TS2339: Property 'dispose' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(705,40): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(717,39): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(734,11): error TS2555: Expected at least 2 arguments, but got 1. @@ -11482,7 +11424,6 @@ node_modules/chrome-devtools-frontend/front_end/sources/UISourceCodeFrame.js(443 node_modules/chrome-devtools-frontend/front_end/sources/UISourceCodeFrame.js(461,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/UISourceCodeFrame.js(469,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/UISourceCodeFrame.js(483,10): error TS2339: Property 'runtime' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/sources/UISourceCodeFrame.js(488,40): error TS2339: Property 'operation' does not exist on type 'CodeMirror'. node_modules/chrome-devtools-frontend/front_end/sources/UISourceCodeFrame.js(496,32): error TS2339: Property 'runtime' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/sources/UISourceCodeFrame.js(511,24): error TS2339: Property 'pushAll' does not exist on type 'ToolbarItem[]'. node_modules/chrome-devtools-frontend/front_end/sources/UISourceCodeFrame.js(512,25): error TS2339: Property 'pushAll' does not exist on type 'any[]'. @@ -11791,16 +11732,10 @@ node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(47,35): error TS2339: Property 'CodeMirror' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(165,18): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(169,67): error TS2694: Namespace 'TextEditor.CodeMirrorTextEditor' has no exported member 'Decoration'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(198,45): error TS2339: Property '_codeMirrorTextEditor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(207,16): error TS2339: Property '_codeMirrorTextEditor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(214,16): error TS2339: Property '_codeMirrorTextEditor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(222,16): error TS2339: Property '_codeMirrorTextEditor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(230,16): error TS2339: Property '_codeMirrorTextEditor' does not exist on type 'CodeMirror'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(251,22): error TS2339: Property 'name' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(252,22): error TS2339: Property 'token' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(252,70): error TS2339: Property 'token' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(270,27): error TS2339: Property 'runtime' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(356,16): error TS2339: Property 'addKeyMap' does not exist on type 'CodeMirror'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(395,29): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(449,60): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(557,9): error TS2339: Property 'consume' does not exist on type 'Event'. @@ -11809,44 +11744,32 @@ node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(602,30): error TS2339: Property 'isSelfOrDescendant' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(735,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(796,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(842,23): error TS2339: Property 'set' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(842,27): error TS2345: Argument of type 'number' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(855,13): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(856,13): error TS2339: Property 'style' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(863,23): error TS2339: Property 'get' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(863,27): error TS2345: Argument of type 'number' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(866,49): error TS2694: Namespace 'TextEditor.CodeMirrorTextEditor' has no exported member 'Decoration'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(879,23): error TS2339: Property 'get' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(879,27): error TS2345: Argument of type 'number' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(883,49): error TS2694: Namespace 'TextEditor.CodeMirrorTextEditor' has no exported member 'Decoration'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(889,25): error TS2339: Property 'delete' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(889,32): error TS2345: Argument of type 'number' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(899,25): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(902,27): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(955,5): error TS2322: Type 'string' is not assignable to type 'number'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(956,18): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(968,62): error TS2339: Property 'offsetTop' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1038,34): error TS2694: Namespace 'CodeMirror' has no exported member 'ChangeObject'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1052,23): error TS2339: Property 'valuesArray' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1053,23): error TS2339: Property 'clear' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1261,5): error TS2322: Type 'CodeMirrorPositionHandle' is not assignable to type '{ resolve(): { lineNumber: number; columnNumber: number; }; equal(positionHandle: any): boolean; }'. - Property '_codeMirror' does not exist on type '{ resolve(): { lineNumber: number; columnNumber: number; }; equal(positionHandle: any): boolean; }'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1301,31): error TS2339: Property 'listSelections' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1305,38): error TS2339: Property 'findMatchingBracket' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1313,14): error TS2339: Property 'setSelections' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1320,31): error TS2339: Property 'getScrollInfo' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1321,14): error TS2339: Property 'execCommand' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1322,27): error TS2339: Property 'getCursor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1323,14): error TS2339: Property '_codeMirrorTextEditor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1324,43): error TS2339: Property '_codeMirrorTextEditor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1333,31): error TS2339: Property 'getScrollInfo' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1334,14): error TS2339: Property 'execCommand' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1335,27): error TS2339: Property 'getCursor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1336,14): error TS2339: Property '_codeMirrorTextEditor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1337,43): error TS2339: Property '_codeMirrorTextEditor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1392,35): error TS2339: Property 'getLineHandle' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1401,58): error TS2339: Property 'getLineNumber' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1451,22): error TS2339: Property 'execCommand' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1539,44): error TS2339: Property 'getLine' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1543,22): error TS2339: Property 'eachLine' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1543,69): error TS2339: Property 'lineCount' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1545,22): error TS2339: Property 'eachLine' does not exist on type 'CodeMirror'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1052,104): error TS2339: Property 'widget' does not exist on type 'V'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1302,34): error TS2339: Property 'length' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1307,9): error TS1345: An expression of type 'void' cannot be tested for truthiness +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1307,9): error TS1345: An expression of type 'void' cannot be tested for truthiness +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1307,44): error TS2339: Property 'match' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1308,64): error TS2339: Property 'from' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1309,56): error TS2339: Property 'to' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1309,81): error TS2339: Property 'to' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1323,60): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1336,60): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1404,13): error TS2322: Type 'void' is not assignable to type 'number'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1541,98): error TS2339: Property 'length' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1551,68): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'number'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1563,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1569,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. @@ -11862,47 +11785,45 @@ node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1650,33): error TS2339: Property 'Decoration' does not exist on type 'typeof CodeMirrorTextEditor'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1659,29): error TS2694: Namespace 'UI.TextEditor' has no exported member 'Options'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorUtils.js(53,24): error TS2694: Namespace 'CodeMirror' has no exported member 'ChangeObject'. -node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorUtils.js(80,14): error TS2339: Property 'eachLine' does not exist on type 'CodeMirror'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorUtils.js(146,15): error TS1345: An expression of type 'void' cannot be tested for truthiness node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorUtils.js(147,26): error TS2339: Property 'token' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorUtils.js(149,67): error TS2339: Property 'length' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(12,18): error TS2694: Namespace 'UI' has no exported member 'AutocompleteConfig'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(26,22): error TS2339: Property 'on' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(35,22): error TS2339: Property 'on' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(36,22): error TS2339: Property 'on' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(37,22): error TS2339: Property 'on' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(38,22): error TS2339: Property 'on' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(40,24): error TS2339: Property 'on' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(42,47): error TS2339: Property 'getValue' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(47,22): error TS2339: Property 'off' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(49,24): error TS2339: Property 'off' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(50,24): error TS2339: Property 'off' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(51,24): error TS2339: Property 'off' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(52,24): error TS2339: Property 'off' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(55,24): error TS2339: Property 'off' does not exist on type 'CodeMirror'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(42,30): error TS2345: Argument of type 'void' is not assignable to parameter of type 'string'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(62,26): error TS2694: Namespace 'CodeMirror' has no exported member 'BeforeChangeObject'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(67,48): error TS2339: Property 'getLine' does not exist on type 'CodeMirror'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(113,40): error TS2694: Namespace 'UI.SuggestBox' has no exported member 'Suggestions'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(135,34): error TS2694: Namespace 'CodeMirror' has no exported member 'ChangeObject'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(151,47): error TS2339: Property 'getLine' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(159,35): error TS2339: Property 'getCursor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(198,39): error TS2339: Property 'listSelections' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(218,26): error TS2339: Property 'somethingSelected' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(223,35): error TS2339: Property 'getCursor' does not exist on type 'CodeMirror'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(163,43): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(163,85): error TS2339: Property 'ch' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(168,83): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(169,45): error TS2339: Property 'ch' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(199,20): error TS2339: Property 'length' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(202,36): error TS2339: Property 'length' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(218,9): error TS1345: An expression of type 'void' cannot be tested for truthiness +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(224,56): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(224,69): error TS2339: Property 'ch' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(231,35): error TS2339: Property 'ch' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(239,31): error TS2694: Namespace 'UI.SuggestBox' has no exported member 'Suggestions'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(275,35): error TS2339: Property 'getCursor' does not exist on type 'CodeMirror'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(278,86): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(278,99): error TS2339: Property 'ch' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(286,18): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(286,31): error TS2339: Property 'ch' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(303,29): error TS2694: Namespace 'UI.SuggestBox' has no exported member 'Suggestions'. node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(329,19): error TS2339: Property 'keyCode' does not exist on type 'Event'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(359,35): error TS2339: Property 'getCursor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(360,43): error TS2339: Property 'getLine' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(377,39): error TS2339: Property 'listSelections' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(382,24): error TS2339: Property 'replaceRange' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(389,35): error TS2339: Property 'getCursor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(390,39): error TS2339: Property 'getScrollInfo' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(391,46): error TS2339: Property 'lineAtHeight' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(392,39): error TS2339: Property 'lineAtHeight' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(404,35): error TS2339: Property 'getCursor' does not exist on type 'CodeMirror'. -node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(410,35): error TS2339: Property 'getLine' does not exist on type 'CodeMirror'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(360,19): error TS2339: Property 'ch' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(360,58): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(360,64): error TS2339: Property 'length' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(377,56): error TS2339: Property 'slice' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(393,16): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(393,51): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(406,18): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(406,96): error TS2339: Property 'ch' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(407,18): error TS2339: Property 'ch' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(409,16): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(409,62): error TS2339: Property 'ch' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(410,50): error TS2339: Property 'line' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(411,89): error TS2339: Property 'charAt' does not exist on type 'void'. +node_modules/chrome-devtools-frontend/front_end/text_editor/TextEditorAutocompleteController.js(411,103): error TS2339: Property 'ch' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/text_utils/Text.js(21,39): error TS2339: Property 'computeLineEndings' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/text_utils/Text.js(51,31): error TS2694: Namespace 'TextUtils.Text' has no exported member 'Position'. node_modules/chrome-devtools-frontend/front_end/text_utils/Text.js(55,34): error TS2339: Property 'lowerBound' does not exist on type 'number[]'. @@ -12671,7 +12592,6 @@ node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineModel.js( node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineModel.js(1811,25): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineModel.js(1819,32): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineModelFilter.js(43,22): error TS1110: Type expected. -node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineProfileTree.js(72,15): error TS2587: JSDoc type 'TopDownNode' circularly references itself. node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineProfileTree.js(74,26): error TS2502: 'parent' is referenced directly or indirectly in its own type annotation. node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineProfileTree.js(168,31): error TS2345: Argument of type 'string | symbol' is not assignable to parameter of type 'string'. Type 'symbol' is not assignable to type 'string'. @@ -12735,7 +12655,6 @@ node_modules/chrome-devtools-frontend/front_end/ui/Context.js(73,30): error TS23 node_modules/chrome-devtools-frontend/front_end/ui/Context.js(77,33): error TS1110: Type expected. node_modules/chrome-devtools-frontend/front_end/ui/Context.js(86,45): error TS1110: Type expected. node_modules/chrome-devtools-frontend/front_end/ui/Context.js(101,16): error TS2339: Property 'runtime' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(36,15): error TS2587: JSDoc type 'ContextMenu' circularly references itself. node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(42,15): error TS2502: 'contextMenu' is referenced directly or indirectly in its own type annotation. node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(81,41): error TS2694: Namespace 'InspectorFrontendHostAPI' has no exported member 'ContextMenuDescriptor'. node_modules/chrome-devtools-frontend/front_end/ui/ContextMenu.js(87,18): error TS2339: Property '_customElement' does not exist on type 'ContextMenuItem'. @@ -13047,7 +12966,6 @@ node_modules/chrome-devtools-frontend/front_end/ui/SearchableView.js(367,42): er node_modules/chrome-devtools-frontend/front_end/ui/SearchableView.js(474,9): error TS2352: Conversion of type '{ searchCanceled(): void; performSearch(searchConfig: SearchConfig, shouldJump: boolean, jumpBackwards?: boolean): void; jumpToNextSearchResult(): void; jumpToPreviousSearchResult(): void; supportsCaseSensitiveSearch(): boolean; supportsRegexSearch(): boolean; }' to type '{ replaceSelectionWith(searchConfig: SearchConfig, replacement: string): void; replaceAllWith(searchConfig: SearchConfig, replacement: string): void; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type '{ searchCanceled(): void; performSearch(searchConfig: SearchConfig, shouldJump: boolean, jumpBackwards?: boolean): void; jumpToNextSearchResult(): void; jumpToPreviousSearchResult(): void; supportsCaseSensitiveSearch(): boolean; supportsRegexSearch(): boolean; }' is missing the following properties from type '{ replaceSelectionWith(searchConfig: SearchConfig, replacement: string): void; replaceAllWith(searchConfig: SearchConfig, replacement: string): void; }': replaceSelectionWith, replaceAllWith node_modules/chrome-devtools-frontend/front_end/ui/SearchableView.js(482,9): error TS2352: Conversion of type '{ searchCanceled(): void; performSearch(searchConfig: SearchConfig, shouldJump: boolean, jumpBackwards?: boolean): void; jumpToNextSearchResult(): void; jumpToPreviousSearchResult(): void; supportsCaseSensitiveSearch(): boolean; supportsRegexSearch(): boolean; }' to type '{ replaceSelectionWith(searchConfig: SearchConfig, replacement: string): void; replaceAllWith(searchConfig: SearchConfig, replacement: string): void; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - Type '{ searchCanceled(): void; performSearch(searchConfig: SearchConfig, shouldJump: boolean, jumpBackwards?: boolean): void; jumpToNextSearchResult(): void; jumpToPreviousSearchResult(): void; supportsCaseSensitiveSearch(): boolean; supportsRegexSearch(): boolean; }' is missing the following properties from type '{ replaceSelectionWith(searchConfig: SearchConfig, replacement: string): void; replaceAllWith(searchConfig: SearchConfig, replacement: string): void; }': replaceSelectionWith, replaceAllWith node_modules/chrome-devtools-frontend/front_end/ui/SearchableView.js(527,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/ui/SearchableView.js(532,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/ui/SearchableView.js(587,15): error TS2339: Property '__fromRegExpQuery' does not exist on type 'RegExp'. @@ -13063,13 +12981,13 @@ node_modules/chrome-devtools-frontend/front_end/ui/SettingsUI.js(133,17): error node_modules/chrome-devtools-frontend/front_end/ui/SettingsUI.js(155,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(16,56): error TS2694: Namespace 'UI.KeyboardShortcut' has no exported member 'Descriptor'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(26,83): error TS2339: Property 'valuesArray' does not exist on type 'Set'. -node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(34,38): error TS2339: Property 'get' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(34,42): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(39,44): error TS2694: Namespace 'UI.KeyboardShortcut' has no exported member 'Descriptor'. -node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(42,42): error TS2339: Property 'get' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(42,46): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(88,15): error TS2339: Property 'consume' does not exist on type 'KeyboardEvent'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(94,15): error TS2339: Property 'consume' does not exist on type 'KeyboardEvent'. -node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(147,35): error TS2339: Property 'set' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(148,31): error TS2339: Property 'set' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(147,39): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(148,35): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(163,27): error TS2339: Property 'runtime' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutsScreen.js(42,54): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutsScreen.js(46,46): error TS2555: Expected at least 2 arguments, but got 1. @@ -13285,7 +13203,7 @@ node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(58,15): error T node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(70,18): error TS2694: Namespace 'UI' has no exported member 'AutocompleteConfig'. node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(79,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(101,15): error TS2300: Duplicate identifier 'Options'. -node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(101,15): error TS2339: Property 'Options' does not exist on type '{ (): void; prototype: { widget(): Widget; fullRange(): TextRange; selection(): TextRange; setSelection(selection: TextRange): void; text(textRange?: TextRange): string; setText(text: string): void; ... 5 more ...; tokenAtTextPosition(lineNumber: number, columnNumber: number): { ...; }; }; Events: { ...; }; }'. +node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(101,15): error TS2339: Property 'Options' does not exist on type 'typeof TextEditor'. node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(106,119): error TS2694: Namespace 'UI.SuggestBox' has no exported member 'Suggestions'. node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(52,74): error TS2694: Namespace 'UI.SuggestBox' has no exported member 'Suggestions'. node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(89,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. @@ -13732,13 +13650,12 @@ node_modules/chrome-devtools-frontend/front_end/workspace/SearchConfig.js(177,24 node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(45,25): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(136,14): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(298,26): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(546,23): error TS2339: Property 'set' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(556,37): error TS2339: Property 'get' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(557,23): error TS2339: Property 'deleteAll' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(567,50): error TS2339: Property 'valuesArray' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(573,44): error TS2339: Property 'valuesArray' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(574,23): error TS2339: Property 'clear' does not exist on type 'Multimap'. -node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(584,50): error TS2339: Property 'get' does not exist on type 'Multimap'. +node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(546,27): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(556,41): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(557,33): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. +node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(567,5): error TS2322: Type 'V[]' is not assignable to type 'LineMarker[]'. + Type 'V' is not assignable to type 'LineMarker'. +node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(584,54): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. node_modules/chrome-devtools-frontend/front_end/workspace/Workspace.js(37,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/workspace/Workspace.js(42,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/workspace/Workspace.js(47,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. diff --git a/tests/baselines/reference/user/lodash.log b/tests/baselines/reference/user/lodash.log index f224b826c9c..79200e0d87b 100644 --- a/tests/baselines/reference/user/lodash.log +++ b/tests/baselines/reference/user/lodash.log @@ -79,7 +79,6 @@ node_modules/lodash/_baseWrapperValue.js(18,21): error TS2339: Property 'value' node_modules/lodash/_cloneArrayBuffer.js(11,16): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. node_modules/lodash/_cloneBuffer.js(4,69): error TS2339: Property 'nodeType' does not exist on type '(buffer: any, isDeep?: boolean | undefined) => any'. node_modules/lodash/_cloneBuffer.js(7,80): error TS2339: Property 'nodeType' does not exist on type '{ "../../../tests/cases/user/lodash/node_modules/lodash/_cloneBuffer": (buffer: any, isDeep?: boolean | undefined) => any; }'. -node_modules/lodash/_cloneBuffer.js(20,12): error TS2587: JSDoc type 'Buffer' circularly references itself. node_modules/lodash/_cloneBuffer.js(22,14): error TS2577: Return type annotation circularly references itself. node_modules/lodash/_cloneBuffer.js(24,22): error TS2502: 'buffer' is referenced directly or indirectly in its own type annotation. node_modules/lodash/_copySymbols.js(13,29): error TS2554: Expected 0 arguments, but got 1. From 984443623194ebbf3d126f7370cd20d6878dbe4c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 24 Jan 2019 09:30:36 -0800 Subject: [PATCH 69/88] Match control flow logic for switch statements to conditional expressions --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac069d95fac..2dec31595ce 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15780,9 +15780,6 @@ namespace ts { function getTypeAtSwitchClause(flow: FlowSwitchClause): FlowType { const expr = flow.switchStatement.expression; - if (containsMatchingReferenceDiscriminant(reference, expr)) { - return declaredType; - } const flowType = getTypeAtFlowNode(flow.antecedent); let type = getTypeFromFlowType(flowType); if (isMatchingReference(reference, expr)) { @@ -15797,6 +15794,9 @@ namespace ts { else if (expr.kind === SyntaxKind.TypeOfExpression && isMatchingReference(reference, (expr as TypeOfExpression).expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } + else if (containsMatchingReferenceDiscriminant(reference, expr)) { + type = declaredType; + } return createFlowType(type, isIncomplete(flowType)); } From 83f7f4d190b7135fd868a30cae8999a408d94808 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 24 Jan 2019 09:30:46 -0800 Subject: [PATCH 70/88] Add regression test --- .../compiler/discriminantPropertyCheck.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/cases/compiler/discriminantPropertyCheck.ts b/tests/cases/compiler/discriminantPropertyCheck.ts index a24fe07973b..8923e0eb043 100644 --- a/tests/cases/compiler/discriminantPropertyCheck.ts +++ b/tests/cases/compiler/discriminantPropertyCheck.ts @@ -121,3 +121,29 @@ const u: U = {} as any; u.a && u.b && f(u.a, u.b); u.b && u.a && f(u.a, u.b); + +// Repro from #29496 + +declare function never(value: never): never; + +const enum BarEnum { + bar1 = 1, + bar2 = 2, +} + +type UnionOfBar = TypeBar1 | TypeBar2; +type TypeBar1 = { type: BarEnum.bar1 }; +type TypeBar2 = { type: BarEnum.bar2 }; + +function func3(value: Partial) { + if (value.type !== undefined) { + switch (value.type) { + case BarEnum.bar1: + break; + case BarEnum.bar2: + break; + default: + never(value.type); + } + } +} From 48cad7788d1999b9893c62fcebfa5ce42841b0f2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 24 Jan 2019 09:30:54 -0800 Subject: [PATCH 71/88] Accept new baselines --- .../discriminantPropertyCheck.errors.txt | 26 +++++++ .../reference/discriminantPropertyCheck.js | 38 ++++++++++ .../discriminantPropertyCheck.symbols | 72 +++++++++++++++++++ .../reference/discriminantPropertyCheck.types | 70 ++++++++++++++++++ 4 files changed, 206 insertions(+) diff --git a/tests/baselines/reference/discriminantPropertyCheck.errors.txt b/tests/baselines/reference/discriminantPropertyCheck.errors.txt index 313116edde5..a59b89de9de 100644 --- a/tests/baselines/reference/discriminantPropertyCheck.errors.txt +++ b/tests/baselines/reference/discriminantPropertyCheck.errors.txt @@ -128,4 +128,30 @@ tests/cases/compiler/discriminantPropertyCheck.ts(65,9): error TS2532: Object is u.a && u.b && f(u.a, u.b); u.b && u.a && f(u.a, u.b); + + // Repro from #29496 + + declare function never(value: never): never; + + const enum BarEnum { + bar1 = 1, + bar2 = 2, + } + + type UnionOfBar = TypeBar1 | TypeBar2; + type TypeBar1 = { type: BarEnum.bar1 }; + type TypeBar2 = { type: BarEnum.bar2 }; + + function func3(value: Partial) { + if (value.type !== undefined) { + switch (value.type) { + case BarEnum.bar1: + break; + case BarEnum.bar2: + break; + default: + never(value.type); + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/discriminantPropertyCheck.js b/tests/baselines/reference/discriminantPropertyCheck.js index 8b2c6f122bc..2b7c842e0b1 100644 --- a/tests/baselines/reference/discriminantPropertyCheck.js +++ b/tests/baselines/reference/discriminantPropertyCheck.js @@ -120,6 +120,32 @@ const u: U = {} as any; u.a && u.b && f(u.a, u.b); u.b && u.a && f(u.a, u.b); + +// Repro from #29496 + +declare function never(value: never): never; + +const enum BarEnum { + bar1 = 1, + bar2 = 2, +} + +type UnionOfBar = TypeBar1 | TypeBar2; +type TypeBar1 = { type: BarEnum.bar1 }; +type TypeBar2 = { type: BarEnum.bar2 }; + +function func3(value: Partial) { + if (value.type !== undefined) { + switch (value.type) { + case BarEnum.bar1: + break; + case BarEnum.bar2: + break; + default: + never(value.type); + } + } +} //// [discriminantPropertyCheck.js] @@ -188,3 +214,15 @@ var f = function (_a, _b) { }; var u = {}; u.a && u.b && f(u.a, u.b); u.b && u.a && f(u.a, u.b); +function func3(value) { + if (value.type !== undefined) { + switch (value.type) { + case 1 /* bar1 */: + break; + case 2 /* bar2 */: + break; + default: + never(value.type); + } + } +} diff --git a/tests/baselines/reference/discriminantPropertyCheck.symbols b/tests/baselines/reference/discriminantPropertyCheck.symbols index 78884eaf69f..8a906adec13 100644 --- a/tests/baselines/reference/discriminantPropertyCheck.symbols +++ b/tests/baselines/reference/discriminantPropertyCheck.symbols @@ -377,3 +377,75 @@ u.b && u.a && f(u.a, u.b); >u : Symbol(u, Decl(discriminantPropertyCheck.ts, 116, 5)) >b : Symbol(b, Decl(discriminantPropertyCheck.ts, 105, 13), Decl(discriminantPropertyCheck.ts, 110, 12)) +// Repro from #29496 + +declare function never(value: never): never; +>never : Symbol(never, Decl(discriminantPropertyCheck.ts, 120, 26)) +>value : Symbol(value, Decl(discriminantPropertyCheck.ts, 124, 23)) + +const enum BarEnum { +>BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 124, 44)) + + bar1 = 1, +>bar1 : Symbol(BarEnum.bar1, Decl(discriminantPropertyCheck.ts, 126, 20)) + + bar2 = 2, +>bar2 : Symbol(BarEnum.bar2, Decl(discriminantPropertyCheck.ts, 127, 13)) +} + +type UnionOfBar = TypeBar1 | TypeBar2; +>UnionOfBar : Symbol(UnionOfBar, Decl(discriminantPropertyCheck.ts, 129, 1)) +>TypeBar1 : Symbol(TypeBar1, Decl(discriminantPropertyCheck.ts, 131, 38)) +>TypeBar2 : Symbol(TypeBar2, Decl(discriminantPropertyCheck.ts, 132, 39)) + +type TypeBar1 = { type: BarEnum.bar1 }; +>TypeBar1 : Symbol(TypeBar1, Decl(discriminantPropertyCheck.ts, 131, 38)) +>type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17)) +>BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 124, 44)) +>bar1 : Symbol(BarEnum.bar1, Decl(discriminantPropertyCheck.ts, 126, 20)) + +type TypeBar2 = { type: BarEnum.bar2 }; +>TypeBar2 : Symbol(TypeBar2, Decl(discriminantPropertyCheck.ts, 132, 39)) +>type : Symbol(type, Decl(discriminantPropertyCheck.ts, 133, 17)) +>BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 124, 44)) +>bar2 : Symbol(BarEnum.bar2, Decl(discriminantPropertyCheck.ts, 127, 13)) + +function func3(value: Partial) { +>func3 : Symbol(func3, Decl(discriminantPropertyCheck.ts, 133, 39)) +>value : Symbol(value, Decl(discriminantPropertyCheck.ts, 135, 15)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>UnionOfBar : Symbol(UnionOfBar, Decl(discriminantPropertyCheck.ts, 129, 1)) + + if (value.type !== undefined) { +>value.type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17), Decl(discriminantPropertyCheck.ts, 133, 17)) +>value : Symbol(value, Decl(discriminantPropertyCheck.ts, 135, 15)) +>type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17), Decl(discriminantPropertyCheck.ts, 133, 17)) +>undefined : Symbol(undefined) + + switch (value.type) { +>value.type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17), Decl(discriminantPropertyCheck.ts, 133, 17)) +>value : Symbol(value, Decl(discriminantPropertyCheck.ts, 135, 15)) +>type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17), Decl(discriminantPropertyCheck.ts, 133, 17)) + + case BarEnum.bar1: +>BarEnum.bar1 : Symbol(BarEnum.bar1, Decl(discriminantPropertyCheck.ts, 126, 20)) +>BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 124, 44)) +>bar1 : Symbol(BarEnum.bar1, Decl(discriminantPropertyCheck.ts, 126, 20)) + + break; + case BarEnum.bar2: +>BarEnum.bar2 : Symbol(BarEnum.bar2, Decl(discriminantPropertyCheck.ts, 127, 13)) +>BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 124, 44)) +>bar2 : Symbol(BarEnum.bar2, Decl(discriminantPropertyCheck.ts, 127, 13)) + + break; + default: + never(value.type); +>never : Symbol(never, Decl(discriminantPropertyCheck.ts, 120, 26)) +>value.type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17), Decl(discriminantPropertyCheck.ts, 133, 17)) +>value : Symbol(value, Decl(discriminantPropertyCheck.ts, 135, 15)) +>type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17), Decl(discriminantPropertyCheck.ts, 133, 17)) + } + } +} + diff --git a/tests/baselines/reference/discriminantPropertyCheck.types b/tests/baselines/reference/discriminantPropertyCheck.types index c243ef5e798..5a30f575189 100644 --- a/tests/baselines/reference/discriminantPropertyCheck.types +++ b/tests/baselines/reference/discriminantPropertyCheck.types @@ -378,3 +378,73 @@ u.b && u.a && f(u.a, u.b); >u : U >b : string +// Repro from #29496 + +declare function never(value: never): never; +>never : (value: never) => never +>value : never + +const enum BarEnum { +>BarEnum : BarEnum + + bar1 = 1, +>bar1 : BarEnum.bar1 +>1 : 1 + + bar2 = 2, +>bar2 : BarEnum.bar2 +>2 : 2 +} + +type UnionOfBar = TypeBar1 | TypeBar2; +>UnionOfBar : UnionOfBar + +type TypeBar1 = { type: BarEnum.bar1 }; +>TypeBar1 : TypeBar1 +>type : BarEnum.bar1 +>BarEnum : any + +type TypeBar2 = { type: BarEnum.bar2 }; +>TypeBar2 : TypeBar2 +>type : BarEnum.bar2 +>BarEnum : any + +function func3(value: Partial) { +>func3 : (value: Partial | Partial) => void +>value : Partial | Partial + + if (value.type !== undefined) { +>value.type !== undefined : boolean +>value.type : BarEnum | undefined +>value : Partial | Partial +>type : BarEnum | undefined +>undefined : undefined + + switch (value.type) { +>value.type : BarEnum +>value : Partial | Partial +>type : BarEnum + + case BarEnum.bar1: +>BarEnum.bar1 : BarEnum.bar1 +>BarEnum : typeof BarEnum +>bar1 : BarEnum.bar1 + + break; + case BarEnum.bar2: +>BarEnum.bar2 : BarEnum.bar2 +>BarEnum : typeof BarEnum +>bar2 : BarEnum.bar2 + + break; + default: + never(value.type); +>never(value.type) : never +>never : (value: never) => never +>value.type : never +>value : Partial | Partial +>type : never + } + } +} + From 500c4729e98fe8d77d98ba11d1267bf74c4d5004 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 24 Jan 2019 10:12:35 -0800 Subject: [PATCH 72/88] Add additional repro --- .../compiler/discriminantPropertyCheck.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/cases/compiler/discriminantPropertyCheck.ts b/tests/cases/compiler/discriminantPropertyCheck.ts index 8923e0eb043..6a15af5db65 100644 --- a/tests/cases/compiler/discriminantPropertyCheck.ts +++ b/tests/cases/compiler/discriminantPropertyCheck.ts @@ -122,6 +122,34 @@ u.a && u.b && f(u.a, u.b); u.b && u.a && f(u.a, u.b); +// Repro from #29012 + +type Additive = '+' | '-'; +type Multiplicative = '*' | '/'; + +interface AdditiveObj { + key: Additive +} + +interface MultiplicativeObj { + key: Multiplicative +} + +type Obj = AdditiveObj | MultiplicativeObj + +export function foo(obj: Obj) { + switch (obj.key) { + case '+': { + onlyPlus(obj.key); + return; + } + } +} + +function onlyPlus(arg: '+') { + return arg; +} + // Repro from #29496 declare function never(value: never): never; From 936ee9b92127c31c9f6e2c5eadd2f343ef9e67ea Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 24 Jan 2019 10:12:43 -0800 Subject: [PATCH 73/88] Accept new baselines --- .../discriminantPropertyCheck.errors.txt | 28 ++++ .../reference/discriminantPropertyCheck.js | 42 +++++ .../discriminantPropertyCheck.symbols | 155 ++++++++++++------ .../reference/discriminantPropertyCheck.types | 53 ++++++ 4 files changed, 230 insertions(+), 48 deletions(-) diff --git a/tests/baselines/reference/discriminantPropertyCheck.errors.txt b/tests/baselines/reference/discriminantPropertyCheck.errors.txt index a59b89de9de..962faaa740e 100644 --- a/tests/baselines/reference/discriminantPropertyCheck.errors.txt +++ b/tests/baselines/reference/discriminantPropertyCheck.errors.txt @@ -129,6 +129,34 @@ tests/cases/compiler/discriminantPropertyCheck.ts(65,9): error TS2532: Object is u.b && u.a && f(u.a, u.b); + // Repro from #29012 + + type Additive = '+' | '-'; + type Multiplicative = '*' | '/'; + + interface AdditiveObj { + key: Additive + } + + interface MultiplicativeObj { + key: Multiplicative + } + + type Obj = AdditiveObj | MultiplicativeObj + + export function foo(obj: Obj) { + switch (obj.key) { + case '+': { + onlyPlus(obj.key); + return; + } + } + } + + function onlyPlus(arg: '+') { + return arg; + } + // Repro from #29496 declare function never(value: never): never; diff --git a/tests/baselines/reference/discriminantPropertyCheck.js b/tests/baselines/reference/discriminantPropertyCheck.js index 2b7c842e0b1..25e66e044cd 100644 --- a/tests/baselines/reference/discriminantPropertyCheck.js +++ b/tests/baselines/reference/discriminantPropertyCheck.js @@ -121,6 +121,34 @@ u.a && u.b && f(u.a, u.b); u.b && u.a && f(u.a, u.b); +// Repro from #29012 + +type Additive = '+' | '-'; +type Multiplicative = '*' | '/'; + +interface AdditiveObj { + key: Additive +} + +interface MultiplicativeObj { + key: Multiplicative +} + +type Obj = AdditiveObj | MultiplicativeObj + +export function foo(obj: Obj) { + switch (obj.key) { + case '+': { + onlyPlus(obj.key); + return; + } + } +} + +function onlyPlus(arg: '+') { + return arg; +} + // Repro from #29496 declare function never(value: never): never; @@ -149,6 +177,8 @@ function func3(value: Partial) { //// [discriminantPropertyCheck.js] +"use strict"; +exports.__esModule = true; function goo1(x) { if (x.kind === "A" && x.foo !== undefined) { x.foo.length; @@ -214,6 +244,18 @@ var f = function (_a, _b) { }; var u = {}; u.a && u.b && f(u.a, u.b); u.b && u.a && f(u.a, u.b); +function foo(obj) { + switch (obj.key) { + case '+': { + onlyPlus(obj.key); + return; + } + } +} +exports.foo = foo; +function onlyPlus(arg) { + return arg; +} function func3(value) { if (value.type !== undefined) { switch (value.type) { diff --git a/tests/baselines/reference/discriminantPropertyCheck.symbols b/tests/baselines/reference/discriminantPropertyCheck.symbols index 8a906adec13..b02a8113d46 100644 --- a/tests/baselines/reference/discriminantPropertyCheck.symbols +++ b/tests/baselines/reference/discriminantPropertyCheck.symbols @@ -377,74 +377,133 @@ u.b && u.a && f(u.a, u.b); >u : Symbol(u, Decl(discriminantPropertyCheck.ts, 116, 5)) >b : Symbol(b, Decl(discriminantPropertyCheck.ts, 105, 13), Decl(discriminantPropertyCheck.ts, 110, 12)) -// Repro from #29496 +// Repro from #29012 -declare function never(value: never): never; ->never : Symbol(never, Decl(discriminantPropertyCheck.ts, 120, 26)) ->value : Symbol(value, Decl(discriminantPropertyCheck.ts, 124, 23)) +type Additive = '+' | '-'; +>Additive : Symbol(Additive, Decl(discriminantPropertyCheck.ts, 120, 26)) -const enum BarEnum { ->BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 124, 44)) +type Multiplicative = '*' | '/'; +>Multiplicative : Symbol(Multiplicative, Decl(discriminantPropertyCheck.ts, 124, 26)) - bar1 = 1, ->bar1 : Symbol(BarEnum.bar1, Decl(discriminantPropertyCheck.ts, 126, 20)) +interface AdditiveObj { +>AdditiveObj : Symbol(AdditiveObj, Decl(discriminantPropertyCheck.ts, 125, 32)) - bar2 = 2, ->bar2 : Symbol(BarEnum.bar2, Decl(discriminantPropertyCheck.ts, 127, 13)) + key: Additive +>key : Symbol(AdditiveObj.key, Decl(discriminantPropertyCheck.ts, 127, 23)) +>Additive : Symbol(Additive, Decl(discriminantPropertyCheck.ts, 120, 26)) } -type UnionOfBar = TypeBar1 | TypeBar2; ->UnionOfBar : Symbol(UnionOfBar, Decl(discriminantPropertyCheck.ts, 129, 1)) ->TypeBar1 : Symbol(TypeBar1, Decl(discriminantPropertyCheck.ts, 131, 38)) ->TypeBar2 : Symbol(TypeBar2, Decl(discriminantPropertyCheck.ts, 132, 39)) +interface MultiplicativeObj { +>MultiplicativeObj : Symbol(MultiplicativeObj, Decl(discriminantPropertyCheck.ts, 129, 1)) -type TypeBar1 = { type: BarEnum.bar1 }; ->TypeBar1 : Symbol(TypeBar1, Decl(discriminantPropertyCheck.ts, 131, 38)) ->type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17)) ->BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 124, 44)) ->bar1 : Symbol(BarEnum.bar1, Decl(discriminantPropertyCheck.ts, 126, 20)) + key: Multiplicative +>key : Symbol(MultiplicativeObj.key, Decl(discriminantPropertyCheck.ts, 131, 29)) +>Multiplicative : Symbol(Multiplicative, Decl(discriminantPropertyCheck.ts, 124, 26)) +} -type TypeBar2 = { type: BarEnum.bar2 }; ->TypeBar2 : Symbol(TypeBar2, Decl(discriminantPropertyCheck.ts, 132, 39)) ->type : Symbol(type, Decl(discriminantPropertyCheck.ts, 133, 17)) ->BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 124, 44)) ->bar2 : Symbol(BarEnum.bar2, Decl(discriminantPropertyCheck.ts, 127, 13)) +type Obj = AdditiveObj | MultiplicativeObj +>Obj : Symbol(Obj, Decl(discriminantPropertyCheck.ts, 133, 1)) +>AdditiveObj : Symbol(AdditiveObj, Decl(discriminantPropertyCheck.ts, 125, 32)) +>MultiplicativeObj : Symbol(MultiplicativeObj, Decl(discriminantPropertyCheck.ts, 129, 1)) -function func3(value: Partial) { ->func3 : Symbol(func3, Decl(discriminantPropertyCheck.ts, 133, 39)) ->value : Symbol(value, Decl(discriminantPropertyCheck.ts, 135, 15)) ->Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) ->UnionOfBar : Symbol(UnionOfBar, Decl(discriminantPropertyCheck.ts, 129, 1)) +export function foo(obj: Obj) { +>foo : Symbol(foo, Decl(discriminantPropertyCheck.ts, 135, 42)) +>obj : Symbol(obj, Decl(discriminantPropertyCheck.ts, 137, 20)) +>Obj : Symbol(Obj, Decl(discriminantPropertyCheck.ts, 133, 1)) - if (value.type !== undefined) { ->value.type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17), Decl(discriminantPropertyCheck.ts, 133, 17)) ->value : Symbol(value, Decl(discriminantPropertyCheck.ts, 135, 15)) ->type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17), Decl(discriminantPropertyCheck.ts, 133, 17)) ->undefined : Symbol(undefined) + switch (obj.key) { +>obj.key : Symbol(key, Decl(discriminantPropertyCheck.ts, 127, 23), Decl(discriminantPropertyCheck.ts, 131, 29)) +>obj : Symbol(obj, Decl(discriminantPropertyCheck.ts, 137, 20)) +>key : Symbol(key, Decl(discriminantPropertyCheck.ts, 127, 23), Decl(discriminantPropertyCheck.ts, 131, 29)) - switch (value.type) { ->value.type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17), Decl(discriminantPropertyCheck.ts, 133, 17)) ->value : Symbol(value, Decl(discriminantPropertyCheck.ts, 135, 15)) ->type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17), Decl(discriminantPropertyCheck.ts, 133, 17)) + case '+': { + onlyPlus(obj.key); +>onlyPlus : Symbol(onlyPlus, Decl(discriminantPropertyCheck.ts, 144, 1)) +>obj.key : Symbol(AdditiveObj.key, Decl(discriminantPropertyCheck.ts, 127, 23)) +>obj : Symbol(obj, Decl(discriminantPropertyCheck.ts, 137, 20)) +>key : Symbol(AdditiveObj.key, Decl(discriminantPropertyCheck.ts, 127, 23)) + return; + } + } +} + +function onlyPlus(arg: '+') { +>onlyPlus : Symbol(onlyPlus, Decl(discriminantPropertyCheck.ts, 144, 1)) +>arg : Symbol(arg, Decl(discriminantPropertyCheck.ts, 146, 18)) + + return arg; +>arg : Symbol(arg, Decl(discriminantPropertyCheck.ts, 146, 18)) +} + +// Repro from #29496 + +declare function never(value: never): never; +>never : Symbol(never, Decl(discriminantPropertyCheck.ts, 148, 1)) +>value : Symbol(value, Decl(discriminantPropertyCheck.ts, 152, 23)) + +const enum BarEnum { +>BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 152, 44)) + + bar1 = 1, +>bar1 : Symbol(BarEnum.bar1, Decl(discriminantPropertyCheck.ts, 154, 20)) + + bar2 = 2, +>bar2 : Symbol(BarEnum.bar2, Decl(discriminantPropertyCheck.ts, 155, 13)) +} + +type UnionOfBar = TypeBar1 | TypeBar2; +>UnionOfBar : Symbol(UnionOfBar, Decl(discriminantPropertyCheck.ts, 157, 1)) +>TypeBar1 : Symbol(TypeBar1, Decl(discriminantPropertyCheck.ts, 159, 38)) +>TypeBar2 : Symbol(TypeBar2, Decl(discriminantPropertyCheck.ts, 160, 39)) + +type TypeBar1 = { type: BarEnum.bar1 }; +>TypeBar1 : Symbol(TypeBar1, Decl(discriminantPropertyCheck.ts, 159, 38)) +>type : Symbol(type, Decl(discriminantPropertyCheck.ts, 160, 17)) +>BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 152, 44)) +>bar1 : Symbol(BarEnum.bar1, Decl(discriminantPropertyCheck.ts, 154, 20)) + +type TypeBar2 = { type: BarEnum.bar2 }; +>TypeBar2 : Symbol(TypeBar2, Decl(discriminantPropertyCheck.ts, 160, 39)) +>type : Symbol(type, Decl(discriminantPropertyCheck.ts, 161, 17)) +>BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 152, 44)) +>bar2 : Symbol(BarEnum.bar2, Decl(discriminantPropertyCheck.ts, 155, 13)) + +function func3(value: Partial) { +>func3 : Symbol(func3, Decl(discriminantPropertyCheck.ts, 161, 39)) +>value : Symbol(value, Decl(discriminantPropertyCheck.ts, 163, 15)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>UnionOfBar : Symbol(UnionOfBar, Decl(discriminantPropertyCheck.ts, 157, 1)) + + if (value.type !== undefined) { +>value.type : Symbol(type, Decl(discriminantPropertyCheck.ts, 160, 17), Decl(discriminantPropertyCheck.ts, 161, 17)) +>value : Symbol(value, Decl(discriminantPropertyCheck.ts, 163, 15)) +>type : Symbol(type, Decl(discriminantPropertyCheck.ts, 160, 17), Decl(discriminantPropertyCheck.ts, 161, 17)) +>undefined : Symbol(undefined) + + switch (value.type) { +>value.type : Symbol(type, Decl(discriminantPropertyCheck.ts, 160, 17), Decl(discriminantPropertyCheck.ts, 161, 17)) +>value : Symbol(value, Decl(discriminantPropertyCheck.ts, 163, 15)) +>type : Symbol(type, Decl(discriminantPropertyCheck.ts, 160, 17), Decl(discriminantPropertyCheck.ts, 161, 17)) + case BarEnum.bar1: ->BarEnum.bar1 : Symbol(BarEnum.bar1, Decl(discriminantPropertyCheck.ts, 126, 20)) ->BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 124, 44)) ->bar1 : Symbol(BarEnum.bar1, Decl(discriminantPropertyCheck.ts, 126, 20)) +>BarEnum.bar1 : Symbol(BarEnum.bar1, Decl(discriminantPropertyCheck.ts, 154, 20)) +>BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 152, 44)) +>bar1 : Symbol(BarEnum.bar1, Decl(discriminantPropertyCheck.ts, 154, 20)) break; case BarEnum.bar2: ->BarEnum.bar2 : Symbol(BarEnum.bar2, Decl(discriminantPropertyCheck.ts, 127, 13)) ->BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 124, 44)) ->bar2 : Symbol(BarEnum.bar2, Decl(discriminantPropertyCheck.ts, 127, 13)) +>BarEnum.bar2 : Symbol(BarEnum.bar2, Decl(discriminantPropertyCheck.ts, 155, 13)) +>BarEnum : Symbol(BarEnum, Decl(discriminantPropertyCheck.ts, 152, 44)) +>bar2 : Symbol(BarEnum.bar2, Decl(discriminantPropertyCheck.ts, 155, 13)) break; default: never(value.type); ->never : Symbol(never, Decl(discriminantPropertyCheck.ts, 120, 26)) ->value.type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17), Decl(discriminantPropertyCheck.ts, 133, 17)) ->value : Symbol(value, Decl(discriminantPropertyCheck.ts, 135, 15)) ->type : Symbol(type, Decl(discriminantPropertyCheck.ts, 132, 17), Decl(discriminantPropertyCheck.ts, 133, 17)) +>never : Symbol(never, Decl(discriminantPropertyCheck.ts, 148, 1)) +>value.type : Symbol(type, Decl(discriminantPropertyCheck.ts, 160, 17), Decl(discriminantPropertyCheck.ts, 161, 17)) +>value : Symbol(value, Decl(discriminantPropertyCheck.ts, 163, 15)) +>type : Symbol(type, Decl(discriminantPropertyCheck.ts, 160, 17), Decl(discriminantPropertyCheck.ts, 161, 17)) } } } diff --git a/tests/baselines/reference/discriminantPropertyCheck.types b/tests/baselines/reference/discriminantPropertyCheck.types index 5a30f575189..def89e7be1f 100644 --- a/tests/baselines/reference/discriminantPropertyCheck.types +++ b/tests/baselines/reference/discriminantPropertyCheck.types @@ -378,6 +378,59 @@ u.b && u.a && f(u.a, u.b); >u : U >b : string +// Repro from #29012 + +type Additive = '+' | '-'; +>Additive : Additive + +type Multiplicative = '*' | '/'; +>Multiplicative : Multiplicative + +interface AdditiveObj { + key: Additive +>key : Additive +} + +interface MultiplicativeObj { + key: Multiplicative +>key : Multiplicative +} + +type Obj = AdditiveObj | MultiplicativeObj +>Obj : Obj + +export function foo(obj: Obj) { +>foo : (obj: Obj) => void +>obj : Obj + + switch (obj.key) { +>obj.key : "+" | "-" | "*" | "/" +>obj : Obj +>key : "+" | "-" | "*" | "/" + + case '+': { +>'+' : "+" + + onlyPlus(obj.key); +>onlyPlus(obj.key) : "+" +>onlyPlus : (arg: "+") => "+" +>obj.key : "+" +>obj : AdditiveObj +>key : "+" + + return; + } + } +} + +function onlyPlus(arg: '+') { +>onlyPlus : (arg: "+") => "+" +>arg : "+" + + return arg; +>arg : "+" +} + // Repro from #29496 declare function never(value: never): never; From 9acff37947392bb3c3c53d16c9fb25039cbc0f4b Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 24 Jan 2019 11:45:22 -0800 Subject: [PATCH 74/88] Add test to test the readFile called on prepend input file for emitting and verifying emit --- src/testRunner/unittests/tsbuild.ts | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/testRunner/unittests/tsbuild.ts b/src/testRunner/unittests/tsbuild.ts index ba94072b230..b8a58eb1bc0 100644 --- a/src/testRunner/unittests/tsbuild.ts +++ b/src/testRunner/unittests/tsbuild.ts @@ -469,11 +469,20 @@ export const b = new A();`); describe("unittests:: tsbuild - baseline sectioned sourcemaps", () => { let fs: vfs.FileSystem | undefined; + const actualReadFileMap = createMap(); before(() => { fs = outFileFs.shadow(); const host = new fakes.SolutionBuilderHost(fs); const builder = createSolutionBuilder(host, ["/src/third"], { dry: false, force: false, verbose: false }); host.clearDiagnostics(); + const originalReadFile = host.readFile; + host.readFile = path => { + // Dont record libs + if (path.startsWith("/src/")) { + actualReadFileMap.set(path, (actualReadFileMap.get(path) || 0) + 1); + } + return originalReadFile.call(host, path); + }; builder.buildAllProjects(); host.assertDiagnosticMessages(/*none*/); }); @@ -485,6 +494,39 @@ export const b = new A();`); // tslint:disable-next-line:no-null-keyword Harness.Baseline.runBaseline("outfile-concat.js", patch ? vfs.formatPatch(patch) : null); }); + it("verify readFile calls", () => { + const expectedMap = createMap(); + // Configs + expectedMap.set("/src/third/tsconfig.json", 1); + expectedMap.set("/src/second/tsconfig.json", 1); + expectedMap.set("/src/first/tsconfig.json", 1); + + // Source files + expectedMap.set("/src/third/third_part1.ts", 1); + expectedMap.set("/src/second/second_part1.ts", 1); + expectedMap.set("/src/second/second_part2.ts", 1); + expectedMap.set("/src/first/first_PART1.ts", 1); + expectedMap.set("/src/first/first_part2.ts", 1); + expectedMap.set("/src/first/first_part3.ts", 1); + + // outputs + expectedMap.set("/src/first/bin/first-output.js", 2); + expectedMap.set("/src/first/bin/first-output.js.map", 2); + // 1 for reading source File, 2 for forEachEmittedFiles (verifying compiler Options and actual emit)when prepend array is created + expectedMap.set("/src/first/bin/first-output.d.ts", 3); + expectedMap.set("/src/first/bin/first-output.d.ts.map", 2); + expectedMap.set("/src/2/second-output.js", 2); + expectedMap.set("/src/2/second-output.js.map", 2); + // 1 for reading source File, 2 for forEachEmittedFiles (verifying compiler Options and actual emit)when prepend array is created + expectedMap.set("/src/2/second-output.d.ts", 3); + expectedMap.set("/src/2/second-output.d.ts.map", 2); + + assert.equal(actualReadFileMap.size, expectedMap.size, `Expected: ${JSON.stringify(arrayFrom(expectedMap.entries()))} \nActual: ${JSON.stringify(arrayFrom(actualReadFileMap.entries()))}`); + actualReadFileMap.forEach((value, key) => { + const expected = expectedMap.get(key); + assert.equal(value, expected, `Expected: ${JSON.stringify(arrayFrom(expectedMap.entries()))} \nActual: ${JSON.stringify(arrayFrom(actualReadFileMap.entries()))}`); + }); + }); }); describe("unittests:: tsbuild - downstream prepend projects always get rebuilt", () => { From fdeb8f01df33eaedfb2cb76d003a6be08bd3ff14 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 24 Jan 2019 12:58:46 -0800 Subject: [PATCH 75/88] Fix typo in runner selection in gulp --- scripts/build/tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build/tests.js b/scripts/build/tests.js index 5bc619e3823..46c31ed8913 100644 --- a/scripts/build/tests.js +++ b/scripts/build/tests.js @@ -165,7 +165,7 @@ exports.cleanTestDirs = cleanTestDirs; function writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, timeout, keepFailed) { const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, - runner: runners ? runners.split(",") : undefined, + runners: runners ? runners.split(",") : undefined, light, workerCount, stackTraceLimit, @@ -192,4 +192,4 @@ function restoreSavedNodeEnv() { function deleteTemporaryProjectOutput() { return del(path.join(exports.localBaseline, "projectOutput/")); -} \ No newline at end of file +} From 95eec999e8ed4c91bad1f9c72181667df7bb3b40 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 24 Jan 2019 13:31:44 -0800 Subject: [PATCH 76/88] Tweaks --- CONTRIBUTING.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a25ed0ad4cd..c707e3c034c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,12 +51,11 @@ In general, things we find useful when reviewing suggestions are: ### Faster clones -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. +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`. ### 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`. +Run `gulp 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 50d98aee0e83bbf806d1f08c0b3eae785690da69 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 24 Jan 2019 12:40:52 -0800 Subject: [PATCH 77/88] Create getters for js sourcemap, dts and dts map text getters in prepend nodes --- src/compiler/emitter.ts | 19 +++-- src/compiler/factory.ts | 81 +++++++++++++++---- src/compiler/program.ts | 10 +-- src/compiler/transformers/declarations.ts | 2 +- src/compiler/transformers/ts.ts | 2 +- src/compiler/types.ts | 3 + src/testRunner/unittests/tsbuild.ts | 20 ++--- .../reference/api/tsserverlibrary.d.ts | 9 ++- tests/baselines/reference/api/typescript.d.ts | 9 ++- 9 files changed, 107 insertions(+), 48 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 395f6448890..8daedabf29a 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -38,17 +38,22 @@ namespace ts { } } + /*@internal*/ + export function getOutputPathsForBundle(options: CompilerOptions, forceDtsPaths: boolean): EmitFileNames { + const outPath = options.outFile || options.out!; + const jsFilePath = options.emitDeclarationOnly ? undefined : outPath; + const sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); + const declarationFilePath = (forceDtsPaths || getEmitDeclarations(options)) ? removeFileExtension(outPath) + Extension.Dts : undefined; + const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; + const bundleInfoPath = options.references && jsFilePath ? (removeFileExtension(jsFilePath) + infoExtension) : undefined; + return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath }; + } + /*@internal*/ export function getOutputPathsFor(sourceFile: SourceFile | Bundle, host: EmitHost, forceDtsPaths: boolean): EmitFileNames { const options = host.getCompilerOptions(); if (sourceFile.kind === SyntaxKind.Bundle) { - const outPath = options.outFile || options.out!; - const jsFilePath = options.emitDeclarationOnly ? undefined : outPath; - const sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); - const declarationFilePath = (forceDtsPaths || getEmitDeclarations(options)) ? removeFileExtension(outPath) + Extension.Dts : undefined; - const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - const bundleInfoPath = options.references && jsFilePath ? (removeFileExtension(jsFilePath) + infoExtension) : undefined; - return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath }; + return getOutputPathsForBundle(options, forceDtsPaths); } else { const ownOutputFilePath = getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options)); diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index ec19d2c906c..3707b725ed3 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2630,41 +2630,88 @@ namespace ts { } export function createUnparsedSourceFile(text: string): UnparsedSource; + export function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts"): UnparsedSource; export function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; - export function createUnparsedSourceFile(text: string, mapPath?: string, map?: string): UnparsedSource { + export function createUnparsedSourceFile(textOrInputFiles: string | InputFiles, mapPathOrType?: string | "js" | "dts", map?: string): UnparsedSource { const node = createNode(SyntaxKind.UnparsedSource); - node.text = text; - node.sourceMapPath = mapPath; - node.sourceMapText = map; + if (!isString(textOrInputFiles)) { + Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts"); + node.fileName = mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath; + node.sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath; + Object.defineProperties(node, { + text: { get() { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; } }, + sourceMapText: { get() { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } }, + }); + } + else { + node.text = textOrInputFiles; + node.sourceMapPath = mapPathOrType; + node.sourceMapText = map; + } return node; } export function createInputFiles( - javascript: string, - declaration: string + javascriptText: string, + declarationText: string ): InputFiles; export function createInputFiles( - javascript: string, - declaration: string, + readFileText: (path: string) => string | undefined, + javascriptPath: string, + javascriptMapPath: string | undefined, + declarationPath: string, + declarationMapPath: string | undefined, + ): InputFiles; + export function createInputFiles( + javascriptText: string, + declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined ): InputFiles; export function createInputFiles( - javascript: string, - declaration: string, + javascriptTextOrReadFileText: string | ((path: string) => string | undefined), + declarationTextOrJavascriptPath: string, javascriptMapPath?: string, - javascriptMapText?: string, + javascriptMapTextOrDeclarationPath?: string, declarationMapPath?: string, declarationMapText?: string ): InputFiles { const node = createNode(SyntaxKind.InputFiles); - node.javascriptText = javascript; - node.javascriptMapPath = javascriptMapPath; - node.javascriptMapText = javascriptMapText; - node.declarationText = declaration; - node.declarationMapPath = declarationMapPath; - node.declarationMapText = declarationMapText; + if (!isString(javascriptTextOrReadFileText)) { + const cache = createMap(); + const textGetter = (path: string | undefined) => { + if (path === undefined) return undefined; + let value = cache.get(path); + if (value === undefined) { + value = javascriptTextOrReadFileText(path); + cache.set(path, value !== undefined ? value : false); + } + return value !== false ? value as string : undefined; + }; + const definedTextGetter = (path: string) => { + const result = textGetter(path); + return result !== undefined ? result : `/* Input file ${path} was missing */\r\n`; + }; + node.javascriptPath = declarationTextOrJavascriptPath; + node.javascriptMapPath = javascriptMapPath; + node.declarationPath = Debug.assertDefined(javascriptMapTextOrDeclarationPath); + node.declarationMapPath = declarationMapPath; + Object.defineProperties(node, { + javascriptText: { get() { return definedTextGetter(declarationTextOrJavascriptPath); } }, + javascriptMapText: { get() { return textGetter(javascriptMapPath); } }, + declarationText: { get() { return definedTextGetter(Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } }, + declarationMapText: { get() { return textGetter(declarationMapPath); } } + }); + } + else { + node.javascriptText = javascriptTextOrReadFileText; + node.javascriptMapPath = javascriptMapPath; + node.javascriptMapText = javascriptMapTextOrDeclarationPath; + node.declarationText = declarationTextOrJavascriptPath; + node.declarationMapPath = declarationMapPath; + node.declarationMapText = declarationMapText; + } return node; } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 14042a89e94..dbc2e61fa42 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1456,14 +1456,8 @@ namespace ts { // Upstream project didn't have outFile set -- skip (error will have been issued earlier) if (!out) continue; - const dtsFilename = changeExtension(out, ".d.ts"); - const js = host.readFile(out) || `/* Input file ${out} was missing */\r\n`; - const jsMapPath = out + ".map"; // TODO: try to read sourceMappingUrl comment from the file - const jsMap = host.readFile(jsMapPath); - const dts = host.readFile(dtsFilename) || `/* Input file ${dtsFilename} was missing */\r\n`; - const dtsMapPath = dtsFilename + ".map"; - const dtsMap = host.readFile(dtsMapPath); - const node = createInputFiles(js, dts, jsMap && jsMapPath, jsMap, dtsMap && dtsMapPath, dtsMap); + const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath } = getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true); + const node = createInputFiles(path => host.readFile(path), jsFilePath!, sourceMapFilePath, declarationFilePath!, declarationMapPath); nodes.push(node); } } diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index d03c3b8d30b..42bb5d77931 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -207,7 +207,7 @@ namespace ts { } ), mapDefined(node.prepends, prepend => { if (prepend.kind === SyntaxKind.InputFiles) { - return createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); + return createUnparsedSourceFile(prepend, "dts"); } })); bundle.syntheticFileReferences = []; diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index a22c6df8d06..7aebed59588 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -101,7 +101,7 @@ namespace ts { function transformBundle(node: Bundle) { return createBundle(node.sourceFiles.map(transformSourceFile), mapDefined(node.prepends, prepend => { if (prepend.kind === SyntaxKind.InputFiles) { - return createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); + return createUnparsedSourceFile(prepend, "js"); } return prepend; })); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d213e862299..c460b948347 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2761,9 +2761,11 @@ namespace ts { export interface InputFiles extends Node { kind: SyntaxKind.InputFiles; + javascriptPath?: string; javascriptText: string; javascriptMapPath?: string; javascriptMapText?: string; + declarationPath?: string; declarationText: string; declarationMapPath?: string; declarationMapText?: string; @@ -2771,6 +2773,7 @@ namespace ts { export interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; + fileName?: string; text: string; sourceMapPath?: string; sourceMapText?: string; diff --git a/src/testRunner/unittests/tsbuild.ts b/src/testRunner/unittests/tsbuild.ts index b8a58eb1bc0..be544f4eb1d 100644 --- a/src/testRunner/unittests/tsbuild.ts +++ b/src/testRunner/unittests/tsbuild.ts @@ -510,16 +510,16 @@ export const b = new A();`); expectedMap.set("/src/first/first_part3.ts", 1); // outputs - expectedMap.set("/src/first/bin/first-output.js", 2); - expectedMap.set("/src/first/bin/first-output.js.map", 2); - // 1 for reading source File, 2 for forEachEmittedFiles (verifying compiler Options and actual emit)when prepend array is created - expectedMap.set("/src/first/bin/first-output.d.ts", 3); - expectedMap.set("/src/first/bin/first-output.d.ts.map", 2); - expectedMap.set("/src/2/second-output.js", 2); - expectedMap.set("/src/2/second-output.js.map", 2); - // 1 for reading source File, 2 for forEachEmittedFiles (verifying compiler Options and actual emit)when prepend array is created - expectedMap.set("/src/2/second-output.d.ts", 3); - expectedMap.set("/src/2/second-output.d.ts.map", 2); + expectedMap.set("/src/first/bin/first-output.js", 1); + expectedMap.set("/src/first/bin/first-output.js.map", 1); + // 1 for reading source File, 1 for emit + expectedMap.set("/src/first/bin/first-output.d.ts", 2); + expectedMap.set("/src/first/bin/first-output.d.ts.map", 1); + expectedMap.set("/src/2/second-output.js", 1); + expectedMap.set("/src/2/second-output.js.map", 1); + // 1 for reading source File, 1 for emit + expectedMap.set("/src/2/second-output.d.ts", 2); + expectedMap.set("/src/2/second-output.d.ts.map", 1); assert.equal(actualReadFileMap.size, expectedMap.size, `Expected: ${JSON.stringify(arrayFrom(expectedMap.entries()))} \nActual: ${JSON.stringify(arrayFrom(actualReadFileMap.entries()))}`); actualReadFileMap.forEach((value, key) => { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 4353bbcd8fa..a384375b248 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1726,15 +1726,18 @@ declare namespace ts { } interface InputFiles extends Node { kind: SyntaxKind.InputFiles; + javascriptPath?: string; javascriptText: string; javascriptMapPath?: string; javascriptMapText?: string; + declarationPath?: string; declarationText: string; declarationMapPath?: string; declarationMapText?: string; } interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; + fileName?: string; text: string; sourceMapPath?: string; sourceMapText?: string; @@ -3979,9 +3982,11 @@ declare namespace ts { function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; + function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts"): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; - function createInputFiles(javascript: string, declaration: string): InputFiles; - function createInputFiles(javascript: string, declaration: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; + function createInputFiles(javascriptText: string, declarationText: string): InputFiles; + function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined): InputFiles; + function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index d8deb32c0ef..5ae49608353 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1726,15 +1726,18 @@ declare namespace ts { } interface InputFiles extends Node { kind: SyntaxKind.InputFiles; + javascriptPath?: string; javascriptText: string; javascriptMapPath?: string; javascriptMapText?: string; + declarationPath?: string; declarationText: string; declarationMapPath?: string; declarationMapText?: string; } interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; + fileName?: string; text: string; sourceMapPath?: string; sourceMapText?: string; @@ -3979,9 +3982,11 @@ declare namespace ts { function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; + function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts"): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; - function createInputFiles(javascript: string, declaration: string): InputFiles; - function createInputFiles(javascript: string, declaration: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; + function createInputFiles(javascriptText: string, declarationText: string): InputFiles; + function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined): InputFiles; + function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; From 216ed1b3859489a36a0ae0c315ec6209d64ec022 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 24 Jan 2019 13:47:27 -0800 Subject: [PATCH 78/88] Get dts content from sourceFile if present --- src/compiler/program.ts | 6 +++- src/testRunner/unittests/tsbuild.ts | 53 ++++++++++++++--------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index dbc2e61fa42..e7c2295a0ca 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1457,7 +1457,11 @@ namespace ts { if (!out) continue; const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath } = getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true); - const node = createInputFiles(path => host.readFile(path), jsFilePath!, sourceMapFilePath, declarationFilePath!, declarationMapPath); + const node = createInputFiles(fileName => { + const path = toPath(fileName); + const sourceFile = getSourceFileByPath(path); + return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); + }, jsFilePath! , sourceMapFilePath, declarationFilePath! , declarationMapPath); nodes.push(node); } } diff --git a/src/testRunner/unittests/tsbuild.ts b/src/testRunner/unittests/tsbuild.ts index be544f4eb1d..e1bc78c712b 100644 --- a/src/testRunner/unittests/tsbuild.ts +++ b/src/testRunner/unittests/tsbuild.ts @@ -495,36 +495,35 @@ export const b = new A();`); Harness.Baseline.runBaseline("outfile-concat.js", patch ? vfs.formatPatch(patch) : null); }); it("verify readFile calls", () => { - const expectedMap = createMap(); - // Configs - expectedMap.set("/src/third/tsconfig.json", 1); - expectedMap.set("/src/second/tsconfig.json", 1); - expectedMap.set("/src/first/tsconfig.json", 1); + const expected = [ + // Configs + "/src/third/tsconfig.json", + "/src/second/tsconfig.json", + "/src/first/tsconfig.json", - // Source files - expectedMap.set("/src/third/third_part1.ts", 1); - expectedMap.set("/src/second/second_part1.ts", 1); - expectedMap.set("/src/second/second_part2.ts", 1); - expectedMap.set("/src/first/first_PART1.ts", 1); - expectedMap.set("/src/first/first_part2.ts", 1); - expectedMap.set("/src/first/first_part3.ts", 1); + // Source files + "/src/third/third_part1.ts", + "/src/second/second_part1.ts", + "/src/second/second_part2.ts", + "/src/first/first_PART1.ts", + "/src/first/first_part2.ts", + "/src/first/first_part3.ts", - // outputs - expectedMap.set("/src/first/bin/first-output.js", 1); - expectedMap.set("/src/first/bin/first-output.js.map", 1); - // 1 for reading source File, 1 for emit - expectedMap.set("/src/first/bin/first-output.d.ts", 2); - expectedMap.set("/src/first/bin/first-output.d.ts.map", 1); - expectedMap.set("/src/2/second-output.js", 1); - expectedMap.set("/src/2/second-output.js.map", 1); - // 1 for reading source File, 1 for emit - expectedMap.set("/src/2/second-output.d.ts", 2); - expectedMap.set("/src/2/second-output.d.ts.map", 1); + // outputs + "/src/first/bin/first-output.js", + "/src/first/bin/first-output.js.map", + "/src/first/bin/first-output.d.ts", + "/src/first/bin/first-output.d.ts.map", + "/src/2/second-output.js", + "/src/2/second-output.js.map", + "/src/2/second-output.d.ts", + "/src/2/second-output.d.ts.map" + ]; - assert.equal(actualReadFileMap.size, expectedMap.size, `Expected: ${JSON.stringify(arrayFrom(expectedMap.entries()))} \nActual: ${JSON.stringify(arrayFrom(actualReadFileMap.entries()))}`); - actualReadFileMap.forEach((value, key) => { - const expected = expectedMap.get(key); - assert.equal(value, expected, `Expected: ${JSON.stringify(arrayFrom(expectedMap.entries()))} \nActual: ${JSON.stringify(arrayFrom(actualReadFileMap.entries()))}`); + assert.equal(actualReadFileMap.size, expected.length, `Expected: ${JSON.stringify(expected)} \nActual: ${JSON.stringify(arrayFrom(actualReadFileMap.entries()))}`); + expected.forEach(expectedValue => { + const actual = actualReadFileMap.get(expectedValue); + assert.equal(actual, 1, `Mismatch in read file call number for: ${expectedValue}\nExpected: ${JSON.stringify(expected)} \nActual: ${JSON.stringify(arrayFrom(actualReadFileMap.entries()))}`); }); }); }); From 399f98791808e3ace7731aa89a26a3e246d02a30 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 24 Jan 2019 13:54:45 -0800 Subject: [PATCH 79/88] Add todos for sourcemap that accidently got reverted. --- src/compiler/factory.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 3707b725ed3..c59b2f67e98 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2699,9 +2699,9 @@ namespace ts { node.declarationMapPath = declarationMapPath; Object.defineProperties(node, { javascriptText: { get() { return definedTextGetter(declarationTextOrJavascriptPath); } }, - javascriptMapText: { get() { return textGetter(javascriptMapPath); } }, + javascriptMapText: { get() { return textGetter(javascriptMapPath); } }, // TODO:: if there is inline sourceMap in jsFile, use that declarationText: { get() { return definedTextGetter(Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } }, - declarationMapText: { get() { return textGetter(declarationMapPath); } } + declarationMapText: { get() { return textGetter(declarationMapPath); } } // TODO:: if there is inline sourceMap in dtsFile, use that }); } else { From ec817f55f3a143ca7b035c11cf88a621e4a6f0f1 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 24 Jan 2019 15:27:39 -0800 Subject: [PATCH 80/88] Fix unnecessary union --- src/compiler/factory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index c59b2f67e98..ab15bccafb0 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2632,7 +2632,7 @@ namespace ts { export function createUnparsedSourceFile(text: string): UnparsedSource; export function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts"): UnparsedSource; export function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; - export function createUnparsedSourceFile(textOrInputFiles: string | InputFiles, mapPathOrType?: string | "js" | "dts", map?: string): UnparsedSource { + export function createUnparsedSourceFile(textOrInputFiles: string | InputFiles, mapPathOrType?: string, map?: string): UnparsedSource { const node = createNode(SyntaxKind.UnparsedSource); if (!isString(textOrInputFiles)) { Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts"); From 0ddcab34690683feb577af8bdab876d74132008d Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 24 Jan 2019 15:37:13 -0800 Subject: [PATCH 81/88] Fix master: handle generating type name for late bound dupe message more nicely (#29572) * Fix master: handle generating type name for late bound dupe message more nicely * Make literal type casts more specific in many places to better reflect the checks performed --- src/compiler/checker.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f7e66b89a7b..8947f98f864 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4855,7 +4855,7 @@ namespace ts { function getLiteralPropertyNameText(name: PropertyName) { const type = getLiteralTypeFromPropertyName(name); - return type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral) ? "" + (type).value : undefined; + return type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral) ? "" + (type).value : undefined; } /** Return the inferred type for a binding element */ @@ -6450,12 +6450,12 @@ namespace ts { /** * Gets the symbolic name for a late-bound member from its type. */ - function getLateBoundNameFromType(type: LiteralType | UniqueESSymbolType): __String { + function getLateBoundNameFromType(type: StringLiteralType | NumberLiteralType | UniqueESSymbolType): __String { if (type.flags & TypeFlags.UniqueESSymbol) { return `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}` as __String; } if (type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral)) { - return escapeLeadingUnderscores("" + (type).value); + return escapeLeadingUnderscores("" + (type).value); } return Debug.fail(); } @@ -6534,7 +6534,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 = (type).value || declarationNameToString(decl.name); + const name = !(type.flags & TypeFlags.UniqueESSymbol) && unescapeLeadingUnderscores(memberName) || declarationNameToString(decl.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); @@ -9814,7 +9814,7 @@ namespace ts { if (accessNode) { const indexNode = getIndexNodeForAccessExpression(accessNode); if (indexType.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral)) { - error(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + (indexType).value, typeToString(objectType)); + error(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + (indexType).value, typeToString(objectType)); } else if (indexType.flags & (TypeFlags.String | TypeFlags.Number)) { error(indexNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); @@ -11759,11 +11759,11 @@ namespace ts { if (s & TypeFlags.StringLike && t & TypeFlags.String) return true; if (s & TypeFlags.StringLiteral && s & TypeFlags.EnumLiteral && t & TypeFlags.StringLiteral && !(t & TypeFlags.EnumLiteral) && - (source).value === (target).value) return true; + (source).value === (target).value) return true; if (s & TypeFlags.NumberLike && t & TypeFlags.Number) return true; if (s & TypeFlags.NumberLiteral && s & TypeFlags.EnumLiteral && t & TypeFlags.NumberLiteral && !(t & TypeFlags.EnumLiteral) && - (source).value === (target).value) return true; + (source).value === (target).value) return true; if (s & TypeFlags.BigIntLike && t & TypeFlags.BigInt) return true; if (s & TypeFlags.BooleanLike && t & TypeFlags.Boolean) return true; if (s & TypeFlags.ESSymbolLike && t & TypeFlags.ESSymbol) return true; @@ -13687,8 +13687,8 @@ namespace ts { // no flags for all other types (including non-falsy literal types). function getFalsyFlags(type: Type): TypeFlags { return type.flags & TypeFlags.Union ? getFalsyFlagsOfTypes((type).types) : - type.flags & TypeFlags.StringLiteral ? (type).value === "" ? TypeFlags.StringLiteral : 0 : - type.flags & TypeFlags.NumberLiteral ? (type).value === 0 ? TypeFlags.NumberLiteral : 0 : + type.flags & TypeFlags.StringLiteral ? (type).value === "" ? TypeFlags.StringLiteral : 0 : + type.flags & TypeFlags.NumberLiteral ? (type).value === 0 ? TypeFlags.NumberLiteral : 0 : type.flags & TypeFlags.BigIntLiteral ? isZeroBigInt(type) ? TypeFlags.BigIntLiteral : 0 : type.flags & TypeFlags.BooleanLiteral ? (type === falseType || type === regularFalseType) ? TypeFlags.BooleanLiteral : 0 : type.flags & TypeFlags.PossiblyFalsy; @@ -13711,8 +13711,8 @@ namespace ts { type === regularFalseType || type === falseType || type.flags & (TypeFlags.Void | TypeFlags.Undefined | TypeFlags.Null) || - type.flags & TypeFlags.StringLiteral && (type).value === "" || - type.flags & TypeFlags.NumberLiteral && (type).value === 0 || + type.flags & TypeFlags.StringLiteral && (type).value === "" || + type.flags & TypeFlags.NumberLiteral && (type).value === 0 || type.flags & TypeFlags.BigIntLiteral && isZeroBigInt(type) ? type : neverType; } @@ -15100,7 +15100,7 @@ namespace ts { return strictNullChecks ? TypeFacts.StringStrictFacts : TypeFacts.StringFacts; } if (flags & TypeFlags.StringLiteral) { - const isEmpty = (type).value === ""; + const isEmpty = (type).value === ""; return strictNullChecks ? isEmpty ? TypeFacts.EmptyStringStrictFacts : TypeFacts.NonEmptyStringStrictFacts : isEmpty ? TypeFacts.EmptyStringFacts : TypeFacts.NonEmptyStringFacts; @@ -15109,7 +15109,7 @@ namespace ts { return strictNullChecks ? TypeFacts.NumberStrictFacts : TypeFacts.NumberFacts; } if (flags & TypeFlags.NumberLiteral) { - const isZero = (type).value === 0; + const isZero = (type).value === 0; return strictNullChecks ? isZero ? TypeFacts.ZeroNumberStrictFacts : TypeFacts.NonZeroNumberStrictFacts : isZero ? TypeFacts.ZeroNumberFacts : TypeFacts.NonZeroNumberFacts; From d16cf761ba49d9e0579a0fe3f90fd5a7f52d0c44 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 24 Jan 2019 17:33:12 -0800 Subject: [PATCH 82/88] Move random file in root into test folder (#29575) --- .../cases/fourslash/completionAtDottedNamespace.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename completionAtDottedNamespace.ts => tests/cases/fourslash/completionAtDottedNamespace.ts (100%) diff --git a/completionAtDottedNamespace.ts b/tests/cases/fourslash/completionAtDottedNamespace.ts similarity index 100% rename from completionAtDottedNamespace.ts rename to tests/cases/fourslash/completionAtDottedNamespace.ts From b3f873631635810fdae9a0dd4771565bf326f2e5 Mon Sep 17 00:00:00 2001 From: Yang Cao Date: Fri, 25 Jan 2019 13:48:32 -0500 Subject: [PATCH 83/88] Remove extra http str in badge url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 57c2a54385d..2826db8aec6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Build Status](https://travis-ci.org/Microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/Microsoft/TypeScript) -[![VSTS Build Status](https://dev.azure.com/typescript/TypeScript/_apis/build/status/Typescript/node10)](https://https://dev.azure.com/typescript/TypeScript/_build/latest?definitionId=4&view=logs) +[![VSTS Build Status](https://dev.azure.com/typescript/TypeScript/_apis/build/status/Typescript/node10)](https://dev.azure.com/typescript/TypeScript/_build/latest?definitionId=4&view=logs) [![npm version](https://badge.fury.io/js/typescript.svg)](https://www.npmjs.com/package/typescript) [![Downloads](https://img.shields.io/npm/dm/typescript.svg)](https://www.npmjs.com/package/typescript) From f51939326a7cc1392765b86bd9768ba071ffa479 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 25 Jan 2019 10:52:00 -0800 Subject: [PATCH 84/88] Add tsserver task to gulp --- Gulpfile.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Gulpfile.js b/Gulpfile.js index c272caf2b6e..7a577ebafe1 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -215,6 +215,11 @@ const tsserverProject = "src/tsserver/tsconfig.json"; const tsserverJs = "built/local/tsserver.js"; gulp.task(tsserverJs, /*help*/ false, useCompilerDeps, () => project.compile(tsserverProject, { typescript: useCompiler })); +gulp.task( + "tsserver", + "Builds the language server", + [tsserverJs]); + const watchGuardProject = "src/watchGuard/tsconfig.json"; const watchGuardJs = "built/local/watchGuard.js"; gulp.task(watchGuardJs, /*help*/ false, useCompilerDeps, () => project.compile(watchGuardProject, { typescript: useCompiler })); From 74d41b926a04a354e0fe01236085f02ba25e44bb Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 25 Jan 2019 10:55:24 -0800 Subject: [PATCH 85/88] Fix crash in watch-local --- Gulpfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gulpfile.js b/Gulpfile.js index c272caf2b6e..cacaf4c3d00 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -542,7 +542,7 @@ const watchLocalPatterns = [ gulp.task( "watch-local", "Watches for changes to projects in src/ (but does not execute tests).", - () => gulp.watch(watchLocalPatterns, "local")); + () => gulp.watch(watchLocalPatterns, ["local"])); const watchPatterns = [ "src/tsconfig-base.json", @@ -632,4 +632,4 @@ gulp.task( "clean:scripts", "clean-rules", "clean-built" - ]); \ No newline at end of file + ]); From e51a2fe80d0b4f47dc4348ebcdf308e39895b846 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 25 Jan 2019 14:02:15 -0800 Subject: [PATCH 86/88] Skip declaration emit for files that are just executables --- Gulpfile.js | 2 +- Jakefile.js | 2 +- src/cancellationToken/tsconfig.json | 2 +- src/testRunner/tsconfig.json | 2 +- src/tsc/tsconfig.json | 2 +- src/tsconfig-noncomposite-base.json | 8 ++++++++ src/tsserver/tsconfig.json | 2 +- src/typingsInstaller/tsconfig.json | 2 +- src/watchGuard/tsconfig.json | 4 ++-- 9 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 src/tsconfig-noncomposite-base.json diff --git a/Gulpfile.js b/Gulpfile.js index cf80668cbd0..3aed88d3a70 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -138,7 +138,7 @@ gulp.task(typescriptServicesProject, /*help*/ false, () => { compilerOptions: { "removeComments": false, "stripInternal": true, - "declarationMap": false, + "declaration": true, "outFile": "typescriptServices.out.js" // must align with same task in jakefile. We fix this name below. } }); diff --git a/Jakefile.js b/Jakefile.js index 1413230c079..1a38e4d09e2 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -361,7 +361,7 @@ file(ConfigFileFor.tsserverLibrary, [], function () { compilerOptions: { "removeComments": false, "stripInternal": true, - "declarationMap": false, + "declaration": true, "outFile": "tsserverlibrary.out.js" } }) diff --git a/src/cancellationToken/tsconfig.json b/src/cancellationToken/tsconfig.json index e16ce22120e..6d9e0af7724 100644 --- a/src/cancellationToken/tsconfig.json +++ b/src/cancellationToken/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig-base", + "extends": "../tsconfig-noncomposite-base", "compilerOptions": { "outDir": "../../built/local/", "rootDir": ".", diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 2e5341732b5..3b3a477511e 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig-base", + "extends": "../tsconfig-noncomposite-base", "compilerOptions": { "outFile": "../../built/local/run.js", "composite": false, diff --git a/src/tsc/tsconfig.json b/src/tsc/tsconfig.json index 8bc02279930..e97cedc5de2 100644 --- a/src/tsc/tsconfig.json +++ b/src/tsc/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig-base", + "extends": "../tsconfig-noncomposite-base", "compilerOptions": { "outFile": "../../built/local/tsc.js" }, diff --git a/src/tsconfig-noncomposite-base.json b/src/tsconfig-noncomposite-base.json new file mode 100644 index 00000000000..569269f7562 --- /dev/null +++ b/src/tsconfig-noncomposite-base.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig-base", + "compilerOptions": { + "declaration": false, + "declarationMap": false, + "composite": false + } +} diff --git a/src/tsserver/tsconfig.json b/src/tsserver/tsconfig.json index 8f14785cd47..16ffd722f2d 100644 --- a/src/tsserver/tsconfig.json +++ b/src/tsserver/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig-base", + "extends": "../tsconfig-noncomposite-base", "compilerOptions": { "outFile": "../../built/local/tsserver.js", diff --git a/src/typingsInstaller/tsconfig.json b/src/typingsInstaller/tsconfig.json index 675c045ba00..143409e9e9a 100644 --- a/src/typingsInstaller/tsconfig.json +++ b/src/typingsInstaller/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig-base", + "extends": "../tsconfig-noncomposite-base", "compilerOptions": { "removeComments": true, "outFile": "../../built/local/typingsInstaller.js", diff --git a/src/watchGuard/tsconfig.json b/src/watchGuard/tsconfig.json index 7262a5db58e..aafa2270297 100644 --- a/src/watchGuard/tsconfig.json +++ b/src/watchGuard/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig-base", + "extends": "../tsconfig-noncomposite-base", "compilerOptions": { "removeComments": true, "outFile": "../../built/local/watchGuard.js", @@ -13,4 +13,4 @@ "files": [ "watchGuard.ts" ] -} \ No newline at end of file +} From 5f782bf58a5931f299a42d863aa7fac244d1e7a2 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 25 Jan 2019 15:18:07 -0800 Subject: [PATCH 87/88] Fixup restrictive instantiations to actually erase type parameter constraints (#29592) --- src/compiler/checker.ts | 6 +++++- .../typeParameterIndirectlyConstrainedToItself.errors.txt | 5 +---- .../typeParameterIndirectlyConstrainedToItself.types | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c96f93e1136..4c74b60766b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10636,7 +10636,11 @@ namespace ts { } function getRestrictiveTypeParameter(tp: TypeParameter) { - return !tp.constraint ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol)); + return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || ( + tp.restrictiveInstantiation = createTypeParameter(tp.symbol), + (tp.restrictiveInstantiation as TypeParameter).constraint = unknownType, + tp.restrictiveInstantiation + ); } function restrictiveMapper(type: Type) { diff --git a/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.errors.txt b/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.errors.txt index 8ca5c51ea2d..4dcf8530b01 100644 --- a/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.errors.txt +++ b/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.errors.txt @@ -25,10 +25,9 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterInd tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(16,47): error TS2313: Type parameter 'V' has a circular constraint. tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(18,32): error TS2313: Type parameter 'T' has a circular constraint. tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(18,45): error TS2313: Type parameter 'V' has a circular constraint. -tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(23,24): error TS2313: Type parameter 'S' has a circular constraint. -==== tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts (28 errors) ==== +==== tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts (27 errors) ==== class C { } ~ !!! error TS2313: Type parameter 'U' has a circular constraint. @@ -106,6 +105,4 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterInd type Foo = [T] extends [number] ? {} : {}; function foo>() {} - ~~~~~~ -!!! error TS2313: Type parameter 'S' has a circular constraint. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.types b/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.types index c2b20688fb5..637cb583d2e 100644 --- a/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.types +++ b/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.types @@ -38,5 +38,5 @@ type Foo = [T] extends [number] ? {} : {}; >Foo : Foo function foo>() {} ->foo : () => void +>foo : >() => void From 4da9d8bc87f356950496bde3d4a82d06bc5ce264 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 25 Jan 2019 15:22:35 -0800 Subject: [PATCH 88/88] Include index signatures of the source in mapped type template target inferences (#29253) --- src/compiler/checker.ts | 7 ++++++- src/compiler/core.ts | 7 +++++-- .../mappedToToIndexSignatureInference.js | 8 ++++++++ .../mappedToToIndexSignatureInference.symbols | 18 ++++++++++++++++++ .../mappedToToIndexSignatureInference.types | 14 ++++++++++++++ .../mappedToToIndexSignatureInference.ts | 3 +++ 6 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/mappedToToIndexSignatureInference.js create mode 100644 tests/baselines/reference/mappedToToIndexSignatureInference.symbols create mode 100644 tests/baselines/reference/mappedToToIndexSignatureInference.types create mode 100644 tests/cases/compiler/mappedToToIndexSignatureInference.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4c74b60766b..6385d150a3e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14574,7 +14574,12 @@ namespace ts { priority |= InferencePriority.MappedTypeConstraint; inferFromTypes(getIndexType(source), constraintType); priority = savePriority; - inferFromTypes(getUnionType(map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + const valueTypes = compact([ + getIndexTypeOfType(source, IndexKind.String), + getIndexTypeOfType(source, IndexKind.Number), + ...map(getPropertiesOfType(source), getTypeOfSymbol) + ]); + inferFromTypes(getUnionType(valueTypes), getTemplateTypeFromMappedType(target)); return true; } return false; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index d4f5fe9664a..fd4807fc586 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -884,8 +884,11 @@ namespace ts { /** * Compacts an array, removing any falsey elements. */ - export function compact(array: T[]): T[]; - export function compact(array: ReadonlyArray): ReadonlyArray; + export function compact(array: (T | undefined | null | false | 0 | "")[]): T[]; + export function compact(array: ReadonlyArray): ReadonlyArray; + // TSLint thinks these can be combined with the above - they cannot; they'd produce higher-priority inferences and prevent the falsey types from being stripped + export function compact(array: T[]): T[]; // tslint:disable-line unified-signatures + export function compact(array: ReadonlyArray): ReadonlyArray; // tslint:disable-line unified-signatures export function compact(array: T[]): T[] { let result: T[] | undefined; if (array) { diff --git a/tests/baselines/reference/mappedToToIndexSignatureInference.js b/tests/baselines/reference/mappedToToIndexSignatureInference.js new file mode 100644 index 00000000000..2ea09b663a9 --- /dev/null +++ b/tests/baselines/reference/mappedToToIndexSignatureInference.js @@ -0,0 +1,8 @@ +//// [mappedToToIndexSignatureInference.ts] +declare const fn: (object: { [Key in K]: V }) => object; +declare const a: { [index: string]: number }; +fn(a); + + +//// [mappedToToIndexSignatureInference.js] +fn(a); diff --git a/tests/baselines/reference/mappedToToIndexSignatureInference.symbols b/tests/baselines/reference/mappedToToIndexSignatureInference.symbols new file mode 100644 index 00000000000..d071f3f4c1c --- /dev/null +++ b/tests/baselines/reference/mappedToToIndexSignatureInference.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/mappedToToIndexSignatureInference.ts === +declare const fn: (object: { [Key in K]: V }) => object; +>fn : Symbol(fn, Decl(mappedToToIndexSignatureInference.ts, 0, 13)) +>K : Symbol(K, Decl(mappedToToIndexSignatureInference.ts, 0, 19)) +>V : Symbol(V, Decl(mappedToToIndexSignatureInference.ts, 0, 36)) +>object : Symbol(object, Decl(mappedToToIndexSignatureInference.ts, 0, 40)) +>Key : Symbol(Key, Decl(mappedToToIndexSignatureInference.ts, 0, 51)) +>K : Symbol(K, Decl(mappedToToIndexSignatureInference.ts, 0, 19)) +>V : Symbol(V, Decl(mappedToToIndexSignatureInference.ts, 0, 36)) + +declare const a: { [index: string]: number }; +>a : Symbol(a, Decl(mappedToToIndexSignatureInference.ts, 1, 13)) +>index : Symbol(index, Decl(mappedToToIndexSignatureInference.ts, 1, 20)) + +fn(a); +>fn : Symbol(fn, Decl(mappedToToIndexSignatureInference.ts, 0, 13)) +>a : Symbol(a, Decl(mappedToToIndexSignatureInference.ts, 1, 13)) + diff --git a/tests/baselines/reference/mappedToToIndexSignatureInference.types b/tests/baselines/reference/mappedToToIndexSignatureInference.types new file mode 100644 index 00000000000..35b9b3565e0 --- /dev/null +++ b/tests/baselines/reference/mappedToToIndexSignatureInference.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/mappedToToIndexSignatureInference.ts === +declare const fn: (object: { [Key in K]: V }) => object; +>fn : (object: { [Key in K]: V; }) => object +>object : { [Key in K]: V; } + +declare const a: { [index: string]: number }; +>a : { [index: string]: number; } +>index : string + +fn(a); +>fn(a) : object +>fn : (object: { [Key in K]: V; }) => object +>a : { [index: string]: number; } + diff --git a/tests/cases/compiler/mappedToToIndexSignatureInference.ts b/tests/cases/compiler/mappedToToIndexSignatureInference.ts new file mode 100644 index 00000000000..6ce63ead59c --- /dev/null +++ b/tests/cases/compiler/mappedToToIndexSignatureInference.ts @@ -0,0 +1,3 @@ +declare const fn: (object: { [Key in K]: V }) => object; +declare const a: { [index: string]: number }; +fn(a);