From d4f6b9b0a66e27de05debaf4ef4e2d733fe1ccfb Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Fri, 27 Jul 2018 21:08:22 +0200 Subject: [PATCH 001/113] allow BindingPattern in FunctionRestParameter also add downlevel emit for the destructured rest param Part of #6275 --- src/compiler/checker.ts | 4 --- src/compiler/transformers/es2015.ts | 26 ++++++++++++++++--- .../iterableArrayPattern14.errors.txt | 23 ---------------- .../iterableArrayPattern15.errors.txt | 23 ---------------- .../iterableArrayPattern16.errors.txt | 5 +--- .../iterableArrayPattern17.errors.txt | 5 +--- .../iterableArrayPattern20.errors.txt | 23 ---------------- .../iterableArrayPattern25.errors.txt | 5 +--- .../iterableArrayPattern26.errors.txt | 5 +--- .../iterableArrayPattern27.errors.txt | 8 ------ .../iterableArrayPattern28.errors.txt | 5 +--- .../iterableArrayPattern29.errors.txt | 5 +--- ...estParameterWithBindingPattern1.errors.txt | 7 ----- .../restParameterWithBindingPattern1.js | 8 +++++- ...estParameterWithBindingPattern2.errors.txt | 7 ----- .../restParameterWithBindingPattern2.js | 8 +++++- 16 files changed, 42 insertions(+), 125 deletions(-) delete mode 100644 tests/baselines/reference/iterableArrayPattern14.errors.txt delete mode 100644 tests/baselines/reference/iterableArrayPattern15.errors.txt delete mode 100644 tests/baselines/reference/iterableArrayPattern20.errors.txt delete mode 100644 tests/baselines/reference/iterableArrayPattern27.errors.txt delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern1.errors.txt delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern2.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2b255da7ae3..441de3a4253 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28570,10 +28570,6 @@ namespace ts { checkGrammarForDisallowedTrailingComma(parameters, Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } - if (isBindingPattern(parameter.name)) { - return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); - } - if (parameter.questionToken) { return grammarErrorOnNode(parameter.questionToken, Diagnostics.A_rest_parameter_cannot_be_optional); } diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index bffdc5809b0..89c87fa82b3 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -1340,8 +1340,8 @@ namespace ts { * part of a constructor declaration with a * synthesized call to `super` */ - function shouldAddRestParameter(node: ParameterDeclaration | undefined, inConstructorWithSynthesizedSuper: boolean) { - return node && node.dotDotDotToken && node.name.kind === SyntaxKind.Identifier && !inConstructorWithSynthesizedSuper; + function shouldAddRestParameter(node: ParameterDeclaration | undefined, inConstructorWithSynthesizedSuper: boolean): node is ParameterDeclaration { + return !!(node && node.dotDotDotToken && !inConstructorWithSynthesizedSuper); } /** @@ -1360,11 +1360,11 @@ namespace ts { } // `declarationName` is the name of the local declaration for the parameter. - const declarationName = getMutableClone(parameter!.name); + const declarationName = parameter.name.kind === SyntaxKind.Identifier ? getMutableClone(parameter.name) : createTempVariable(/*recordTempVariable*/ undefined); setEmitFlags(declarationName, EmitFlags.NoSourceMap); // `expressionName` is the name of the parameter used in expressions. - const expressionName = getSynthesizedClone(parameter!.name); + const expressionName = parameter.name.kind === SyntaxKind.Identifier ? getSynthesizedClone(parameter.name) : declarationName; const restIndex = node.parameters.length - 1; const temp = createLoopVariable(); @@ -1429,6 +1429,24 @@ namespace ts { setEmitFlags(forStatement, EmitFlags.CustomPrologue); startOnNewLine(forStatement); statements.push(forStatement); + + if (parameter.name.kind !== SyntaxKind.Identifier) { + // do the actual destructuring of the rest parameter if necessary + statements.push( + setEmitFlags( + setTextRange( + createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList( + flattenDestructuringBinding(parameter, visitor, context, FlattenLevel.All, expressionName), + ) + ), + parameter + ), + EmitFlags.CustomPrologue + ) + ); + } } /** diff --git a/tests/baselines/reference/iterableArrayPattern14.errors.txt b/tests/baselines/reference/iterableArrayPattern14.errors.txt deleted file mode 100644 index 664f73e13a0..00000000000 --- a/tests/baselines/reference/iterableArrayPattern14.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts(16,17): error TS2501: A rest element cannot contain a binding pattern. - - -==== tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts (1 errors) ==== - class Bar { x } - class Foo extends Bar { y } - class FooIterator { - next() { - return { - value: new Foo, - done: false - }; - } - - [Symbol.iterator]() { - return this; - } - } - - function fun(...[a, ...b]) { } - ~~~~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. - fun(new FooIterator); \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern15.errors.txt b/tests/baselines/reference/iterableArrayPattern15.errors.txt deleted file mode 100644 index ce7559de94f..00000000000 --- a/tests/baselines/reference/iterableArrayPattern15.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts(16,17): error TS2501: A rest element cannot contain a binding pattern. - - -==== tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts (1 errors) ==== - class Bar { x } - class Foo extends Bar { y } - class FooIterator { - next() { - return { - value: new Foo, - done: false - }; - } - - [Symbol.iterator]() { - return this; - } - } - - function fun(...[a, b]: Bar[]) { } - ~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. - fun(...new FooIterator); \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern16.errors.txt b/tests/baselines/reference/iterableArrayPattern16.errors.txt index b07d8c976a5..2de26b3a721 100644 --- a/tests/baselines/reference/iterableArrayPattern16.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern16.errors.txt @@ -1,13 +1,10 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(1,17): error TS2501: A rest element cannot contain a binding pattern. tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[Bar, Bar]'. Property '0' is missing in type 'FooIterator'. tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(2,12): error TS2449: Class 'FooIteratorIterator' used before its declaration. -==== tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts (3 errors) ==== +==== tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts (2 errors) ==== function fun(...[a, b]: [Bar, Bar][]) { } - ~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. fun(...new FooIteratorIterator); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[Bar, Bar]'. diff --git a/tests/baselines/reference/iterableArrayPattern17.errors.txt b/tests/baselines/reference/iterableArrayPattern17.errors.txt index d22d8580c71..09f8b8695a7 100644 --- a/tests/baselines/reference/iterableArrayPattern17.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern17.errors.txt @@ -1,9 +1,8 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(16,17): error TS2501: A rest element cannot contain a binding pattern. tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(17,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'. Property 'x' is missing in type 'FooIterator'. -==== tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts (2 errors) ==== +==== tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts (1 errors) ==== class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -20,8 +19,6 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(17,5): error } function fun(...[a, b]: Bar[]) { } - ~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. fun(new FooIterator); ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'. diff --git a/tests/baselines/reference/iterableArrayPattern20.errors.txt b/tests/baselines/reference/iterableArrayPattern20.errors.txt deleted file mode 100644 index 23f133238ce..00000000000 --- a/tests/baselines/reference/iterableArrayPattern20.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts(16,17): error TS2501: A rest element cannot contain a binding pattern. - - -==== tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts (1 errors) ==== - class Bar { x } - class Foo extends Bar { y } - class FooArrayIterator { - next() { - return { - value: [new Foo], - done: false - }; - } - - [Symbol.iterator]() { - return this; - } - } - - function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. - fun(...new FooArrayIterator); \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern25.errors.txt b/tests/baselines/reference/iterableArrayPattern25.errors.txt index 19f2dca07f3..0161be07d4b 100644 --- a/tests/baselines/reference/iterableArrayPattern25.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern25.errors.txt @@ -1,11 +1,8 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts(1,33): error TS2501: A rest element cannot contain a binding pattern. tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts(2,1): error TS2554: Expected 2 arguments, but got 1. -==== tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts (2 errors) ==== +==== tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts (1 errors) ==== function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) { } - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. takeFirstTwoEntries(new Map([["", 0], ["hello", 1]])); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 2 arguments, but got 1. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern26.errors.txt b/tests/baselines/reference/iterableArrayPattern26.errors.txt index a5eff0afb0d..9fb3e688039 100644 --- a/tests/baselines/reference/iterableArrayPattern26.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern26.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern26.ts(1,33): error TS2501: A rest element cannot contain a binding pattern. tests/cases/conformance/es6/destructuring/iterableArrayPattern26.ts(2,21): error TS2345: Argument of type 'Map' is not assignable to parameter of type '[string, number]'. Property '0' is missing in type 'Map'. -==== tests/cases/conformance/es6/destructuring/iterableArrayPattern26.ts (2 errors) ==== +==== tests/cases/conformance/es6/destructuring/iterableArrayPattern26.ts (1 errors) ==== function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { } - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. takeFirstTwoEntries(new Map([["", 0], ["hello", 1]])); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type 'Map' is not assignable to parameter of type '[string, number]'. diff --git a/tests/baselines/reference/iterableArrayPattern27.errors.txt b/tests/baselines/reference/iterableArrayPattern27.errors.txt deleted file mode 100644 index 99914ddc508..00000000000 --- a/tests/baselines/reference/iterableArrayPattern27.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern27.ts(1,33): error TS2501: A rest element cannot contain a binding pattern. - - -==== tests/cases/conformance/es6/destructuring/iterableArrayPattern27.ts (1 errors) ==== - function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { } - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. - takeFirstTwoEntries(...new Map([["", 0], ["hello", 1]])); \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern28.errors.txt b/tests/baselines/reference/iterableArrayPattern28.errors.txt index 7ca750cd81f..264cb8e7885 100644 --- a/tests/baselines/reference/iterableArrayPattern28.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern28.errors.txt @@ -1,4 +1,3 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(1,33): error TS2501: A rest element cannot contain a binding pattern. tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,32): error TS2345: Argument of type '([string, number] | [string, boolean])[]' is not assignable to parameter of type 'ReadonlyArray<[string, number]>'. Types of property 'concat' are incompatible. Type '{ (...items: ConcatArray<[string, number] | [string, boolean]>[]): ([string, number] | [string, boolean])[]; (...items: ([string, number] | [string, boolean] | ConcatArray<[string, number] | [string, boolean]>)[]): ([string, number] | [string, boolean])[]; }' is not assignable to type '{ (...items: ConcatArray<[string, number]>[]): [string, number][]; (...items: ([string, number] | ConcatArray<[string, number]>)[]): [string, number][]; }'. @@ -8,10 +7,8 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,32): error Type 'boolean' is not assignable to type 'number'. -==== tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts (2 errors) ==== +==== tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts (1 errors) ==== function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { } - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. takeFirstTwoEntries(...new Map([["", 0], ["hello", true]])); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '([string, number] | [string, boolean])[]' is not assignable to parameter of type 'ReadonlyArray<[string, number]>'. diff --git a/tests/baselines/reference/iterableArrayPattern29.errors.txt b/tests/baselines/reference/iterableArrayPattern29.errors.txt index 29e5d0d2a3f..a978e357cdf 100644 --- a/tests/baselines/reference/iterableArrayPattern29.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern29.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts(1,33): error TS2501: A rest element cannot contain a binding pattern. tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts(2,21): error TS2345: Argument of type '[string, boolean]' is not assignable to parameter of type '[string, number]'. Type 'boolean' is not assignable to type 'number'. -==== tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts (2 errors) ==== +==== tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts (1 errors) ==== function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { } - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. takeFirstTwoEntries(...new Map([["", true], ["hello", true]])); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[string, boolean]' is not assignable to parameter of type '[string, number]'. diff --git a/tests/baselines/reference/restParameterWithBindingPattern1.errors.txt b/tests/baselines/reference/restParameterWithBindingPattern1.errors.txt deleted file mode 100644 index 7194159a220..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern1.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/compiler/restParameterWithBindingPattern1.ts(1,15): error TS2501: A rest element cannot contain a binding pattern. - - -==== tests/cases/compiler/restParameterWithBindingPattern1.ts (1 errors) ==== - function a(...{a, b}) { } - ~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern1.js b/tests/baselines/reference/restParameterWithBindingPattern1.js index 9fb45768afe..eca1a760471 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern1.js +++ b/tests/baselines/reference/restParameterWithBindingPattern1.js @@ -2,4 +2,10 @@ function a(...{a, b}) { } //// [restParameterWithBindingPattern1.js] -function a() { } +function a() { + var _a = []; + for (var _i = 0; _i < arguments.length; _i++) { + _a[_i] = arguments[_i]; + } + var a = _a.a, b = _a.b; +} diff --git a/tests/baselines/reference/restParameterWithBindingPattern2.errors.txt b/tests/baselines/reference/restParameterWithBindingPattern2.errors.txt deleted file mode 100644 index e69e1c2ba78..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern2.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/compiler/restParameterWithBindingPattern2.ts(1,15): error TS2501: A rest element cannot contain a binding pattern. - - -==== tests/cases/compiler/restParameterWithBindingPattern2.ts (1 errors) ==== - function a(...[a, b]) { } - ~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern2.js b/tests/baselines/reference/restParameterWithBindingPattern2.js index 5c97769acbb..348023d7aa4 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern2.js +++ b/tests/baselines/reference/restParameterWithBindingPattern2.js @@ -2,4 +2,10 @@ function a(...[a, b]) { } //// [restParameterWithBindingPattern2.js] -function a() { } +function a() { + var _a = []; + for (var _i = 0; _i < arguments.length; _i++) { + _a[_i] = arguments[_i]; + } + var a = _a[0], b = _a[1]; +} From 421a5f2698fd3efa7ac2cbd898934d8c2e6d95ac Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Sat, 28 Jul 2018 08:50:08 +0200 Subject: [PATCH 002/113] add additional test for grammar and type checking --- .../restParameterWithBindingPattern3.errors.txt | 10 ++++++++++ .../reference/restParameterWithBindingPattern3.js | 11 +++++++++++ .../restParameterWithBindingPattern3.symbols | 6 ++++++ .../reference/restParameterWithBindingPattern3.types | 8 ++++++++ .../restParameterWithBindingPattern4.errors.txt | 7 +++++++ .../reference/restParameterWithBindingPattern4.js | 11 +++++++++++ .../restParameterWithBindingPattern4.symbols | 5 +++++ .../reference/restParameterWithBindingPattern4.types | 6 ++++++ .../reference/restParameterWithBindingPattern5.js | 11 +++++++++++ .../restParameterWithBindingPattern5.symbols | 7 +++++++ .../reference/restParameterWithBindingPattern5.types | 7 +++++++ .../restParameterWithBindingPattern6.errors.txt | 7 +++++++ .../reference/restParameterWithBindingPattern6.js | 11 +++++++++++ .../restParameterWithBindingPattern6.symbols | 6 ++++++ .../reference/restParameterWithBindingPattern6.types | 8 ++++++++ .../compiler/restParameterWithBindingPattern3.ts | 1 + .../compiler/restParameterWithBindingPattern4.ts | 1 + .../compiler/restParameterWithBindingPattern5.ts | 1 + .../compiler/restParameterWithBindingPattern6.ts | 1 + 19 files changed, 125 insertions(+) create mode 100644 tests/baselines/reference/restParameterWithBindingPattern3.errors.txt create mode 100644 tests/baselines/reference/restParameterWithBindingPattern3.js create mode 100644 tests/baselines/reference/restParameterWithBindingPattern3.symbols create mode 100644 tests/baselines/reference/restParameterWithBindingPattern3.types create mode 100644 tests/baselines/reference/restParameterWithBindingPattern4.errors.txt create mode 100644 tests/baselines/reference/restParameterWithBindingPattern4.js create mode 100644 tests/baselines/reference/restParameterWithBindingPattern4.symbols create mode 100644 tests/baselines/reference/restParameterWithBindingPattern4.types create mode 100644 tests/baselines/reference/restParameterWithBindingPattern5.js create mode 100644 tests/baselines/reference/restParameterWithBindingPattern5.symbols create mode 100644 tests/baselines/reference/restParameterWithBindingPattern5.types create mode 100644 tests/baselines/reference/restParameterWithBindingPattern6.errors.txt create mode 100644 tests/baselines/reference/restParameterWithBindingPattern6.js create mode 100644 tests/baselines/reference/restParameterWithBindingPattern6.symbols create mode 100644 tests/baselines/reference/restParameterWithBindingPattern6.types create mode 100644 tests/cases/compiler/restParameterWithBindingPattern3.ts create mode 100644 tests/cases/compiler/restParameterWithBindingPattern4.ts create mode 100644 tests/cases/compiler/restParameterWithBindingPattern5.ts create mode 100644 tests/cases/compiler/restParameterWithBindingPattern6.ts diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt b/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt new file mode 100644 index 00000000000..8b278ed3783 --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/restParameterWithBindingPattern3.ts(1,16): error TS2322: Type '1' is not assignable to type 'string'. +tests/cases/compiler/restParameterWithBindingPattern3.ts(1,23): error TS2322: Type 'true' is not assignable to type 'string'. + + +==== tests/cases/compiler/restParameterWithBindingPattern3.ts (2 errors) ==== + function a(...[a = 1, b = true]: string[]) { } + ~ +!!! error TS2322: Type '1' is not assignable to type 'string'. + ~ +!!! error TS2322: Type 'true' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.js b/tests/baselines/reference/restParameterWithBindingPattern3.js new file mode 100644 index 00000000000..86bda118119 --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern3.js @@ -0,0 +1,11 @@ +//// [restParameterWithBindingPattern3.ts] +function a(...[a = 1, b = true]: string[]) { } + +//// [restParameterWithBindingPattern3.js] +function a() { + var _a = []; + for (var _i = 0; _i < arguments.length; _i++) { + _a[_i] = arguments[_i]; + } + var _b = _a[0], a = _b === void 0 ? 1 : _b, _c = _a[1], b = _c === void 0 ? true : _c; +} diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.symbols b/tests/baselines/reference/restParameterWithBindingPattern3.symbols new file mode 100644 index 00000000000..09ffc4d8adc --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern3.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/restParameterWithBindingPattern3.ts === +function a(...[a = 1, b = true]: string[]) { } +>a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 0, 0)) +>a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 0, 15)) +>b : Symbol(b, Decl(restParameterWithBindingPattern3.ts, 0, 21)) + diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.types b/tests/baselines/reference/restParameterWithBindingPattern3.types new file mode 100644 index 00000000000..09b2f9143fe --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern3.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/restParameterWithBindingPattern3.ts === +function a(...[a = 1, b = true]: string[]) { } +>a : (...[a, b]: string[]) => void +>a : string +>1 : 1 +>b : string +>true : true + diff --git a/tests/baselines/reference/restParameterWithBindingPattern4.errors.txt b/tests/baselines/reference/restParameterWithBindingPattern4.errors.txt new file mode 100644 index 00000000000..355ab26c6c5 --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern4.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/restParameterWithBindingPattern4.ts(1,23): error TS1186: A rest element cannot have an initializer. + + +==== tests/cases/compiler/restParameterWithBindingPattern4.ts (1 errors) ==== + function a(...[...foo = []]: string[]) { } + ~ +!!! error TS1186: A rest element cannot have an initializer. \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern4.js b/tests/baselines/reference/restParameterWithBindingPattern4.js new file mode 100644 index 00000000000..348fa5a02bb --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern4.js @@ -0,0 +1,11 @@ +//// [restParameterWithBindingPattern4.ts] +function a(...[...foo = []]: string[]) { } + +//// [restParameterWithBindingPattern4.js] +function a() { + var _a = []; + for (var _i = 0; _i < arguments.length; _i++) { + _a[_i] = arguments[_i]; + } + var _b = _a.slice(0), foo = _b === void 0 ? [] : _b; +} diff --git a/tests/baselines/reference/restParameterWithBindingPattern4.symbols b/tests/baselines/reference/restParameterWithBindingPattern4.symbols new file mode 100644 index 00000000000..f281620423e --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern4.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/restParameterWithBindingPattern4.ts === +function a(...[...foo = []]: string[]) { } +>a : Symbol(a, Decl(restParameterWithBindingPattern4.ts, 0, 0)) +>foo : Symbol(foo, Decl(restParameterWithBindingPattern4.ts, 0, 15)) + diff --git a/tests/baselines/reference/restParameterWithBindingPattern4.types b/tests/baselines/reference/restParameterWithBindingPattern4.types new file mode 100644 index 00000000000..f4af66e9be7 --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern4.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/restParameterWithBindingPattern4.ts === +function a(...[...foo = []]: string[]) { } +>a : (...[...foo]: string[]) => void +>foo : string[] +>[] : undefined[] + diff --git a/tests/baselines/reference/restParameterWithBindingPattern5.js b/tests/baselines/reference/restParameterWithBindingPattern5.js new file mode 100644 index 00000000000..4bff99068e0 --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern5.js @@ -0,0 +1,11 @@ +//// [restParameterWithBindingPattern5.ts] +function a(...{0: a, length, 3: d}: [boolean, string, number]) { } + +//// [restParameterWithBindingPattern5.js] +function a() { + var _a = []; + for (var _i = 0; _i < arguments.length; _i++) { + _a[_i] = arguments[_i]; + } + var a = _a[0], length = _a.length, d = _a[3]; +} diff --git a/tests/baselines/reference/restParameterWithBindingPattern5.symbols b/tests/baselines/reference/restParameterWithBindingPattern5.symbols new file mode 100644 index 00000000000..a59b24f64f4 --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern5.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/restParameterWithBindingPattern5.ts === +function a(...{0: a, length, 3: d}: [boolean, string, number]) { } +>a : Symbol(a, Decl(restParameterWithBindingPattern5.ts, 0, 0)) +>a : Symbol(a, Decl(restParameterWithBindingPattern5.ts, 0, 15)) +>length : Symbol(length, Decl(restParameterWithBindingPattern5.ts, 0, 20)) +>d : Symbol(d, Decl(restParameterWithBindingPattern5.ts, 0, 28)) + diff --git a/tests/baselines/reference/restParameterWithBindingPattern5.types b/tests/baselines/reference/restParameterWithBindingPattern5.types new file mode 100644 index 00000000000..6986660adcd --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern5.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/restParameterWithBindingPattern5.ts === +function a(...{0: a, length, 3: d}: [boolean, string, number]) { } +>a : (__0_0: boolean, __0_1: string, __0_2: number) => void +>a : boolean +>length : 3 +>d : string | number | boolean + diff --git a/tests/baselines/reference/restParameterWithBindingPattern6.errors.txt b/tests/baselines/reference/restParameterWithBindingPattern6.errors.txt new file mode 100644 index 00000000000..6f590b2bb67 --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/restParameterWithBindingPattern6.ts(1,23): error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'. + + +==== tests/cases/compiler/restParameterWithBindingPattern6.ts (1 errors) ==== + function a(...[a, , , d]: [boolean, string, number]) { } + ~ +!!! error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'. \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern6.js b/tests/baselines/reference/restParameterWithBindingPattern6.js new file mode 100644 index 00000000000..02101d0fcdb --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern6.js @@ -0,0 +1,11 @@ +//// [restParameterWithBindingPattern6.ts] +function a(...[a, , , d]: [boolean, string, number]) { } + +//// [restParameterWithBindingPattern6.js] +function a() { + var _a = []; + for (var _i = 0; _i < arguments.length; _i++) { + _a[_i] = arguments[_i]; + } + var a = _a[0], d = _a[3]; +} diff --git a/tests/baselines/reference/restParameterWithBindingPattern6.symbols b/tests/baselines/reference/restParameterWithBindingPattern6.symbols new file mode 100644 index 00000000000..2c16d11e33f --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/restParameterWithBindingPattern6.ts === +function a(...[a, , , d]: [boolean, string, number]) { } +>a : Symbol(a, Decl(restParameterWithBindingPattern6.ts, 0, 0)) +>a : Symbol(a, Decl(restParameterWithBindingPattern6.ts, 0, 15)) +>d : Symbol(d, Decl(restParameterWithBindingPattern6.ts, 0, 21)) + diff --git a/tests/baselines/reference/restParameterWithBindingPattern6.types b/tests/baselines/reference/restParameterWithBindingPattern6.types new file mode 100644 index 00000000000..f0062077458 --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern6.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/restParameterWithBindingPattern6.ts === +function a(...[a, , , d]: [boolean, string, number]) { } +>a : (__0_0: boolean, __0_1: string, __0_2: number) => void +>a : boolean +> : undefined +> : undefined +>d : any + diff --git a/tests/cases/compiler/restParameterWithBindingPattern3.ts b/tests/cases/compiler/restParameterWithBindingPattern3.ts new file mode 100644 index 00000000000..920e00ac2e8 --- /dev/null +++ b/tests/cases/compiler/restParameterWithBindingPattern3.ts @@ -0,0 +1 @@ +function a(...[a = 1, b = true]: string[]) { } \ No newline at end of file diff --git a/tests/cases/compiler/restParameterWithBindingPattern4.ts b/tests/cases/compiler/restParameterWithBindingPattern4.ts new file mode 100644 index 00000000000..fee0067bd50 --- /dev/null +++ b/tests/cases/compiler/restParameterWithBindingPattern4.ts @@ -0,0 +1 @@ +function a(...[...foo = []]: string[]) { } \ No newline at end of file diff --git a/tests/cases/compiler/restParameterWithBindingPattern5.ts b/tests/cases/compiler/restParameterWithBindingPattern5.ts new file mode 100644 index 00000000000..7707a99b11e --- /dev/null +++ b/tests/cases/compiler/restParameterWithBindingPattern5.ts @@ -0,0 +1 @@ +function a(...{0: a, length, 3: d}: [boolean, string, number]) { } \ No newline at end of file diff --git a/tests/cases/compiler/restParameterWithBindingPattern6.ts b/tests/cases/compiler/restParameterWithBindingPattern6.ts new file mode 100644 index 00000000000..ae95ad8c4d9 --- /dev/null +++ b/tests/cases/compiler/restParameterWithBindingPattern6.ts @@ -0,0 +1 @@ +function a(...[a, , , d]: [boolean, string, number]) { } \ No newline at end of file From 3894d0524c918883763a658bd0c11c3b9cc2af36 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Mon, 30 Jul 2018 16:13:22 +0200 Subject: [PATCH 003/113] merge tests --- ...estParameterWithBindingPattern3.errors.txt | 16 ++++++++-- .../restParameterWithBindingPattern3.js | 29 ++++++++++++++++++- .../restParameterWithBindingPattern3.symbols | 15 ++++++++++ .../restParameterWithBindingPattern3.types | 18 ++++++++++++ ...estParameterWithBindingPattern4.errors.txt | 7 ----- .../restParameterWithBindingPattern4.js | 11 ------- .../restParameterWithBindingPattern4.symbols | 5 ---- .../restParameterWithBindingPattern4.types | 6 ---- .../restParameterWithBindingPattern5.js | 11 ------- .../restParameterWithBindingPattern5.symbols | 7 ----- .../restParameterWithBindingPattern5.types | 7 ----- ...estParameterWithBindingPattern6.errors.txt | 7 ----- .../restParameterWithBindingPattern6.js | 11 ------- .../restParameterWithBindingPattern6.symbols | 6 ---- .../restParameterWithBindingPattern6.types | 8 ----- .../restParameterWithBindingPattern3.ts | 8 ++++- .../restParameterWithBindingPattern4.ts | 1 - .../restParameterWithBindingPattern5.ts | 1 - .../restParameterWithBindingPattern6.ts | 1 - 19 files changed, 82 insertions(+), 93 deletions(-) delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern4.errors.txt delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern4.js delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern4.symbols delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern4.types delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern5.js delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern5.symbols delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern5.types delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern6.errors.txt delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern6.js delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern6.symbols delete mode 100644 tests/baselines/reference/restParameterWithBindingPattern6.types delete mode 100644 tests/cases/compiler/restParameterWithBindingPattern4.ts delete mode 100644 tests/cases/compiler/restParameterWithBindingPattern5.ts delete mode 100644 tests/cases/compiler/restParameterWithBindingPattern6.ts diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt b/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt index 8b278ed3783..ea6bda983d8 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt +++ b/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt @@ -1,10 +1,22 @@ tests/cases/compiler/restParameterWithBindingPattern3.ts(1,16): error TS2322: Type '1' is not assignable to type 'string'. tests/cases/compiler/restParameterWithBindingPattern3.ts(1,23): error TS2322: Type 'true' is not assignable to type 'string'. +tests/cases/compiler/restParameterWithBindingPattern3.ts(3,23): error TS1186: A rest element cannot have an initializer. +tests/cases/compiler/restParameterWithBindingPattern3.ts(7,23): error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'. -==== tests/cases/compiler/restParameterWithBindingPattern3.ts (2 errors) ==== +==== tests/cases/compiler/restParameterWithBindingPattern3.ts (4 errors) ==== function a(...[a = 1, b = true]: string[]) { } ~ !!! error TS2322: Type '1' is not assignable to type 'string'. ~ -!!! error TS2322: Type 'true' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2322: Type 'true' is not assignable to type 'string'. + + function b(...[...foo = []]: string[]) { } + ~ +!!! error TS1186: A rest element cannot have an initializer. + + function c(...{0: a, length, 3: d}: [boolean, string, number]) { } + + function d(...[a, , , d]: [boolean, string, number]) { } + ~ +!!! error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'. \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.js b/tests/baselines/reference/restParameterWithBindingPattern3.js index 86bda118119..da3531633b6 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.js +++ b/tests/baselines/reference/restParameterWithBindingPattern3.js @@ -1,5 +1,11 @@ //// [restParameterWithBindingPattern3.ts] -function a(...[a = 1, b = true]: string[]) { } +function a(...[a = 1, b = true]: string[]) { } + +function b(...[...foo = []]: string[]) { } + +function c(...{0: a, length, 3: d}: [boolean, string, number]) { } + +function d(...[a, , , d]: [boolean, string, number]) { } //// [restParameterWithBindingPattern3.js] function a() { @@ -9,3 +15,24 @@ function a() { } var _b = _a[0], a = _b === void 0 ? 1 : _b, _c = _a[1], b = _c === void 0 ? true : _c; } +function b() { + var _a = []; + for (var _i = 0; _i < arguments.length; _i++) { + _a[_i] = arguments[_i]; + } + var _b = _a.slice(0), foo = _b === void 0 ? [] : _b; +} +function c() { + var _a = []; + for (var _i = 0; _i < arguments.length; _i++) { + _a[_i] = arguments[_i]; + } + var a = _a[0], length = _a.length, d = _a[3]; +} +function d() { + var _a = []; + for (var _i = 0; _i < arguments.length; _i++) { + _a[_i] = arguments[_i]; + } + var a = _a[0], d = _a[3]; +} diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.symbols b/tests/baselines/reference/restParameterWithBindingPattern3.symbols index 09ffc4d8adc..2694c7327da 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.symbols +++ b/tests/baselines/reference/restParameterWithBindingPattern3.symbols @@ -4,3 +4,18 @@ function a(...[a = 1, b = true]: string[]) { } >a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 0, 15)) >b : Symbol(b, Decl(restParameterWithBindingPattern3.ts, 0, 21)) +function b(...[...foo = []]: string[]) { } +>b : Symbol(b, Decl(restParameterWithBindingPattern3.ts, 0, 46)) +>foo : Symbol(foo, Decl(restParameterWithBindingPattern3.ts, 2, 15)) + +function c(...{0: a, length, 3: d}: [boolean, string, number]) { } +>c : Symbol(c, Decl(restParameterWithBindingPattern3.ts, 2, 42)) +>a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 4, 15)) +>length : Symbol(length, Decl(restParameterWithBindingPattern3.ts, 4, 20)) +>d : Symbol(d, Decl(restParameterWithBindingPattern3.ts, 4, 28)) + +function d(...[a, , , d]: [boolean, string, number]) { } +>d : Symbol(d, Decl(restParameterWithBindingPattern3.ts, 4, 66)) +>a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 6, 15)) +>d : Symbol(d, Decl(restParameterWithBindingPattern3.ts, 6, 21)) + diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.types b/tests/baselines/reference/restParameterWithBindingPattern3.types index 09b2f9143fe..7ab8bdf621a 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.types +++ b/tests/baselines/reference/restParameterWithBindingPattern3.types @@ -6,3 +6,21 @@ function a(...[a = 1, b = true]: string[]) { } >b : string >true : true +function b(...[...foo = []]: string[]) { } +>b : (...[...foo]: string[]) => void +>foo : string[] +>[] : undefined[] + +function c(...{0: a, length, 3: d}: [boolean, string, number]) { } +>c : (__0_0: boolean, __0_1: string, __0_2: number) => void +>a : boolean +>length : 3 +>d : string | number | boolean + +function d(...[a, , , d]: [boolean, string, number]) { } +>d : (__0_0: boolean, __0_1: string, __0_2: number) => void +>a : boolean +> : undefined +> : undefined +>d : any + diff --git a/tests/baselines/reference/restParameterWithBindingPattern4.errors.txt b/tests/baselines/reference/restParameterWithBindingPattern4.errors.txt deleted file mode 100644 index 355ab26c6c5..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern4.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/compiler/restParameterWithBindingPattern4.ts(1,23): error TS1186: A rest element cannot have an initializer. - - -==== tests/cases/compiler/restParameterWithBindingPattern4.ts (1 errors) ==== - function a(...[...foo = []]: string[]) { } - ~ -!!! error TS1186: A rest element cannot have an initializer. \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern4.js b/tests/baselines/reference/restParameterWithBindingPattern4.js deleted file mode 100644 index 348fa5a02bb..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern4.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [restParameterWithBindingPattern4.ts] -function a(...[...foo = []]: string[]) { } - -//// [restParameterWithBindingPattern4.js] -function a() { - var _a = []; - for (var _i = 0; _i < arguments.length; _i++) { - _a[_i] = arguments[_i]; - } - var _b = _a.slice(0), foo = _b === void 0 ? [] : _b; -} diff --git a/tests/baselines/reference/restParameterWithBindingPattern4.symbols b/tests/baselines/reference/restParameterWithBindingPattern4.symbols deleted file mode 100644 index f281620423e..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern4.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/restParameterWithBindingPattern4.ts === -function a(...[...foo = []]: string[]) { } ->a : Symbol(a, Decl(restParameterWithBindingPattern4.ts, 0, 0)) ->foo : Symbol(foo, Decl(restParameterWithBindingPattern4.ts, 0, 15)) - diff --git a/tests/baselines/reference/restParameterWithBindingPattern4.types b/tests/baselines/reference/restParameterWithBindingPattern4.types deleted file mode 100644 index f4af66e9be7..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern4.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/restParameterWithBindingPattern4.ts === -function a(...[...foo = []]: string[]) { } ->a : (...[...foo]: string[]) => void ->foo : string[] ->[] : undefined[] - diff --git a/tests/baselines/reference/restParameterWithBindingPattern5.js b/tests/baselines/reference/restParameterWithBindingPattern5.js deleted file mode 100644 index 4bff99068e0..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern5.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [restParameterWithBindingPattern5.ts] -function a(...{0: a, length, 3: d}: [boolean, string, number]) { } - -//// [restParameterWithBindingPattern5.js] -function a() { - var _a = []; - for (var _i = 0; _i < arguments.length; _i++) { - _a[_i] = arguments[_i]; - } - var a = _a[0], length = _a.length, d = _a[3]; -} diff --git a/tests/baselines/reference/restParameterWithBindingPattern5.symbols b/tests/baselines/reference/restParameterWithBindingPattern5.symbols deleted file mode 100644 index a59b24f64f4..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern5.symbols +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/compiler/restParameterWithBindingPattern5.ts === -function a(...{0: a, length, 3: d}: [boolean, string, number]) { } ->a : Symbol(a, Decl(restParameterWithBindingPattern5.ts, 0, 0)) ->a : Symbol(a, Decl(restParameterWithBindingPattern5.ts, 0, 15)) ->length : Symbol(length, Decl(restParameterWithBindingPattern5.ts, 0, 20)) ->d : Symbol(d, Decl(restParameterWithBindingPattern5.ts, 0, 28)) - diff --git a/tests/baselines/reference/restParameterWithBindingPattern5.types b/tests/baselines/reference/restParameterWithBindingPattern5.types deleted file mode 100644 index 6986660adcd..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern5.types +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/compiler/restParameterWithBindingPattern5.ts === -function a(...{0: a, length, 3: d}: [boolean, string, number]) { } ->a : (__0_0: boolean, __0_1: string, __0_2: number) => void ->a : boolean ->length : 3 ->d : string | number | boolean - diff --git a/tests/baselines/reference/restParameterWithBindingPattern6.errors.txt b/tests/baselines/reference/restParameterWithBindingPattern6.errors.txt deleted file mode 100644 index 6f590b2bb67..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/compiler/restParameterWithBindingPattern6.ts(1,23): error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'. - - -==== tests/cases/compiler/restParameterWithBindingPattern6.ts (1 errors) ==== - function a(...[a, , , d]: [boolean, string, number]) { } - ~ -!!! error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'. \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern6.js b/tests/baselines/reference/restParameterWithBindingPattern6.js deleted file mode 100644 index 02101d0fcdb..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern6.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [restParameterWithBindingPattern6.ts] -function a(...[a, , , d]: [boolean, string, number]) { } - -//// [restParameterWithBindingPattern6.js] -function a() { - var _a = []; - for (var _i = 0; _i < arguments.length; _i++) { - _a[_i] = arguments[_i]; - } - var a = _a[0], d = _a[3]; -} diff --git a/tests/baselines/reference/restParameterWithBindingPattern6.symbols b/tests/baselines/reference/restParameterWithBindingPattern6.symbols deleted file mode 100644 index 2c16d11e33f..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern6.symbols +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/restParameterWithBindingPattern6.ts === -function a(...[a, , , d]: [boolean, string, number]) { } ->a : Symbol(a, Decl(restParameterWithBindingPattern6.ts, 0, 0)) ->a : Symbol(a, Decl(restParameterWithBindingPattern6.ts, 0, 15)) ->d : Symbol(d, Decl(restParameterWithBindingPattern6.ts, 0, 21)) - diff --git a/tests/baselines/reference/restParameterWithBindingPattern6.types b/tests/baselines/reference/restParameterWithBindingPattern6.types deleted file mode 100644 index f0062077458..00000000000 --- a/tests/baselines/reference/restParameterWithBindingPattern6.types +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/compiler/restParameterWithBindingPattern6.ts === -function a(...[a, , , d]: [boolean, string, number]) { } ->a : (__0_0: boolean, __0_1: string, __0_2: number) => void ->a : boolean -> : undefined -> : undefined ->d : any - diff --git a/tests/cases/compiler/restParameterWithBindingPattern3.ts b/tests/cases/compiler/restParameterWithBindingPattern3.ts index 920e00ac2e8..93d0daae538 100644 --- a/tests/cases/compiler/restParameterWithBindingPattern3.ts +++ b/tests/cases/compiler/restParameterWithBindingPattern3.ts @@ -1 +1,7 @@ -function a(...[a = 1, b = true]: string[]) { } \ No newline at end of file +function a(...[a = 1, b = true]: string[]) { } + +function b(...[...foo = []]: string[]) { } + +function c(...{0: a, length, 3: d}: [boolean, string, number]) { } + +function d(...[a, , , d]: [boolean, string, number]) { } \ No newline at end of file diff --git a/tests/cases/compiler/restParameterWithBindingPattern4.ts b/tests/cases/compiler/restParameterWithBindingPattern4.ts deleted file mode 100644 index fee0067bd50..00000000000 --- a/tests/cases/compiler/restParameterWithBindingPattern4.ts +++ /dev/null @@ -1 +0,0 @@ -function a(...[...foo = []]: string[]) { } \ No newline at end of file diff --git a/tests/cases/compiler/restParameterWithBindingPattern5.ts b/tests/cases/compiler/restParameterWithBindingPattern5.ts deleted file mode 100644 index 7707a99b11e..00000000000 --- a/tests/cases/compiler/restParameterWithBindingPattern5.ts +++ /dev/null @@ -1 +0,0 @@ -function a(...{0: a, length, 3: d}: [boolean, string, number]) { } \ No newline at end of file diff --git a/tests/cases/compiler/restParameterWithBindingPattern6.ts b/tests/cases/compiler/restParameterWithBindingPattern6.ts deleted file mode 100644 index ae95ad8c4d9..00000000000 --- a/tests/cases/compiler/restParameterWithBindingPattern6.ts +++ /dev/null @@ -1 +0,0 @@ -function a(...[a, , , d]: [boolean, string, number]) { } \ No newline at end of file From 5b122dbad6d72e6df49e2e0dc5f07a4f601ba699 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Mon, 30 Jul 2018 16:22:25 +0200 Subject: [PATCH 004/113] test sourceMap --- .../restParameterWithBindingPattern2.js | 1 + .../restParameterWithBindingPattern2.js.map | 2 + ...ParameterWithBindingPattern2.sourcemap.txt | 90 +++++++++++++++++++ .../restParameterWithBindingPattern2.ts | 2 + 4 files changed, 95 insertions(+) create mode 100644 tests/baselines/reference/restParameterWithBindingPattern2.js.map create mode 100644 tests/baselines/reference/restParameterWithBindingPattern2.sourcemap.txt diff --git a/tests/baselines/reference/restParameterWithBindingPattern2.js b/tests/baselines/reference/restParameterWithBindingPattern2.js index 348023d7aa4..acef0954194 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern2.js +++ b/tests/baselines/reference/restParameterWithBindingPattern2.js @@ -9,3 +9,4 @@ function a() { } var a = _a[0], b = _a[1]; } +//# sourceMappingURL=restParameterWithBindingPattern2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern2.js.map b/tests/baselines/reference/restParameterWithBindingPattern2.js.map new file mode 100644 index 00000000000..1e25b0f14be --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern2.js.map @@ -0,0 +1,2 @@ +//// [restParameterWithBindingPattern2.js.map] +{"version":3,"file":"restParameterWithBindingPattern2.js","sourceRoot":"","sources":["restParameterWithBindingPattern2.ts"],"names":[],"mappings":"AAAA,SAAS,CAAC;IAAC,YAAS;SAAT,UAAS,EAAT,qBAAS,EAAT,IAAS;QAAT,uBAAS;;IAAT,IAAI,SAAC,EAAE,SAAC,CAAC;AAAI,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern2.sourcemap.txt b/tests/baselines/reference/restParameterWithBindingPattern2.sourcemap.txt new file mode 100644 index 00000000000..7cd85ba9deb --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern2.sourcemap.txt @@ -0,0 +1,90 @@ +=================================================================== +JsFile: restParameterWithBindingPattern2.js +mapUrl: restParameterWithBindingPattern2.js.map +sourceRoot: +sources: restParameterWithBindingPattern2.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/restParameterWithBindingPattern2.js +sourceFile:restParameterWithBindingPattern2.ts +------------------------------------------------------------------- +>>>function a() { +1 > +2 >^^^^^^^^^ +3 > ^ +4 > ^^^^^^^-> +1 > +2 >function +3 > a +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 10) Source(1, 10) + SourceIndex(0) +3 >Emitted(1, 11) Source(1, 11) + SourceIndex(0) +--- +>>> var _a = []; +1->^^^^ +2 > ^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1->( +2 > ...[a, b] +1->Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 17) Source(1, 21) + SourceIndex(0) +--- +>>> for (var _i = 0; _i < arguments.length; _i++) { +1->^^^^^^^^^ +2 > ^^^^^^^^^^ +3 > ^^ +4 > ^^^^^^^^^^^^^^^^^^^^^ +5 > ^^ +6 > ^^^^ +1-> +2 > ...[a, b] +3 > +4 > ...[a, b] +5 > +6 > ...[a, b] +1->Emitted(3, 10) Source(1, 12) + SourceIndex(0) +2 >Emitted(3, 20) Source(1, 21) + SourceIndex(0) +3 >Emitted(3, 22) Source(1, 12) + SourceIndex(0) +4 >Emitted(3, 43) Source(1, 21) + SourceIndex(0) +5 >Emitted(3, 45) Source(1, 12) + SourceIndex(0) +6 >Emitted(3, 49) Source(1, 21) + SourceIndex(0) +--- +>>> _a[_i] = arguments[_i]; +1 >^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 > ...[a, b] +1 >Emitted(4, 9) Source(1, 12) + SourceIndex(0) +2 >Emitted(4, 32) Source(1, 21) + SourceIndex(0) +--- +>>> } +>>> var a = _a[0], b = _a[1]; +1 >^^^^ +2 > ^^^^ +3 > ^^^^^^^^^ +4 > ^^ +5 > ^^^^^^^^^ +6 > ^ +1 > +2 > ...[ +3 > a +4 > , +5 > b +6 > ] +1 >Emitted(6, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(6, 9) Source(1, 16) + SourceIndex(0) +3 >Emitted(6, 18) Source(1, 17) + SourceIndex(0) +4 >Emitted(6, 20) Source(1, 19) + SourceIndex(0) +5 >Emitted(6, 29) Source(1, 20) + SourceIndex(0) +6 >Emitted(6, 30) Source(1, 21) + SourceIndex(0) +--- +>>>} +1 > +2 >^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 >) { +2 >} +1 >Emitted(7, 1) Source(1, 25) + SourceIndex(0) +2 >Emitted(7, 2) Source(1, 26) + SourceIndex(0) +--- +>>>//# sourceMappingURL=restParameterWithBindingPattern2.js.map \ No newline at end of file diff --git a/tests/cases/compiler/restParameterWithBindingPattern2.ts b/tests/cases/compiler/restParameterWithBindingPattern2.ts index 85076703b79..d7057885040 100644 --- a/tests/cases/compiler/restParameterWithBindingPattern2.ts +++ b/tests/cases/compiler/restParameterWithBindingPattern2.ts @@ -1 +1,3 @@ +// @sourcemap: true + function a(...[a, b]) { } \ No newline at end of file From 63c80ddaf5e046befdff3e6c6e19564ff193ea99 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Wed, 1 Aug 2018 11:12:47 +0200 Subject: [PATCH 005/113] additional test --- .../restParameterWithBindingPattern1.js | 1 + .../restParameterWithBindingPattern1.js.map | 2 + ...ParameterWithBindingPattern1.sourcemap.txt | 90 +++++++++++++++++++ ...estParameterWithBindingPattern3.errors.txt | 15 +++- .../restParameterWithBindingPattern3.js | 20 ++++- .../restParameterWithBindingPattern3.symbols | 6 ++ .../restParameterWithBindingPattern3.types | 9 ++ .../restParameterWithBindingPattern1.ts | 2 + .../restParameterWithBindingPattern3.ts | 4 +- 9 files changed, 145 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/restParameterWithBindingPattern1.js.map create mode 100644 tests/baselines/reference/restParameterWithBindingPattern1.sourcemap.txt diff --git a/tests/baselines/reference/restParameterWithBindingPattern1.js b/tests/baselines/reference/restParameterWithBindingPattern1.js index eca1a760471..d872d232450 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern1.js +++ b/tests/baselines/reference/restParameterWithBindingPattern1.js @@ -9,3 +9,4 @@ function a() { } var a = _a.a, b = _a.b; } +//# sourceMappingURL=restParameterWithBindingPattern1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern1.js.map b/tests/baselines/reference/restParameterWithBindingPattern1.js.map new file mode 100644 index 00000000000..94c277257b9 --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern1.js.map @@ -0,0 +1,2 @@ +//// [restParameterWithBindingPattern1.js.map] +{"version":3,"file":"restParameterWithBindingPattern1.js","sourceRoot":"","sources":["restParameterWithBindingPattern1.ts"],"names":[],"mappings":"AAAA,SAAS,CAAC;IAAC,YAAS;SAAT,UAAS,EAAT,qBAAS,EAAT,IAAS;QAAT,uBAAS;;IAAT,IAAI,QAAC,EAAE,QAAC,CAAC;AAAI,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern1.sourcemap.txt b/tests/baselines/reference/restParameterWithBindingPattern1.sourcemap.txt new file mode 100644 index 00000000000..a5aa2351bc0 --- /dev/null +++ b/tests/baselines/reference/restParameterWithBindingPattern1.sourcemap.txt @@ -0,0 +1,90 @@ +=================================================================== +JsFile: restParameterWithBindingPattern1.js +mapUrl: restParameterWithBindingPattern1.js.map +sourceRoot: +sources: restParameterWithBindingPattern1.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/restParameterWithBindingPattern1.js +sourceFile:restParameterWithBindingPattern1.ts +------------------------------------------------------------------- +>>>function a() { +1 > +2 >^^^^^^^^^ +3 > ^ +4 > ^^^^^^^-> +1 > +2 >function +3 > a +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 10) Source(1, 10) + SourceIndex(0) +3 >Emitted(1, 11) Source(1, 11) + SourceIndex(0) +--- +>>> var _a = []; +1->^^^^ +2 > ^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1->( +2 > ...{a, b} +1->Emitted(2, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(2, 17) Source(1, 21) + SourceIndex(0) +--- +>>> for (var _i = 0; _i < arguments.length; _i++) { +1->^^^^^^^^^ +2 > ^^^^^^^^^^ +3 > ^^ +4 > ^^^^^^^^^^^^^^^^^^^^^ +5 > ^^ +6 > ^^^^ +1-> +2 > ...{a, b} +3 > +4 > ...{a, b} +5 > +6 > ...{a, b} +1->Emitted(3, 10) Source(1, 12) + SourceIndex(0) +2 >Emitted(3, 20) Source(1, 21) + SourceIndex(0) +3 >Emitted(3, 22) Source(1, 12) + SourceIndex(0) +4 >Emitted(3, 43) Source(1, 21) + SourceIndex(0) +5 >Emitted(3, 45) Source(1, 12) + SourceIndex(0) +6 >Emitted(3, 49) Source(1, 21) + SourceIndex(0) +--- +>>> _a[_i] = arguments[_i]; +1 >^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 > ...{a, b} +1 >Emitted(4, 9) Source(1, 12) + SourceIndex(0) +2 >Emitted(4, 32) Source(1, 21) + SourceIndex(0) +--- +>>> } +>>> var a = _a.a, b = _a.b; +1 >^^^^ +2 > ^^^^ +3 > ^^^^^^^^ +4 > ^^ +5 > ^^^^^^^^ +6 > ^ +1 > +2 > ...{ +3 > a +4 > , +5 > b +6 > } +1 >Emitted(6, 5) Source(1, 12) + SourceIndex(0) +2 >Emitted(6, 9) Source(1, 16) + SourceIndex(0) +3 >Emitted(6, 17) Source(1, 17) + SourceIndex(0) +4 >Emitted(6, 19) Source(1, 19) + SourceIndex(0) +5 >Emitted(6, 27) Source(1, 20) + SourceIndex(0) +6 >Emitted(6, 28) Source(1, 21) + SourceIndex(0) +--- +>>>} +1 > +2 >^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 >) { +2 >} +1 >Emitted(7, 1) Source(1, 25) + SourceIndex(0) +2 >Emitted(7, 2) Source(1, 26) + SourceIndex(0) +--- +>>>//# sourceMappingURL=restParameterWithBindingPattern1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt b/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt index ea6bda983d8..2ad62269f50 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt +++ b/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt @@ -2,9 +2,12 @@ tests/cases/compiler/restParameterWithBindingPattern3.ts(1,16): error TS2322: Ty tests/cases/compiler/restParameterWithBindingPattern3.ts(1,23): error TS2322: Type 'true' is not assignable to type 'string'. tests/cases/compiler/restParameterWithBindingPattern3.ts(3,23): error TS1186: A rest element cannot have an initializer. tests/cases/compiler/restParameterWithBindingPattern3.ts(7,23): error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'. +tests/cases/compiler/restParameterWithBindingPattern3.ts(9,19): error TS2322: Type '1' is not assignable to type 'boolean'. +tests/cases/compiler/restParameterWithBindingPattern3.ts(9,29): error TS2322: Type 'true' is not assignable to type 'string'. +tests/cases/compiler/restParameterWithBindingPattern3.ts(9,48): error TS2566: A rest element cannot have a property name. -==== tests/cases/compiler/restParameterWithBindingPattern3.ts (4 errors) ==== +==== tests/cases/compiler/restParameterWithBindingPattern3.ts (7 errors) ==== function a(...[a = 1, b = true]: string[]) { } ~ !!! error TS2322: Type '1' is not assignable to type 'string'. @@ -19,4 +22,12 @@ tests/cases/compiler/restParameterWithBindingPattern3.ts(7,23): error TS2493: Tu function d(...[a, , , d]: [boolean, string, number]) { } ~ -!!! error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'. \ No newline at end of file +!!! error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'. + + function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { } + ~ +!!! error TS2322: Type '1' is not assignable to type 'boolean'. + ~ +!!! error TS2322: Type 'true' is not assignable to type 'string'. + ~~~~ +!!! error TS2566: A rest element cannot have a property name. \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.js b/tests/baselines/reference/restParameterWithBindingPattern3.js index da3531633b6..00342e7f741 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.js +++ b/tests/baselines/reference/restParameterWithBindingPattern3.js @@ -5,9 +5,20 @@ function b(...[...foo = []]: string[]) { } function c(...{0: a, length, 3: d}: [boolean, string, number]) { } -function d(...[a, , , d]: [boolean, string, number]) { } +function d(...[a, , , d]: [boolean, string, number]) { } + +function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { } //// [restParameterWithBindingPattern3.js] +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +}; function a() { var _a = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -36,3 +47,10 @@ function d() { } var a = _a[0], d = _a[3]; } +function e() { + var _a = []; + for (var _i = 0; _i < arguments.length; _i++) { + _a[_i] = arguments[_i]; + } + var _b = _a[0], a = _b === void 0 ? 1 : _b, _c = _a[1], b = _c === void 0 ? true : _c, rest = __rest(_a, [0, 1]); +} diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.symbols b/tests/baselines/reference/restParameterWithBindingPattern3.symbols index 2694c7327da..eecaba6d339 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.symbols +++ b/tests/baselines/reference/restParameterWithBindingPattern3.symbols @@ -19,3 +19,9 @@ function d(...[a, , , d]: [boolean, string, number]) { } >a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 6, 15)) >d : Symbol(d, Decl(restParameterWithBindingPattern3.ts, 6, 21)) +function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { } +>e : Symbol(e, Decl(restParameterWithBindingPattern3.ts, 6, 56)) +>a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 8, 15)) +>b : Symbol(b, Decl(restParameterWithBindingPattern3.ts, 8, 24)) +>rest : Symbol(rest, Decl(restParameterWithBindingPattern3.ts, 8, 37)) + diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.types b/tests/baselines/reference/restParameterWithBindingPattern3.types index 7ab8bdf621a..95a058dfe5c 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.types +++ b/tests/baselines/reference/restParameterWithBindingPattern3.types @@ -24,3 +24,12 @@ function d(...[a, , , d]: [boolean, string, number]) { } > : undefined >d : any +function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { } +>e : (__0_0: boolean, __0_1: string, __0_2: number) => void +>a : boolean +>1 : 1 +>b : string +>true : true +>rest : any +>rest : { [n: number]: string | number | boolean; 2: number; length: 3; toString(): string; toLocaleString(): string; pop(): string | number | boolean; push(...items: (string | number | boolean)[]): number; concat(...items: ConcatArray[]): (string | number | boolean)[]; concat(...items: (string | number | boolean | ConcatArray)[]): (string | number | boolean)[]; join(separator?: string): string; reverse(): (string | number | boolean)[]; shift(): string | number | boolean; slice(start?: number, end?: number): (string | number | boolean)[]; sort(compareFn?: (a: string | number | boolean, b: string | number | boolean) => number): [boolean, string, number]; splice(start: number, deleteCount?: number): (string | number | boolean)[]; splice(start: number, deleteCount: number, ...items: (string | number | boolean)[]): (string | number | boolean)[]; unshift(...items: (string | number | boolean)[]): number; indexOf(searchElement: string | number | boolean, fromIndex?: number): number; lastIndexOf(searchElement: string | number | boolean, fromIndex?: number): number; every(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => void, thisArg?: any): void; map(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => any, thisArg?: any): (string | number | boolean)[]; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; } + diff --git a/tests/cases/compiler/restParameterWithBindingPattern1.ts b/tests/cases/compiler/restParameterWithBindingPattern1.ts index 1004b047844..bd6a3b9bbda 100644 --- a/tests/cases/compiler/restParameterWithBindingPattern1.ts +++ b/tests/cases/compiler/restParameterWithBindingPattern1.ts @@ -1 +1,3 @@ +// @sourcemap: true + function a(...{a, b}) { } \ No newline at end of file diff --git a/tests/cases/compiler/restParameterWithBindingPattern3.ts b/tests/cases/compiler/restParameterWithBindingPattern3.ts index 93d0daae538..f0792354c40 100644 --- a/tests/cases/compiler/restParameterWithBindingPattern3.ts +++ b/tests/cases/compiler/restParameterWithBindingPattern3.ts @@ -4,4 +4,6 @@ function b(...[...foo = []]: string[]) { } function c(...{0: a, length, 3: d}: [boolean, string, number]) { } -function d(...[a, , , d]: [boolean, string, number]) { } \ No newline at end of file +function d(...[a, , , d]: [boolean, string, number]) { } + +function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { } \ No newline at end of file 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 006/113] 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 007/113] 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 008/113] 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 009/113] 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 010/113] 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 011/113] 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 012/113] 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 013/113] 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 014/113] #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 015/113] 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 016/113] 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 017/113] 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 018/113] 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 019/113] 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 020/113] 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 021/113] 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 022/113] 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 023/113] 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 024/113] --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 025/113] 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 026/113] 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 027/113] 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 028/113] 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 029/113] 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 030/113] 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 031/113] 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 032/113] 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 033/113] 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 034/113] 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 035/113] 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 036/113] 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 037/113] 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 e68f495b44e7306bd138679cbd7170ffe5def689 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Thu, 3 Jan 2019 17:51:13 +0100 Subject: [PATCH 038/113] update baselines --- .../reference/iterableArrayPattern28.errors.txt | 1 - .../restParameterWithBindingPattern3.errors.txt | 9 ++++++--- .../reference/restParameterWithBindingPattern3.types | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/baselines/reference/iterableArrayPattern28.errors.txt b/tests/baselines/reference/iterableArrayPattern28.errors.txt index 886dce4ca16..f90bba07c1a 100644 --- a/tests/baselines/reference/iterableArrayPattern28.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern28.errors.txt @@ -1,4 +1,3 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(1,33): error TS2501: A rest element cannot contain a binding pattern. tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,52): error TS2322: Type 'true' is not assignable to type 'number'. diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt b/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt index 2ad62269f50..96f066ca194 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt +++ b/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt @@ -1,13 +1,14 @@ tests/cases/compiler/restParameterWithBindingPattern3.ts(1,16): error TS2322: Type '1' is not assignable to type 'string'. tests/cases/compiler/restParameterWithBindingPattern3.ts(1,23): error TS2322: Type 'true' is not assignable to type 'string'. tests/cases/compiler/restParameterWithBindingPattern3.ts(3,23): error TS1186: A rest element cannot have an initializer. -tests/cases/compiler/restParameterWithBindingPattern3.ts(7,23): error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'. +tests/cases/compiler/restParameterWithBindingPattern3.ts(5,30): error TS2493: Tuple type '[boolean, string, number]' of length '3' has no element at index '3'. +tests/cases/compiler/restParameterWithBindingPattern3.ts(7,23): error TS2493: Tuple type '[boolean, string, number]' of length '3' has no element at index '3'. tests/cases/compiler/restParameterWithBindingPattern3.ts(9,19): error TS2322: Type '1' is not assignable to type 'boolean'. tests/cases/compiler/restParameterWithBindingPattern3.ts(9,29): error TS2322: Type 'true' is not assignable to type 'string'. tests/cases/compiler/restParameterWithBindingPattern3.ts(9,48): error TS2566: A rest element cannot have a property name. -==== tests/cases/compiler/restParameterWithBindingPattern3.ts (7 errors) ==== +==== tests/cases/compiler/restParameterWithBindingPattern3.ts (8 errors) ==== function a(...[a = 1, b = true]: string[]) { } ~ !!! error TS2322: Type '1' is not assignable to type 'string'. @@ -19,10 +20,12 @@ tests/cases/compiler/restParameterWithBindingPattern3.ts(9,48): error TS2566: A !!! error TS1186: A rest element cannot have an initializer. function c(...{0: a, length, 3: d}: [boolean, string, number]) { } + ~ +!!! error TS2493: Tuple type '[boolean, string, number]' of length '3' has no element at index '3'. function d(...[a, , , d]: [boolean, string, number]) { } ~ -!!! error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'. +!!! error TS2493: Tuple type '[boolean, string, number]' of length '3' has no element at index '3'. function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { } ~ diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.types b/tests/baselines/reference/restParameterWithBindingPattern3.types index 95a058dfe5c..1385bde0c3f 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.types +++ b/tests/baselines/reference/restParameterWithBindingPattern3.types @@ -15,14 +15,14 @@ function c(...{0: a, length, 3: d}: [boolean, string, number]) { } >c : (__0_0: boolean, __0_1: string, __0_2: number) => void >a : boolean >length : 3 ->d : string | number | boolean +>d : undefined function d(...[a, , , d]: [boolean, string, number]) { } >d : (__0_0: boolean, __0_1: string, __0_2: number) => void >a : boolean > : undefined > : undefined ->d : any +>d : undefined function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { } >e : (__0_0: boolean, __0_1: string, __0_2: number) => void @@ -31,5 +31,5 @@ function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) >b : string >true : true >rest : any ->rest : { [n: number]: string | number | boolean; 2: number; length: 3; toString(): string; toLocaleString(): string; pop(): string | number | boolean; push(...items: (string | number | boolean)[]): number; concat(...items: ConcatArray[]): (string | number | boolean)[]; concat(...items: (string | number | boolean | ConcatArray)[]): (string | number | boolean)[]; join(separator?: string): string; reverse(): (string | number | boolean)[]; shift(): string | number | boolean; slice(start?: number, end?: number): (string | number | boolean)[]; sort(compareFn?: (a: string | number | boolean, b: string | number | boolean) => number): [boolean, string, number]; splice(start: number, deleteCount?: number): (string | number | boolean)[]; splice(start: number, deleteCount: number, ...items: (string | number | boolean)[]): (string | number | boolean)[]; unshift(...items: (string | number | boolean)[]): number; indexOf(searchElement: string | number | boolean, fromIndex?: number): number; lastIndexOf(searchElement: string | number | boolean, fromIndex?: number): number; every(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => void, thisArg?: any): void; map(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => any, thisArg?: any): (string | number | boolean)[]; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; } +>rest : { [n: number]: string | number | boolean; 0: boolean; 1: string; 2: number; length: 3; toString(): string; toLocaleString(): string; pop(): string | number | boolean; push(...items: (string | number | boolean)[]): number; concat(...items: ConcatArray[]): (string | number | boolean)[]; concat(...items: (string | number | boolean | ConcatArray)[]): (string | number | boolean)[]; join(separator?: string): string; reverse(): (string | number | boolean)[]; shift(): string | number | boolean; slice(start?: number, end?: number): (string | number | boolean)[]; sort(compareFn?: (a: string | number | boolean, b: string | number | boolean) => number): [boolean, string, number]; splice(start: number, deleteCount?: number): (string | number | boolean)[]; splice(start: number, deleteCount: number, ...items: (string | number | boolean)[]): (string | number | boolean)[]; unshift(...items: (string | number | boolean)[]): number; indexOf(searchElement: string | number | boolean, fromIndex?: number): number; lastIndexOf(searchElement: string | number | boolean, fromIndex?: number): number; every(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => void, thisArg?: any): void; map(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => any, thisArg?: any): (string | number | boolean)[]; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; } From e16be71c08f13d61adf24bd55a15ebd51104b44c Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Wed, 9 Jan 2019 15:52:05 -0800 Subject: [PATCH 039/113] Add diagnostic message for JSDoc qualified param name without top level param --- src/compiler/diagnosticMessages.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 57f4c4c5611..58ec73c3cab 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4266,6 +4266,10 @@ "category": "Error", "code": 8031 }, + "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'.": { + "category": "Error", + "code": 8032 + }, "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause.": { "category": "Error", "code": 9002 From dd0a612cc9317034c87e2cf6ddec1370ef0e0ddb Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Wed, 9 Jan 2019 16:08:14 -0800 Subject: [PATCH 040/113] Use specific error message for qualified param name without leading top level param name --- src/compiler/checker.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index de44e8bb37c..68ad0afaf5f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -24757,9 +24757,17 @@ namespace ts { return; } if (!containsArgumentsReference(decl)) { - error(node.name, - Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, - idText(node.name.kind === SyntaxKind.QualifiedName ? node.name.right : node.name)); + if (isQualifiedName(node.name)) { + error(node.name, + Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, + entityNameToString(node.name), + entityNameToString(node.name.left)); + } + else { + error(node.name, + Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, + idText(node.name)); + } } else if (findLast(getJSDocTags(decl), isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && From e2524e375029d49de5de8c1393b8d362381aa6c4 Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Thu, 10 Jan 2019 09:55:06 -0800 Subject: [PATCH 041/113] Add test for qualified name param without top level object error --- .../paramTagNestedWithoutTopLevelObject.errors.txt | 12 ++++++++++++ .../paramTagNestedWithoutTopLevelObject.symbols | 11 +++++++++++ .../paramTagNestedWithoutTopLevelObject.types | 13 +++++++++++++ .../jsdoc/paramTagNestedWithoutTopLevelObject.ts | 11 +++++++++++ 4 files changed, 47 insertions(+) create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types create mode 100644 tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt new file mode 100644 index 00000000000..7cfe6e03670 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js(2,20): error TS8032: Qualified name 'xyz.p' is not allowed without a leading '@param {object} xyz'. + + +==== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js (1 errors) ==== + /** + * @param {number} xyz.p + ~~~~~ +!!! error TS8032: Qualified name 'xyz.p' is not allowed without a leading '@param {object} xyz'. + */ + function g(xyz) { + xyz.x; + } \ No newline at end of file diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols new file mode 100644 index 00000000000..63e7e4980b8 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js === +/** + * @param {number} xyz.p + */ +function g(xyz) { +>g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject.js, 0, 0)) +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject.js, 3, 11)) + + xyz.x; +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject.js, 3, 11)) +} diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types new file mode 100644 index 00000000000..d65efd8678a --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js === +/** + * @param {number} xyz.p + */ +function g(xyz) { +>g : (xyz: any) => void +>xyz : any + + xyz.x; +>xyz.x : any +>xyz : any +>x : any +} diff --git a/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts new file mode 100644 index 00000000000..2285ae623ff --- /dev/null +++ b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts @@ -0,0 +1,11 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: paramTagNestedWithoutTopLevelObject.js + +/** + * @param {number} xyz.p + */ +function g(xyz) { + xyz.x; +} \ No newline at end of file From ebe193c6d7757ecfe998634823beb2045f63aec1 Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Thu, 10 Jan 2019 14:05:10 -0800 Subject: [PATCH 042/113] Minor refactor in paramTagNestedWithoutTopLevelObject.ts --- .../paramTagNestedWithoutTopLevelObject.errors.txt | 2 +- .../reference/paramTagNestedWithoutTopLevelObject.symbols | 2 +- .../reference/paramTagNestedWithoutTopLevelObject.types | 8 ++++---- .../jsdoc/paramTagNestedWithoutTopLevelObject.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt index 7cfe6e03670..8ee7b3ba989 100644 --- a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt @@ -8,5 +8,5 @@ tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js(2,20): erro !!! error TS8032: Qualified name 'xyz.p' is not allowed without a leading '@param {object} xyz'. */ function g(xyz) { - xyz.x; + return xyz.p; } \ No newline at end of file diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols index 63e7e4980b8..d8a28a638ff 100644 --- a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols @@ -6,6 +6,6 @@ function g(xyz) { >g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject.js, 0, 0)) >xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject.js, 3, 11)) - xyz.x; + return xyz.p; >xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject.js, 3, 11)) } diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types index d65efd8678a..cc339b84b30 100644 --- a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types @@ -3,11 +3,11 @@ * @param {number} xyz.p */ function g(xyz) { ->g : (xyz: any) => void +>g : (xyz: any) => any >xyz : any - xyz.x; ->xyz.x : any + return xyz.p; +>xyz.p : any >xyz : any ->x : any +>p : any } diff --git a/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts index 2285ae623ff..03c79ce9e1c 100644 --- a/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts +++ b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts @@ -7,5 +7,5 @@ * @param {number} xyz.p */ function g(xyz) { - xyz.x; + return xyz.p; } \ No newline at end of file From 76f444e338218b9496d0c3ee5df7901dfe8dce6a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 10 Jan 2019 14:45:19 -0800 Subject: [PATCH 043/113] Allow nonnull assertions in references (#29351) --- src/compiler/binder.ts | 2 +- src/compiler/checker.ts | 11 + .../reference/nonNullReferenceMatching.js | 54 ++++ .../nonNullReferenceMatching.symbols | 193 +++++++++++++ .../reference/nonNullReferenceMatching.types | 262 ++++++++++++++++++ .../compiler/nonNullReferenceMatching.ts | 34 +++ 6 files changed, 555 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/nonNullReferenceMatching.js create mode 100644 tests/baselines/reference/nonNullReferenceMatching.symbols create mode 100644 tests/baselines/reference/nonNullReferenceMatching.types create mode 100644 tests/cases/compiler/nonNullReferenceMatching.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7216af4e817..f0e17261810 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -753,7 +753,7 @@ namespace ts { function isNarrowableReference(expr: Expression): boolean { return expr.kind === SyntaxKind.Identifier || expr.kind === SyntaxKind.ThisKeyword || expr.kind === SyntaxKind.SuperKeyword || - isPropertyAccessExpression(expr) && isNarrowableReference(expr.expression) || + (isPropertyAccessExpression(expr) || isNonNullExpression(expr) || isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || isElementAccessExpression(expr) && expr.argumentExpression && (isStringLiteral(expr.argumentExpression) || isNumericLiteral(expr.argumentExpression)) && isNarrowableReference(expr.expression); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 92e3b10842b..3bb26e83dd8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14773,6 +14773,9 @@ namespace ts { return symbol !== unknownSymbol ? (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; case SyntaxKind.ThisKeyword: return "0"; + case SyntaxKind.NonNullExpression: + case SyntaxKind.ParenthesizedExpression: + return getFlowCacheKey((node).expression); case SyntaxKind.PropertyAccessExpression: case SyntaxKind.ElementAccessExpression: const propName = getAccessedPropertyName(node); @@ -14785,6 +14788,11 @@ namespace ts { } function isMatchingReference(source: Node, target: Node): boolean { + switch (target.kind) { + case SyntaxKind.ParenthesizedExpression: + case SyntaxKind.NonNullExpression: + return isMatchingReference(source, (target as NonNullExpression | ParenthesizedExpression).expression); + } switch (source.kind) { case SyntaxKind.Identifier: return target.kind === SyntaxKind.Identifier && getResolvedSymbol(source) === getResolvedSymbol(target) || @@ -14794,6 +14802,9 @@ namespace ts { return target.kind === SyntaxKind.ThisKeyword; case SyntaxKind.SuperKeyword: return target.kind === SyntaxKind.SuperKeyword; + case SyntaxKind.NonNullExpression: + case SyntaxKind.ParenthesizedExpression: + return isMatchingReference((source as NonNullExpression | ParenthesizedExpression).expression, target); case SyntaxKind.PropertyAccessExpression: case SyntaxKind.ElementAccessExpression: return isAccessExpression(target) && diff --git a/tests/baselines/reference/nonNullReferenceMatching.js b/tests/baselines/reference/nonNullReferenceMatching.js new file mode 100644 index 00000000000..abb0d5a96db --- /dev/null +++ b/tests/baselines/reference/nonNullReferenceMatching.js @@ -0,0 +1,54 @@ +//// [nonNullReferenceMatching.ts] +type ElementRef = (element: HTMLElement | null) => void; + +type ThumbProps = { + elementRef?: ElementRef; +} + +type ComponentProps = { + thumbYProps?: ThumbProps; + thumbXProps: ThumbProps; +} + +class Component { + props!: ComponentProps; + public thumbYElementRef = (ref: HTMLElement | null) => { + typeof this.props.thumbYProps!.elementRef === 'function' && this.props.thumbYProps!.elementRef(ref); + + typeof (this.props.thumbYProps!.elementRef) === 'function' && this.props.thumbYProps!.elementRef(ref); + + typeof ((this.props).thumbYProps!.elementRef)! === 'function' && this.props.thumbYProps!.elementRef(ref); + + typeof this.props.thumbXProps.elementRef === 'function' && this.props.thumbXProps.elementRef(ref); + + typeof this.props.thumbXProps.elementRef === 'function' && (this.props).thumbXProps.elementRef(ref); + + typeof this.props.thumbXProps.elementRef === 'function' && (this.props.thumbXProps).elementRef(ref); + + typeof this.props.thumbXProps.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); + + typeof (this.props.thumbXProps).elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); + + typeof this.props!.thumbXProps!.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); + }; +} + +//// [nonNullReferenceMatching.js] +"use strict"; +var Component = /** @class */ (function () { + function Component() { + var _this = this; + this.thumbYElementRef = function (ref) { + typeof _this.props.thumbYProps.elementRef === 'function' && _this.props.thumbYProps.elementRef(ref); + typeof (_this.props.thumbYProps.elementRef) === 'function' && _this.props.thumbYProps.elementRef(ref); + typeof ((_this.props).thumbYProps.elementRef) === 'function' && _this.props.thumbYProps.elementRef(ref); + typeof _this.props.thumbXProps.elementRef === 'function' && _this.props.thumbXProps.elementRef(ref); + typeof _this.props.thumbXProps.elementRef === 'function' && (_this.props).thumbXProps.elementRef(ref); + typeof _this.props.thumbXProps.elementRef === 'function' && (_this.props.thumbXProps).elementRef(ref); + typeof _this.props.thumbXProps.elementRef === 'function' && ((_this.props).thumbXProps).elementRef(ref); + typeof (_this.props.thumbXProps).elementRef === 'function' && ((_this.props).thumbXProps).elementRef(ref); + typeof _this.props.thumbXProps.elementRef === 'function' && ((_this.props).thumbXProps).elementRef(ref); + }; + } + return Component; +}()); diff --git a/tests/baselines/reference/nonNullReferenceMatching.symbols b/tests/baselines/reference/nonNullReferenceMatching.symbols new file mode 100644 index 00000000000..ee9c608cea4 --- /dev/null +++ b/tests/baselines/reference/nonNullReferenceMatching.symbols @@ -0,0 +1,193 @@ +=== tests/cases/compiler/nonNullReferenceMatching.ts === +type ElementRef = (element: HTMLElement | null) => void; +>ElementRef : Symbol(ElementRef, Decl(nonNullReferenceMatching.ts, 0, 0)) +>element : Symbol(element, Decl(nonNullReferenceMatching.ts, 0, 19)) +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +type ThumbProps = { +>ThumbProps : Symbol(ThumbProps, Decl(nonNullReferenceMatching.ts, 0, 56)) + + elementRef?: ElementRef; +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>ElementRef : Symbol(ElementRef, Decl(nonNullReferenceMatching.ts, 0, 0)) +} + +type ComponentProps = { +>ComponentProps : Symbol(ComponentProps, Decl(nonNullReferenceMatching.ts, 4, 1)) + + thumbYProps?: ThumbProps; +>thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>ThumbProps : Symbol(ThumbProps, Decl(nonNullReferenceMatching.ts, 0, 56)) + + thumbXProps: ThumbProps; +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>ThumbProps : Symbol(ThumbProps, Decl(nonNullReferenceMatching.ts, 0, 56)) +} + +class Component { +>Component : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) + + props!: ComponentProps; +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>ComponentProps : Symbol(ComponentProps, Decl(nonNullReferenceMatching.ts, 4, 1)) + + public thumbYElementRef = (ref: HTMLElement | null) => { +>thumbYElementRef : Symbol(Component.thumbYElementRef, Decl(nonNullReferenceMatching.ts, 12, 27)) +>ref : Symbol(ref, Decl(nonNullReferenceMatching.ts, 13, 31)) +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + typeof this.props.thumbYProps!.elementRef === 'function' && this.props.thumbYProps!.elementRef(ref); +>this.props.thumbYProps!.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbYProps!.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>ref : Symbol(ref, Decl(nonNullReferenceMatching.ts, 13, 31)) + + typeof (this.props.thumbYProps!.elementRef) === 'function' && this.props.thumbYProps!.elementRef(ref); +>this.props.thumbYProps!.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbYProps!.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>ref : Symbol(ref, Decl(nonNullReferenceMatching.ts, 13, 31)) + + typeof ((this.props).thumbYProps!.elementRef)! === 'function' && this.props.thumbYProps!.elementRef(ref); +>(this.props).thumbYProps!.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>(this.props).thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbYProps!.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbYProps : Symbol(thumbYProps, Decl(nonNullReferenceMatching.ts, 6, 23)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>ref : Symbol(ref, Decl(nonNullReferenceMatching.ts, 13, 31)) + + typeof this.props.thumbXProps.elementRef === 'function' && this.props.thumbXProps.elementRef(ref); +>this.props.thumbXProps.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbXProps.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>ref : Symbol(ref, Decl(nonNullReferenceMatching.ts, 13, 31)) + + typeof this.props.thumbXProps.elementRef === 'function' && (this.props).thumbXProps.elementRef(ref); +>this.props.thumbXProps.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>(this.props).thumbXProps.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>(this.props).thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>ref : Symbol(ref, Decl(nonNullReferenceMatching.ts, 13, 31)) + + typeof this.props.thumbXProps.elementRef === 'function' && (this.props.thumbXProps).elementRef(ref); +>this.props.thumbXProps.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>(this.props.thumbXProps).elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>ref : Symbol(ref, Decl(nonNullReferenceMatching.ts, 13, 31)) + + typeof this.props.thumbXProps.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); +>this.props.thumbXProps.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>((this.props)!.thumbXProps)!.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>(this.props)!.thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>ref : Symbol(ref, Decl(nonNullReferenceMatching.ts, 13, 31)) + + typeof (this.props.thumbXProps).elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); +>(this.props.thumbXProps).elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props.thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>((this.props)!.thumbXProps)!.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>(this.props)!.thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>ref : Symbol(ref, Decl(nonNullReferenceMatching.ts, 13, 31)) + + typeof this.props!.thumbXProps!.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); +>this.props!.thumbXProps!.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>this.props!.thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>((this.props)!.thumbXProps)!.elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>(this.props)!.thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>this.props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>this : Symbol(Component, Decl(nonNullReferenceMatching.ts, 9, 1)) +>props : Symbol(Component.props, Decl(nonNullReferenceMatching.ts, 11, 17)) +>thumbXProps : Symbol(thumbXProps, Decl(nonNullReferenceMatching.ts, 7, 29)) +>elementRef : Symbol(elementRef, Decl(nonNullReferenceMatching.ts, 2, 19)) +>ref : Symbol(ref, Decl(nonNullReferenceMatching.ts, 13, 31)) + + }; +} diff --git a/tests/baselines/reference/nonNullReferenceMatching.types b/tests/baselines/reference/nonNullReferenceMatching.types new file mode 100644 index 00000000000..03ef70177c0 --- /dev/null +++ b/tests/baselines/reference/nonNullReferenceMatching.types @@ -0,0 +1,262 @@ +=== tests/cases/compiler/nonNullReferenceMatching.ts === +type ElementRef = (element: HTMLElement | null) => void; +>ElementRef : ElementRef +>element : HTMLElement | null +>null : null + +type ThumbProps = { +>ThumbProps : ThumbProps + + elementRef?: ElementRef; +>elementRef : ElementRef | undefined +} + +type ComponentProps = { +>ComponentProps : ComponentProps + + thumbYProps?: ThumbProps; +>thumbYProps : ThumbProps | undefined + + thumbXProps: ThumbProps; +>thumbXProps : ThumbProps +} + +class Component { +>Component : Component + + props!: ComponentProps; +>props : ComponentProps + + public thumbYElementRef = (ref: HTMLElement | null) => { +>thumbYElementRef : (ref: HTMLElement | null) => void +>(ref: HTMLElement | null) => { typeof this.props.thumbYProps!.elementRef === 'function' && this.props.thumbYProps!.elementRef(ref); typeof (this.props.thumbYProps!.elementRef) === 'function' && this.props.thumbYProps!.elementRef(ref); typeof ((this.props).thumbYProps!.elementRef)! === 'function' && this.props.thumbYProps!.elementRef(ref); typeof this.props.thumbXProps.elementRef === 'function' && this.props.thumbXProps.elementRef(ref); typeof this.props.thumbXProps.elementRef === 'function' && (this.props).thumbXProps.elementRef(ref); typeof this.props.thumbXProps.elementRef === 'function' && (this.props.thumbXProps).elementRef(ref); typeof this.props.thumbXProps.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); typeof (this.props.thumbXProps).elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); typeof this.props!.thumbXProps!.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); } : (ref: HTMLElement | null) => void +>ref : HTMLElement | null +>null : null + + typeof this.props.thumbYProps!.elementRef === 'function' && this.props.thumbYProps!.elementRef(ref); +>typeof this.props.thumbYProps!.elementRef === 'function' && this.props.thumbYProps!.elementRef(ref) : false | void +>typeof this.props.thumbYProps!.elementRef === 'function' : boolean +>typeof this.props.thumbYProps!.elementRef : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>this.props.thumbYProps!.elementRef : ElementRef | undefined +>this.props.thumbYProps! : ThumbProps +>this.props.thumbYProps : ThumbProps | undefined +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbYProps : ThumbProps | undefined +>elementRef : ElementRef | undefined +>'function' : "function" +>this.props.thumbYProps!.elementRef(ref) : void +>this.props.thumbYProps!.elementRef : ElementRef +>this.props.thumbYProps! : ThumbProps +>this.props.thumbYProps : ThumbProps | undefined +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbYProps : ThumbProps | undefined +>elementRef : ElementRef +>ref : HTMLElement | null + + typeof (this.props.thumbYProps!.elementRef) === 'function' && this.props.thumbYProps!.elementRef(ref); +>typeof (this.props.thumbYProps!.elementRef) === 'function' && this.props.thumbYProps!.elementRef(ref) : false | void +>typeof (this.props.thumbYProps!.elementRef) === 'function' : boolean +>typeof (this.props.thumbYProps!.elementRef) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>(this.props.thumbYProps!.elementRef) : ElementRef | undefined +>this.props.thumbYProps!.elementRef : ElementRef | undefined +>this.props.thumbYProps! : ThumbProps +>this.props.thumbYProps : ThumbProps | undefined +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbYProps : ThumbProps | undefined +>elementRef : ElementRef | undefined +>'function' : "function" +>this.props.thumbYProps!.elementRef(ref) : void +>this.props.thumbYProps!.elementRef : ElementRef +>this.props.thumbYProps! : ThumbProps +>this.props.thumbYProps : ThumbProps | undefined +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbYProps : ThumbProps | undefined +>elementRef : ElementRef +>ref : HTMLElement | null + + typeof ((this.props).thumbYProps!.elementRef)! === 'function' && this.props.thumbYProps!.elementRef(ref); +>typeof ((this.props).thumbYProps!.elementRef)! === 'function' && this.props.thumbYProps!.elementRef(ref) : false | void +>typeof ((this.props).thumbYProps!.elementRef)! === 'function' : boolean +>typeof ((this.props).thumbYProps!.elementRef)! : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>((this.props).thumbYProps!.elementRef)! : ElementRef +>((this.props).thumbYProps!.elementRef) : ElementRef | undefined +>(this.props).thumbYProps!.elementRef : ElementRef | undefined +>(this.props).thumbYProps! : ThumbProps +>(this.props).thumbYProps : ThumbProps | undefined +>(this.props) : ComponentProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbYProps : ThumbProps | undefined +>elementRef : ElementRef | undefined +>'function' : "function" +>this.props.thumbYProps!.elementRef(ref) : void +>this.props.thumbYProps!.elementRef : ElementRef +>this.props.thumbYProps! : ThumbProps +>this.props.thumbYProps : ThumbProps | undefined +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbYProps : ThumbProps | undefined +>elementRef : ElementRef +>ref : HTMLElement | null + + typeof this.props.thumbXProps.elementRef === 'function' && this.props.thumbXProps.elementRef(ref); +>typeof this.props.thumbXProps.elementRef === 'function' && this.props.thumbXProps.elementRef(ref) : false | void +>typeof this.props.thumbXProps.elementRef === 'function' : boolean +>typeof this.props.thumbXProps.elementRef : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>this.props.thumbXProps.elementRef : ElementRef | undefined +>this.props.thumbXProps : ThumbProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbXProps : ThumbProps +>elementRef : ElementRef | undefined +>'function' : "function" +>this.props.thumbXProps.elementRef(ref) : void +>this.props.thumbXProps.elementRef : ElementRef +>this.props.thumbXProps : ThumbProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbXProps : ThumbProps +>elementRef : ElementRef +>ref : HTMLElement | null + + typeof this.props.thumbXProps.elementRef === 'function' && (this.props).thumbXProps.elementRef(ref); +>typeof this.props.thumbXProps.elementRef === 'function' && (this.props).thumbXProps.elementRef(ref) : false | void +>typeof this.props.thumbXProps.elementRef === 'function' : boolean +>typeof this.props.thumbXProps.elementRef : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>this.props.thumbXProps.elementRef : ElementRef | undefined +>this.props.thumbXProps : ThumbProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbXProps : ThumbProps +>elementRef : ElementRef | undefined +>'function' : "function" +>(this.props).thumbXProps.elementRef(ref) : void +>(this.props).thumbXProps.elementRef : ElementRef +>(this.props).thumbXProps : ThumbProps +>(this.props) : ComponentProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbXProps : ThumbProps +>elementRef : ElementRef +>ref : HTMLElement | null + + typeof this.props.thumbXProps.elementRef === 'function' && (this.props.thumbXProps).elementRef(ref); +>typeof this.props.thumbXProps.elementRef === 'function' && (this.props.thumbXProps).elementRef(ref) : false | void +>typeof this.props.thumbXProps.elementRef === 'function' : boolean +>typeof this.props.thumbXProps.elementRef : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>this.props.thumbXProps.elementRef : ElementRef | undefined +>this.props.thumbXProps : ThumbProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbXProps : ThumbProps +>elementRef : ElementRef | undefined +>'function' : "function" +>(this.props.thumbXProps).elementRef(ref) : void +>(this.props.thumbXProps).elementRef : ElementRef +>(this.props.thumbXProps) : ThumbProps +>this.props.thumbXProps : ThumbProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbXProps : ThumbProps +>elementRef : ElementRef +>ref : HTMLElement | null + + typeof this.props.thumbXProps.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); +>typeof this.props.thumbXProps.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref) : false | void +>typeof this.props.thumbXProps.elementRef === 'function' : boolean +>typeof this.props.thumbXProps.elementRef : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>this.props.thumbXProps.elementRef : ElementRef | undefined +>this.props.thumbXProps : ThumbProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbXProps : ThumbProps +>elementRef : ElementRef | undefined +>'function' : "function" +>((this.props)!.thumbXProps)!.elementRef(ref) : void +>((this.props)!.thumbXProps)!.elementRef : ElementRef +>((this.props)!.thumbXProps)! : ThumbProps +>((this.props)!.thumbXProps) : ThumbProps +>(this.props)!.thumbXProps : ThumbProps +>(this.props)! : ComponentProps +>(this.props) : ComponentProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbXProps : ThumbProps +>elementRef : ElementRef +>ref : HTMLElement | null + + typeof (this.props.thumbXProps).elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); +>typeof (this.props.thumbXProps).elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref) : false | void +>typeof (this.props.thumbXProps).elementRef === 'function' : boolean +>typeof (this.props.thumbXProps).elementRef : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>(this.props.thumbXProps).elementRef : ElementRef | undefined +>(this.props.thumbXProps) : ThumbProps +>this.props.thumbXProps : ThumbProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbXProps : ThumbProps +>elementRef : ElementRef | undefined +>'function' : "function" +>((this.props)!.thumbXProps)!.elementRef(ref) : void +>((this.props)!.thumbXProps)!.elementRef : ElementRef +>((this.props)!.thumbXProps)! : ThumbProps +>((this.props)!.thumbXProps) : ThumbProps +>(this.props)!.thumbXProps : ThumbProps +>(this.props)! : ComponentProps +>(this.props) : ComponentProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbXProps : ThumbProps +>elementRef : ElementRef +>ref : HTMLElement | null + + typeof this.props!.thumbXProps!.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); +>typeof this.props!.thumbXProps!.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref) : false | void +>typeof this.props!.thumbXProps!.elementRef === 'function' : boolean +>typeof this.props!.thumbXProps!.elementRef : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>this.props!.thumbXProps!.elementRef : ElementRef | undefined +>this.props!.thumbXProps! : ThumbProps +>this.props!.thumbXProps : ThumbProps +>this.props! : ComponentProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbXProps : ThumbProps +>elementRef : ElementRef | undefined +>'function' : "function" +>((this.props)!.thumbXProps)!.elementRef(ref) : void +>((this.props)!.thumbXProps)!.elementRef : ElementRef +>((this.props)!.thumbXProps)! : ThumbProps +>((this.props)!.thumbXProps) : ThumbProps +>(this.props)!.thumbXProps : ThumbProps +>(this.props)! : ComponentProps +>(this.props) : ComponentProps +>this.props : ComponentProps +>this : this +>props : ComponentProps +>thumbXProps : ThumbProps +>elementRef : ElementRef +>ref : HTMLElement | null + + }; +} diff --git a/tests/cases/compiler/nonNullReferenceMatching.ts b/tests/cases/compiler/nonNullReferenceMatching.ts new file mode 100644 index 00000000000..1295c3ce9a7 --- /dev/null +++ b/tests/cases/compiler/nonNullReferenceMatching.ts @@ -0,0 +1,34 @@ +// @strict: true +type ElementRef = (element: HTMLElement | null) => void; + +type ThumbProps = { + elementRef?: ElementRef; +} + +type ComponentProps = { + thumbYProps?: ThumbProps; + thumbXProps: ThumbProps; +} + +class Component { + props!: ComponentProps; + public thumbYElementRef = (ref: HTMLElement | null) => { + typeof this.props.thumbYProps!.elementRef === 'function' && this.props.thumbYProps!.elementRef(ref); + + typeof (this.props.thumbYProps!.elementRef) === 'function' && this.props.thumbYProps!.elementRef(ref); + + typeof ((this.props).thumbYProps!.elementRef)! === 'function' && this.props.thumbYProps!.elementRef(ref); + + typeof this.props.thumbXProps.elementRef === 'function' && this.props.thumbXProps.elementRef(ref); + + typeof this.props.thumbXProps.elementRef === 'function' && (this.props).thumbXProps.elementRef(ref); + + typeof this.props.thumbXProps.elementRef === 'function' && (this.props.thumbXProps).elementRef(ref); + + typeof this.props.thumbXProps.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); + + typeof (this.props.thumbXProps).elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); + + typeof this.props!.thumbXProps!.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref); + }; +} \ No newline at end of file From aba0b700b638498a7774003b053074193c890103 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 10 Jan 2019 14:48:15 -0800 Subject: [PATCH 044/113] Allow circular umd-merged-with-augmentation refs to resolve to the module as intended (#29335) --- src/compiler/checker.ts | 8 ++++ ...rgedWithGlobalAugmentationIsNotCircular.js | 31 +++++++++++++ ...ithGlobalAugmentationIsNotCircular.symbols | 42 ++++++++++++++++++ ...dWithGlobalAugmentationIsNotCircular.types | 44 +++++++++++++++++++ ...rgedWithGlobalAugmentationIsNotCircular.ts | 26 +++++++++++ 5 files changed, 151 insertions(+) create mode 100644 tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.js create mode 100644 tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.symbols create mode 100644 tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.types create mode 100644 tests/cases/compiler/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3bb26e83dd8..b1f73584c49 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5431,6 +5431,10 @@ namespace ts { // Handle variable, parameter or property if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { + // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` + if (symbol.flags & SymbolFlags.ValueModule) { + return getTypeOfFuncClassEnumModule(symbol); + } return errorType; } let type: Type | undefined; @@ -5486,6 +5490,10 @@ namespace ts { } if (!popTypeResolution()) { + // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` + if (symbol.flags & SymbolFlags.ValueModule) { + return getTypeOfFuncClassEnumModule(symbol); + } type = reportCircularityError(symbol); } return type; diff --git a/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.js b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.js new file mode 100644 index 00000000000..377082fa5d5 --- /dev/null +++ b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.ts] //// + +//// [global.d.ts] +declare global { + const React: typeof import("./module"); +} + +export { }; + +//// [module.d.ts] +export = React; +export as namespace React; + +declare namespace React { + function createRef(): any; +} + +//// [some_module.ts] +export { }; +React.createRef; + +//// [emits.ts] +console.log("hello"); +React.createRef; + +//// [some_module.js] +React.createRef; +//// [emits.js] +"use strict"; +console.log("hello"); +React.createRef; diff --git a/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.symbols b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.symbols new file mode 100644 index 00000000000..24a9885b294 --- /dev/null +++ b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/global.d.ts === +declare global { +>global : Symbol(global, Decl(global.d.ts, 0, 0)) + + const React: typeof import("./module"); +>React : Symbol(React, Decl(module.d.ts, 1, 26), Decl(global.d.ts, 1, 9)) +} + +export { }; + +=== tests/cases/compiler/module.d.ts === +export = React; +>React : Symbol(React, Decl(module.d.ts, 1, 26)) + +export as namespace React; +>React : Symbol(React, Decl(module.d.ts, 0, 15)) + +declare namespace React { +>React : Symbol(React, Decl(module.d.ts, 1, 26), Decl(global.d.ts, 1, 9)) + + function createRef(): any; +>createRef : Symbol(createRef, Decl(module.d.ts, 3, 25)) +} + +=== tests/cases/compiler/some_module.ts === +export { }; +React.createRef; +>React.createRef : Symbol(React.createRef, Decl(module.d.ts, 3, 25)) +>React : Symbol(React, Decl(module.d.ts, 1, 26), Decl(global.d.ts, 1, 9)) +>createRef : Symbol(React.createRef, Decl(module.d.ts, 3, 25)) + +=== tests/cases/compiler/emits.ts === +console.log("hello"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + +React.createRef; +>React.createRef : Symbol(React.createRef, Decl(module.d.ts, 3, 25)) +>React : Symbol(React, Decl(module.d.ts, 1, 26), Decl(global.d.ts, 1, 9)) +>createRef : Symbol(React.createRef, Decl(module.d.ts, 3, 25)) + diff --git a/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.types b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.types new file mode 100644 index 00000000000..2c0ce91aec8 --- /dev/null +++ b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/global.d.ts === +declare global { +>global : typeof global + + const React: typeof import("./module"); +>React : typeof React +} + +export { }; + +=== tests/cases/compiler/module.d.ts === +export = React; +>React : typeof React + +export as namespace React; +>React : typeof React + +declare namespace React { +>React : typeof React + + function createRef(): any; +>createRef : () => any +} + +=== tests/cases/compiler/some_module.ts === +export { }; +React.createRef; +>React.createRef : () => any +>React : typeof React +>createRef : () => any + +=== tests/cases/compiler/emits.ts === +console.log("hello"); +>console.log("hello") : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>"hello" : "hello" + +React.createRef; +>React.createRef : () => any +>React : typeof React +>createRef : () => any + diff --git a/tests/cases/compiler/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.ts b/tests/cases/compiler/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.ts new file mode 100644 index 00000000000..81346aca1b4 --- /dev/null +++ b/tests/cases/compiler/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.ts @@ -0,0 +1,26 @@ +// @strict: true +// @module: esnext +// @moduleResolution: node +// @target: es2018 +// @filename: global.d.ts +declare global { + const React: typeof import("./module"); +} + +export { }; + +// @filename: module.d.ts +export = React; +export as namespace React; + +declare namespace React { + function createRef(): any; +} + +// @filename: some_module.ts +export { }; +React.createRef; + +// @filename: emits.ts +console.log("hello"); +React.createRef; \ No newline at end of file From b3633fab5275f2a3b2c29e2b9f4ba5106e002dfa Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Thu, 10 Jan 2019 15:04:16 -0800 Subject: [PATCH 045/113] Add more tests for qualified name param without top level object error --- ...aramTagNestedWithoutTopLevelObject4.errors.txt | 12 ++++++++++++ .../paramTagNestedWithoutTopLevelObject4.symbols | 11 +++++++++++ .../paramTagNestedWithoutTopLevelObject4.types | 15 +++++++++++++++ .../jsdoc/paramTagNestedWithoutTopLevelObject2.ts | 12 ++++++++++++ .../jsdoc/paramTagNestedWithoutTopLevelObject3.ts | 12 ++++++++++++ .../jsdoc/paramTagNestedWithoutTopLevelObject4.ts | 11 +++++++++++ 6 files changed, 73 insertions(+) create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.errors.txt create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.symbols create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.types create mode 100644 tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.ts create mode 100644 tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.ts create mode 100644 tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.ts diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.errors.txt b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.errors.txt new file mode 100644 index 00000000000..74ca02ef006 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.js(2,20): error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. + + +==== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.js (1 errors) ==== + /** + * @param {number} xyz.bar.p + ~~~~~~~~~ +!!! error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. + */ + function g(xyz) { + return xyz.bar.p; + } \ No newline at end of file diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.symbols b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.symbols new file mode 100644 index 00000000000..6f8e1ffa643 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.js === +/** + * @param {number} xyz.bar.p + */ +function g(xyz) { +>g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject4.js, 0, 0)) +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject4.js, 3, 11)) + + return xyz.bar.p; +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject4.js, 3, 11)) +} diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.types b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.types new file mode 100644 index 00000000000..8b9843bdbee --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.js === +/** + * @param {number} xyz.bar.p + */ +function g(xyz) { +>g : (xyz: any) => any +>xyz : any + + return xyz.bar.p; +>xyz.bar.p : any +>xyz.bar : any +>xyz : any +>bar : any +>p : any +} diff --git a/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.ts b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.ts new file mode 100644 index 00000000000..a6a68aa0861 --- /dev/null +++ b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.ts @@ -0,0 +1,12 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: paramTagNestedWithoutTopLevelObject2.js + +/** + * @param {object} xyz.bar + * @param {number} xyz.bar.p + */ +function g(xyz) { + return xyz.bar.p; +} \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.ts b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.ts new file mode 100644 index 00000000000..8307688a0cd --- /dev/null +++ b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.ts @@ -0,0 +1,12 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: paramTagNestedWithoutTopLevelObject3.js + +/** + * @param {object} xyz + * @param {number} xyz.bar.p + */ +function g(xyz) { + return xyz.bar.p; +} \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.ts b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.ts new file mode 100644 index 00000000000..5840308fa0d --- /dev/null +++ b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.ts @@ -0,0 +1,11 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: paramTagNestedWithoutTopLevelObject4.js + +/** + * @param {number} xyz.bar.p + */ +function g(xyz) { + return xyz.bar.p; +} \ No newline at end of file From abc861862ab7c08b07216ba2c4ede7ccefc1cc60 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 10 Jan 2019 15:18:02 -0800 Subject: [PATCH 046/113] 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 ed5775865a971b74bbbd0f430214e5fb96beed5b Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Thu, 10 Jan 2019 15:45:00 -0800 Subject: [PATCH 047/113] Add missing baseline references --- ...ramTagNestedWithoutTopLevelObject2.errors.txt | 13 +++++++++++++ .../paramTagNestedWithoutTopLevelObject2.symbols | 12 ++++++++++++ .../paramTagNestedWithoutTopLevelObject2.types | 16 ++++++++++++++++ ...ramTagNestedWithoutTopLevelObject3.errors.txt | 13 +++++++++++++ .../paramTagNestedWithoutTopLevelObject3.symbols | 12 ++++++++++++ .../paramTagNestedWithoutTopLevelObject3.types | 16 ++++++++++++++++ 6 files changed, 82 insertions(+) create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.errors.txt create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.symbols create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.types create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.errors.txt create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.symbols create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.types diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.errors.txt b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.errors.txt new file mode 100644 index 00000000000..d3e94e1cff4 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.js(2,20): error TS8032: Qualified name 'xyz.bar' is not allowed without a leading '@param {object} xyz'. + + +==== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.js (1 errors) ==== + /** + * @param {object} xyz.bar + ~~~~~~~ +!!! error TS8032: Qualified name 'xyz.bar' is not allowed without a leading '@param {object} xyz'. + * @param {number} xyz.bar.p + */ + function g(xyz) { + return xyz.bar.p; + } \ No newline at end of file diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.symbols b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.symbols new file mode 100644 index 00000000000..e6acfb7cbc4 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.js === +/** + * @param {object} xyz.bar + * @param {number} xyz.bar.p + */ +function g(xyz) { +>g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject2.js, 0, 0)) +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject2.js, 4, 11)) + + return xyz.bar.p; +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject2.js, 4, 11)) +} diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.types b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.types new file mode 100644 index 00000000000..2f6598ffa2d --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.js === +/** + * @param {object} xyz.bar + * @param {number} xyz.bar.p + */ +function g(xyz) { +>g : (xyz: any) => any +>xyz : any + + return xyz.bar.p; +>xyz.bar.p : any +>xyz.bar : any +>xyz : any +>bar : any +>p : any +} diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.errors.txt b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.errors.txt new file mode 100644 index 00000000000..d73f35cfcb2 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.js(3,20): error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. + + +==== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.js (1 errors) ==== + /** + * @param {object} xyz + * @param {number} xyz.bar.p + ~~~~~~~~~ +!!! error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. + */ + function g(xyz) { + return xyz.bar.p; + } \ No newline at end of file diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.symbols b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.symbols new file mode 100644 index 00000000000..a350edded90 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.js === +/** + * @param {object} xyz + * @param {number} xyz.bar.p + */ +function g(xyz) { +>g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject3.js, 0, 0)) +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject3.js, 4, 11)) + + return xyz.bar.p; +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject3.js, 4, 11)) +} diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.types b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.types new file mode 100644 index 00000000000..a2bb9ddf329 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.js === +/** + * @param {object} xyz + * @param {number} xyz.bar.p + */ +function g(xyz) { +>g : (xyz: any) => any +>xyz : any + + return xyz.bar.p; +>xyz.bar.p : any +>xyz.bar : any +>xyz : any +>bar : any +>p : any +} From 9d16225bc2c96a06589f8e9b5f8a60d79a82d31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Fri, 11 Jan 2019 13:34:18 +0800 Subject: [PATCH 048/113] emit jsx type arguments --- src/compiler/emitter.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 9c09ed79a77..62aba51afec 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2561,6 +2561,7 @@ namespace ts { function emitJsxSelfClosingElement(node: JsxSelfClosingElement) { writePunctuation("<"); emitJsxTagName(node.tagName); + emitTypeArguments(node, node.typeArguments); writeSpace(); emit(node.attributes); writePunctuation("/>"); @@ -2577,6 +2578,7 @@ namespace ts { if (isJsxOpeningElement(node)) { emitJsxTagName(node.tagName); + emitTypeArguments(node, node.typeArguments); if (node.attributes.properties && node.attributes.properties.length > 0) { writeSpace(); } From 11b150129a988fe43bd74f6d349f19edb799f19b Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Fri, 14 Dec 2018 14:26:32 +0100 Subject: [PATCH 049/113] Do not process library reference directives with noLib set. When a user sets `noLib`, this indicates that they will supply their own list of `lib*.d.ts` files as part of input sources. In this situation, TypeScript should not try to resolve library reference directives. This avoids a problem where TypeScript loads a file that e.g. contains `/// `. Previously, TypeScript would use its builtin ts.libMap and attempt to load builtin libraries from the TypeScript installation, instead of respecting the user-supplied set of libraries. --- src/compiler/program.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 080b17b8cbe..271bdab976e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2227,8 +2227,9 @@ namespace ts { processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } - - processLibReferenceDirectives(file); + if (!options.noLib) { + processLibReferenceDirectives(file); + } modulesWithElidedImports.set(file.path, false); processImportedModules(file); @@ -2315,8 +2316,10 @@ namespace ts { processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } + if (!options.noLib) { + processLibReferenceDirectives(file); + } - processLibReferenceDirectives(file); // always process imported modules to record module name resolutions processImportedModules(file); From cc7ddaed281f9ab72586fd4028d6f11f3459fd5f Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Sat, 15 Dec 2018 16:43:37 +0100 Subject: [PATCH 050/113] Add tests for noLib with . --- .../baselines/reference/libReferenceNoLib.js | 51 +++++++++++++++++++ .../reference/libReferenceNoLib.symbols | 40 +++++++++++++++ .../reference/libReferenceNoLib.types | 24 +++++++++ .../declarationEmit/libReferenceNoLib.ts | 21 ++++++++ 4 files changed, 136 insertions(+) create mode 100644 tests/baselines/reference/libReferenceNoLib.js create mode 100644 tests/baselines/reference/libReferenceNoLib.symbols create mode 100644 tests/baselines/reference/libReferenceNoLib.types create mode 100644 tests/cases/conformance/declarationEmit/libReferenceNoLib.ts diff --git a/tests/baselines/reference/libReferenceNoLib.js b/tests/baselines/reference/libReferenceNoLib.js new file mode 100644 index 00000000000..21d1cbbe177 --- /dev/null +++ b/tests/baselines/reference/libReferenceNoLib.js @@ -0,0 +1,51 @@ +//// [tests/cases/conformance/declarationEmit/libReferenceNoLib.ts] //// + +//// [fakelib.ts] +// Test that passing noLib disables resolution. + +interface Object { } +interface Array { } +interface String { } +interface Boolean { } +interface Number { } +interface Function { } +interface RegExp { } +interface IArguments { } + + +//// [file1.ts] +/// +export declare interface HTMLElement { field: string; } +export const elem: HTMLElement = { field: 'a' }; + + +//// [fakelib.js] +// Test that passing noLib disables resolution. +//// [file1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.elem = { field: 'a' }; + + +//// [fakelib.d.ts] +interface Object { +} +interface Array { +} +interface String { +} +interface Boolean { +} +interface Number { +} +interface Function { +} +interface RegExp { +} +interface IArguments { +} +//// [file1.d.ts] +export declare interface HTMLElement { + field: string; +} +export declare const elem: HTMLElement; diff --git a/tests/baselines/reference/libReferenceNoLib.symbols b/tests/baselines/reference/libReferenceNoLib.symbols new file mode 100644 index 00000000000..5f180fd1eed --- /dev/null +++ b/tests/baselines/reference/libReferenceNoLib.symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/declarationEmit/fakelib.ts === +// Test that passing noLib disables resolution. + +interface Object { } +>Object : Symbol(Object, Decl(fakelib.ts, 0, 0)) + +interface Array { } +>Array : Symbol(Array, Decl(fakelib.ts, 2, 20)) +>T : Symbol(T, Decl(fakelib.ts, 3, 16)) + +interface String { } +>String : Symbol(String, Decl(fakelib.ts, 3, 22)) + +interface Boolean { } +>Boolean : Symbol(Boolean, Decl(fakelib.ts, 4, 20)) + +interface Number { } +>Number : Symbol(Number, Decl(fakelib.ts, 5, 21)) + +interface Function { } +>Function : Symbol(Function, Decl(fakelib.ts, 6, 20)) + +interface RegExp { } +>RegExp : Symbol(RegExp, Decl(fakelib.ts, 7, 22)) + +interface IArguments { } +>IArguments : Symbol(IArguments, Decl(fakelib.ts, 8, 20)) + + +=== tests/cases/conformance/declarationEmit/file1.ts === +/// +export declare interface HTMLElement { field: string; } +>HTMLElement : Symbol(HTMLElement, Decl(file1.ts, 0, 0)) +>field : Symbol(HTMLElement.field, Decl(file1.ts, 1, 38)) + +export const elem: HTMLElement = { field: 'a' }; +>elem : Symbol(elem, Decl(file1.ts, 2, 12)) +>HTMLElement : Symbol(HTMLElement, Decl(file1.ts, 0, 0)) +>field : Symbol(field, Decl(file1.ts, 2, 34)) + diff --git a/tests/baselines/reference/libReferenceNoLib.types b/tests/baselines/reference/libReferenceNoLib.types new file mode 100644 index 00000000000..0b2733c2265 --- /dev/null +++ b/tests/baselines/reference/libReferenceNoLib.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/declarationEmit/fakelib.ts === +// Test that passing noLib disables resolution. +No type information for this code. +No type information for this code.interface Object { } +No type information for this code.interface Array { } +No type information for this code.interface String { } +No type information for this code.interface Boolean { } +No type information for this code.interface Number { } +No type information for this code.interface Function { } +No type information for this code.interface RegExp { } +No type information for this code.interface IArguments { } +No type information for this code. +No type information for this code. +No type information for this code.=== tests/cases/conformance/declarationEmit/file1.ts === +/// +export declare interface HTMLElement { field: string; } +>field : string + +export const elem: HTMLElement = { field: 'a' }; +>elem : HTMLElement +>{ field: 'a' } : { field: string; } +>field : string +>'a' : "a" + diff --git a/tests/cases/conformance/declarationEmit/libReferenceNoLib.ts b/tests/cases/conformance/declarationEmit/libReferenceNoLib.ts new file mode 100644 index 00000000000..d29da9a5bc5 --- /dev/null +++ b/tests/cases/conformance/declarationEmit/libReferenceNoLib.ts @@ -0,0 +1,21 @@ +// @target: esnext +// @module: commonjs +// @noLib: true +// @declaration: true +// Test that passing noLib disables resolution. + +// @filename: fakelib.ts +interface Object { } +interface Array { } +interface String { } +interface Boolean { } +interface Number { } +interface Function { } +interface RegExp { } +interface IArguments { } + + +// @filename: file1.ts +/// +export declare interface HTMLElement { field: string; } +export const elem: HTMLElement = { field: 'a' }; From f3f5877c5f7659851fc7494b6c15bc5cb12834af Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Fri, 11 Jan 2019 08:36:16 +0100 Subject: [PATCH 051/113] Add tests for noLib with and bundling. --- .../reference/libReferenceNoLibBundle.js | 53 +++++++++++++++++++ .../reference/libReferenceNoLibBundle.symbols | 40 ++++++++++++++ .../reference/libReferenceNoLibBundle.types | 24 +++++++++ .../libReferenceNoLibBundle.ts | 23 ++++++++ 4 files changed, 140 insertions(+) create mode 100644 tests/baselines/reference/libReferenceNoLibBundle.js create mode 100644 tests/baselines/reference/libReferenceNoLibBundle.symbols create mode 100644 tests/baselines/reference/libReferenceNoLibBundle.types create mode 100644 tests/cases/conformance/declarationEmit/libReferenceNoLibBundle.ts diff --git a/tests/baselines/reference/libReferenceNoLibBundle.js b/tests/baselines/reference/libReferenceNoLibBundle.js new file mode 100644 index 00000000000..a881f11a8a1 --- /dev/null +++ b/tests/baselines/reference/libReferenceNoLibBundle.js @@ -0,0 +1,53 @@ +//// [tests/cases/conformance/declarationEmit/libReferenceNoLibBundle.ts] //// + +//// [fakelib.ts] +// Test that passing noLib disables resolution. + +interface Object { } +interface Array { } +interface String { } +interface Boolean { } +interface Number { } +interface Function { } +interface RegExp { } +interface IArguments { } + + +//// [file1.ts] +/// +export declare interface HTMLElement { field: string; } +export const elem: HTMLElement = { field: 'a' }; + + +//// [bundle.js] +// Test that passing noLib disables resolution. +define("file1", ["require", "exports"], function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.elem = { field: 'a' }; +}); + + +//// [bundle.d.ts] +interface Object { +} +interface Array { +} +interface String { +} +interface Boolean { +} +interface Number { +} +interface Function { +} +interface RegExp { +} +interface IArguments { +} +declare module "file1" { + export interface HTMLElement { + field: string; + } + export const elem: HTMLElement; +} diff --git a/tests/baselines/reference/libReferenceNoLibBundle.symbols b/tests/baselines/reference/libReferenceNoLibBundle.symbols new file mode 100644 index 00000000000..5f180fd1eed --- /dev/null +++ b/tests/baselines/reference/libReferenceNoLibBundle.symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/declarationEmit/fakelib.ts === +// Test that passing noLib disables resolution. + +interface Object { } +>Object : Symbol(Object, Decl(fakelib.ts, 0, 0)) + +interface Array { } +>Array : Symbol(Array, Decl(fakelib.ts, 2, 20)) +>T : Symbol(T, Decl(fakelib.ts, 3, 16)) + +interface String { } +>String : Symbol(String, Decl(fakelib.ts, 3, 22)) + +interface Boolean { } +>Boolean : Symbol(Boolean, Decl(fakelib.ts, 4, 20)) + +interface Number { } +>Number : Symbol(Number, Decl(fakelib.ts, 5, 21)) + +interface Function { } +>Function : Symbol(Function, Decl(fakelib.ts, 6, 20)) + +interface RegExp { } +>RegExp : Symbol(RegExp, Decl(fakelib.ts, 7, 22)) + +interface IArguments { } +>IArguments : Symbol(IArguments, Decl(fakelib.ts, 8, 20)) + + +=== tests/cases/conformance/declarationEmit/file1.ts === +/// +export declare interface HTMLElement { field: string; } +>HTMLElement : Symbol(HTMLElement, Decl(file1.ts, 0, 0)) +>field : Symbol(HTMLElement.field, Decl(file1.ts, 1, 38)) + +export const elem: HTMLElement = { field: 'a' }; +>elem : Symbol(elem, Decl(file1.ts, 2, 12)) +>HTMLElement : Symbol(HTMLElement, Decl(file1.ts, 0, 0)) +>field : Symbol(field, Decl(file1.ts, 2, 34)) + diff --git a/tests/baselines/reference/libReferenceNoLibBundle.types b/tests/baselines/reference/libReferenceNoLibBundle.types new file mode 100644 index 00000000000..0b2733c2265 --- /dev/null +++ b/tests/baselines/reference/libReferenceNoLibBundle.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/declarationEmit/fakelib.ts === +// Test that passing noLib disables resolution. +No type information for this code. +No type information for this code.interface Object { } +No type information for this code.interface Array { } +No type information for this code.interface String { } +No type information for this code.interface Boolean { } +No type information for this code.interface Number { } +No type information for this code.interface Function { } +No type information for this code.interface RegExp { } +No type information for this code.interface IArguments { } +No type information for this code. +No type information for this code. +No type information for this code.=== tests/cases/conformance/declarationEmit/file1.ts === +/// +export declare interface HTMLElement { field: string; } +>field : string + +export const elem: HTMLElement = { field: 'a' }; +>elem : HTMLElement +>{ field: 'a' } : { field: string; } +>field : string +>'a' : "a" + diff --git a/tests/cases/conformance/declarationEmit/libReferenceNoLibBundle.ts b/tests/cases/conformance/declarationEmit/libReferenceNoLibBundle.ts new file mode 100644 index 00000000000..18f0b5387c5 --- /dev/null +++ b/tests/cases/conformance/declarationEmit/libReferenceNoLibBundle.ts @@ -0,0 +1,23 @@ +// @target: esnext +// @module: amd +// @noLib: true +// @declaration: true +// @outFile: bundle.js + +// Test that passing noLib disables resolution. + +// @filename: fakelib.ts +interface Object { } +interface Array { } +interface String { } +interface Boolean { } +interface Number { } +interface Function { } +interface RegExp { } +interface IArguments { } + + +// @filename: file1.ts +/// +export declare interface HTMLElement { field: string; } +export const elem: HTMLElement = { field: 'a' }; From 8d28f9230cb3b4e032218b8019da22e61dd9abdd Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 11 Jan 2019 09:20:12 -0500 Subject: [PATCH 052/113] Added codefix to enable experimentalDecorators in the user's config file Starts on #29035 by creating a codefix to enable the `experimentalDecorators` setting in a user's config file, if one exists. The issue's discussion also mentions giving a more precise error message if the user has a jsconfig or tsconfig or creating one if not; I'd rather tackle those in separate PRs to keep this one small. Doesn't create the code action if no config file is present. Otherwise keeps to the precedent of returning without action when the config file contents aren't the expected JSON structure (looking at `fixCannotFindModule.ts`). Moves a couple JSON helpers from that file into the sibling `helpers.ts` so both codefixes can use them. --- src/compiler/diagnosticMessages.json | 4 ++ src/services/codefixes/fixCannotFindModule.ts | 14 +---- .../fixEnableExperimentalDecorators.ts | 60 +++++++++++++++++++ src/services/codefixes/helpers.ts | 8 +++ src/services/tsconfig.json | 1 + ...rimentalDecorators_blankCompilerOptions.ts | 26 ++++++++ ...talDecorators_disabledInCompilerOptions.ts | 27 +++++++++ ...mentalDecorators_missingCompilerOptions.ts | 22 +++++++ ...EnableExperimentalDecorators_noTsconfig.ts | 10 ++++ 9 files changed, 161 insertions(+), 11 deletions(-) create mode 100644 src/services/codefixes/fixEnableExperimentalDecorators.ts create mode 100644 tests/cases/fourslash/codefixEnableExperimentalDecorators_blankCompilerOptions.ts create mode 100644 tests/cases/fourslash/codefixEnableExperimentalDecorators_disabledInCompilerOptions.ts create mode 100644 tests/cases/fourslash/codefixEnableExperimentalDecorators_missingCompilerOptions.ts create mode 100644 tests/cases/fourslash/codefixEnableExperimentalDecorators_noTsconfig.ts diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9a918507dc4..5bcaf448599 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4811,5 +4811,9 @@ "Add names to all parameters without names": { "category": "Message", "code": 95073 + }, + "Enable the 'experimentalDecorators' option in your configuration file": { + "category": "Message", + "code": 95074 } } diff --git a/src/services/codefixes/fixCannotFindModule.ts b/src/services/codefixes/fixCannotFindModule.ts index 1c7070c74bf..1baaa9714f2 100644 --- a/src/services/codefixes/fixCannotFindModule.ts +++ b/src/services/codefixes/fixCannotFindModule.ts @@ -74,7 +74,7 @@ namespace ts.codefix { const tsconfigObjectLiteral = getTsConfigObjectLiteralExpression(configFile); if (!tsconfigObjectLiteral) return undefined; - const compilerOptionsProperty = findProperty(tsconfigObjectLiteral, "compilerOptions"); + const compilerOptionsProperty = findJsonProperty(tsconfigObjectLiteral, "compilerOptions"); if (!compilerOptionsProperty) { const newCompilerOptions = createObjectLiteral([makeDefaultBaseUrl(), makeDefaultPaths()]); changes.insertNodeAtObjectStart(configFile, tsconfigObjectLiteral, createJsonPropertyAssignment("compilerOptions", newCompilerOptions)); @@ -94,7 +94,7 @@ namespace ts.codefix { return createJsonPropertyAssignment("baseUrl", createStringLiteral(defaultBaseUrl)); } function getOrAddBaseUrl(changes: textChanges.ChangeTracker, tsconfig: TsConfigSourceFile, compilerOptions: ObjectLiteralExpression): string { - const baseUrlProp = findProperty(compilerOptions, "baseUrl"); + const baseUrlProp = findJsonProperty(compilerOptions, "baseUrl"); if (baseUrlProp) { return isStringLiteral(baseUrlProp.initializer) ? baseUrlProp.initializer.text : defaultBaseUrl; } @@ -112,7 +112,7 @@ namespace ts.codefix { return createJsonPropertyAssignment("paths", createObjectLiteral([makeDefaultPathMapping()])); } function getOrAddPathMapping(changes: textChanges.ChangeTracker, tsconfig: TsConfigSourceFile, compilerOptions: ObjectLiteralExpression) { - const paths = findProperty(compilerOptions, "paths"); + const paths = findJsonProperty(compilerOptions, "paths"); if (!paths || !isObjectLiteralExpression(paths.initializer)) { changes.insertNodeAtObjectStart(tsconfig, compilerOptions, makeDefaultPaths()); return defaultTypesDirectoryName; @@ -129,14 +129,6 @@ namespace ts.codefix { return defaultTypesDirectoryName; } - function createJsonPropertyAssignment(name: string, initializer: Expression) { - return createPropertyAssignment(createStringLiteral(name), initializer); - } - - function findProperty(obj: ObjectLiteralExpression, name: string): PropertyAssignment | undefined { - return find(obj.properties, (p): p is PropertyAssignment => isPropertyAssignment(p) && !!p.name && isStringLiteral(p.name) && p.name.text === name); - } - function getInstallCommand(fileName: string, packageName: string): InstallPackageAction { return { type: "install package", file: fileName, packageName }; } diff --git a/src/services/codefixes/fixEnableExperimentalDecorators.ts b/src/services/codefixes/fixEnableExperimentalDecorators.ts new file mode 100644 index 00000000000..8179abdfd1d --- /dev/null +++ b/src/services/codefixes/fixEnableExperimentalDecorators.ts @@ -0,0 +1,60 @@ +/* @internal */ +namespace ts.codefix { + const fixId = "enableExperimentalDecorators"; + const errorCodes = [ + Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning.code + ]; + registerCodeFix({ + errorCodes, + getCodeActions: (context) => { + const { configFile } = context.program.getCompilerOptions(); + if (configFile === undefined) { + return undefined; + } + + const changes = textChanges.ChangeTracker.with(context, changeTracker => makeChange(changeTracker, configFile)); + return [createCodeFixActionNoFixId(fixId, changes, Diagnostics.Enable_the_experimentalDecorators_option_in_your_configuration_file)]; + }, + fixIds: [fixId], + }); + + function makeChange(changeTracker: textChanges.ChangeTracker, configFile: TsConfigSourceFile) { + const tsconfigObjectLiteral = getTsConfigObjectLiteralExpression(configFile); + if (tsconfigObjectLiteral === undefined) { + return; + } + + const compilerOptionsProperty = findJsonProperty(tsconfigObjectLiteral, "compilerOptions"); + if (compilerOptionsProperty === undefined) { + changeTracker.insertNodeAtObjectStart(configFile, tsconfigObjectLiteral, createCompilerOptionsAssignment()); + return; + } + + const compilerOptions = compilerOptionsProperty.initializer; + if (!isObjectLiteralExpression(compilerOptions)) { + return; + } + + const experimentalDecoratorsProperty = findJsonProperty(compilerOptions, "experimentalDecorators"); + + if (experimentalDecoratorsProperty === undefined) { + changeTracker.insertNodeAtObjectStart(configFile, compilerOptions, createExperimentalDecoratorsAssignment()); + } + else { + changeTracker.replaceNodeWithText(configFile, experimentalDecoratorsProperty.initializer, "true"); + } + } + + function createCompilerOptionsAssignment() { + return createJsonPropertyAssignment( + "compilerOptions", + createObjectLiteral([ + createExperimentalDecoratorsAssignment(), + ]), + ); + } + + function createExperimentalDecoratorsAssignment() { + return createJsonPropertyAssignment("experimentalDecorators", createTrue()); + } +} diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 461771c0b5e..0344f51a854 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -1,5 +1,13 @@ /* @internal */ namespace ts.codefix { + export function createJsonPropertyAssignment(name: string, initializer: Expression) { + return createPropertyAssignment(createStringLiteral(name), initializer); + } + + export function findJsonProperty(obj: ObjectLiteralExpression, name: string): PropertyAssignment | undefined { + return find(obj.properties, (p): p is PropertyAssignment => isPropertyAssignment(p) && !!p.name && isStringLiteral(p.name) && p.name.text === name); + } + /** * Finds members of the resolved type that are missing in the class pointed to by class decl * and generates source code for the missing members. diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 15044416f84..21be663055a 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -61,6 +61,7 @@ "codefixes/fixClassDoesntImplementInheritedAbstractMember.ts", "codefixes/fixClassSuperMustPrecedeThisAccess.ts", "codefixes/fixConstructorForDerivedNeedSuperCall.ts", + "codefixes/fixEnableExperimentalDecorators.ts", "codefixes/fixExtendsInterfaceBecomesImplements.ts", "codefixes/fixForgottenThisPropertyAccess.ts", "codefixes/fixUnusedIdentifier.ts", diff --git a/tests/cases/fourslash/codefixEnableExperimentalDecorators_blankCompilerOptions.ts b/tests/cases/fourslash/codefixEnableExperimentalDecorators_blankCompilerOptions.ts new file mode 100644 index 00000000000..0e19b42d921 --- /dev/null +++ b/tests/cases/fourslash/codefixEnableExperimentalDecorators_blankCompilerOptions.ts @@ -0,0 +1,26 @@ +/// + +// @Filename: /dir/a.ts +////declare const decorator: any; +////class A { +//// @decorator method() {}; +////}; + +// @Filename: /dir/tsconfig.json +////{ +//// "compilerOptions": { +//// } +////} + +goTo.file("/dir/a.ts"); +verify.codeFix({ + description: "Enable the 'experimentalDecorators' option in your configuration file", + newFileContent: { + "/dir/tsconfig.json": +`{ + "compilerOptions": { + "experimentalDecorators": true, + } +}`, + }, +}); diff --git a/tests/cases/fourslash/codefixEnableExperimentalDecorators_disabledInCompilerOptions.ts b/tests/cases/fourslash/codefixEnableExperimentalDecorators_disabledInCompilerOptions.ts new file mode 100644 index 00000000000..056e7e15a48 --- /dev/null +++ b/tests/cases/fourslash/codefixEnableExperimentalDecorators_disabledInCompilerOptions.ts @@ -0,0 +1,27 @@ +/// + +// @Filename: /dir/a.ts +////declare const decorator: any; +////class A { +//// @decorator method() {}; +////}; + +// @Filename: /dir/tsconfig.json +////{ +//// "compilerOptions": { +//// "experimentalDecorators": false, +//// } +////} + +goTo.file("/dir/a.ts"); +verify.codeFix({ + description: "Enable the 'experimentalDecorators' option in your configuration file", + newFileContent: { + "/dir/tsconfig.json": +`{ + "compilerOptions": { + "experimentalDecorators": true, + } +}`, + }, +}); diff --git a/tests/cases/fourslash/codefixEnableExperimentalDecorators_missingCompilerOptions.ts b/tests/cases/fourslash/codefixEnableExperimentalDecorators_missingCompilerOptions.ts new file mode 100644 index 00000000000..6d7006f3ce1 --- /dev/null +++ b/tests/cases/fourslash/codefixEnableExperimentalDecorators_missingCompilerOptions.ts @@ -0,0 +1,22 @@ +/// + +// @Filename: /dir/a.ts +////declare const decorator: any; +////class A { +//// @decorator method() {}; +////}; + +// @Filename: /dir/tsconfig.json +////{ +////} + +goTo.file("/dir/a.ts"); +verify.codeFix({ + description: "Enable the 'experimentalDecorators' option in your configuration file", + newFileContent: { + "/dir/tsconfig.json": +`{ + "compilerOptions": { "experimentalDecorators": true }, +}`, + }, +}); diff --git a/tests/cases/fourslash/codefixEnableExperimentalDecorators_noTsconfig.ts b/tests/cases/fourslash/codefixEnableExperimentalDecorators_noTsconfig.ts new file mode 100644 index 00000000000..8430fd0734b --- /dev/null +++ b/tests/cases/fourslash/codefixEnableExperimentalDecorators_noTsconfig.ts @@ -0,0 +1,10 @@ +/// + +// @Filename: /dir/a.ts +////declare const decorator: any; +////class A { +//// @decorator method() {}; +////}; + +goTo.file("/dir/a.ts"); +verify.not.codeFixAvailable(); From 7b6adae6dd438e2393d55f8b8a932c82ad67a10a Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 11 Jan 2019 15:05:24 -0500 Subject: [PATCH 053/113] Extracted compilerOptions setting to helper function --- .../fixEnableExperimentalDecorators.ts | 38 +------------- src/services/codefixes/helpers.ts | 50 ++++++++++++++++--- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/services/codefixes/fixEnableExperimentalDecorators.ts b/src/services/codefixes/fixEnableExperimentalDecorators.ts index 8179abdfd1d..8aeefe48a47 100644 --- a/src/services/codefixes/fixEnableExperimentalDecorators.ts +++ b/src/services/codefixes/fixEnableExperimentalDecorators.ts @@ -19,42 +19,6 @@ namespace ts.codefix { }); function makeChange(changeTracker: textChanges.ChangeTracker, configFile: TsConfigSourceFile) { - const tsconfigObjectLiteral = getTsConfigObjectLiteralExpression(configFile); - if (tsconfigObjectLiteral === undefined) { - return; - } - - const compilerOptionsProperty = findJsonProperty(tsconfigObjectLiteral, "compilerOptions"); - if (compilerOptionsProperty === undefined) { - changeTracker.insertNodeAtObjectStart(configFile, tsconfigObjectLiteral, createCompilerOptionsAssignment()); - return; - } - - const compilerOptions = compilerOptionsProperty.initializer; - if (!isObjectLiteralExpression(compilerOptions)) { - return; - } - - const experimentalDecoratorsProperty = findJsonProperty(compilerOptions, "experimentalDecorators"); - - if (experimentalDecoratorsProperty === undefined) { - changeTracker.insertNodeAtObjectStart(configFile, compilerOptions, createExperimentalDecoratorsAssignment()); - } - else { - changeTracker.replaceNodeWithText(configFile, experimentalDecoratorsProperty.initializer, "true"); - } - } - - function createCompilerOptionsAssignment() { - return createJsonPropertyAssignment( - "compilerOptions", - createObjectLiteral([ - createExperimentalDecoratorsAssignment(), - ]), - ); - } - - function createExperimentalDecoratorsAssignment() { - return createJsonPropertyAssignment("experimentalDecorators", createTrue()); + setJsonCompilerOptionValue(changeTracker, configFile, "experimentalDecorators", createTrue()); } } diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 0344f51a854..66488d5d697 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -1,13 +1,5 @@ /* @internal */ namespace ts.codefix { - export function createJsonPropertyAssignment(name: string, initializer: Expression) { - return createPropertyAssignment(createStringLiteral(name), initializer); - } - - export function findJsonProperty(obj: ObjectLiteralExpression, name: string): PropertyAssignment | undefined { - return find(obj.properties, (p): p is PropertyAssignment => isPropertyAssignment(p) && !!p.name && isStringLiteral(p.name) && p.name.text === name); - } - /** * Finds members of the resolved type that are missing in the class pointed to by class decl * and generates source code for the missing members. @@ -257,4 +249,46 @@ namespace ts.codefix { } return undefined; } + + export function setJsonCompilerOptionValue( + changeTracker: textChanges.ChangeTracker, + configFile: TsConfigSourceFile, + optionName: string, + optionValue: Expression, + ) { + const tsconfigObjectLiteral = getTsConfigObjectLiteralExpression(configFile); + if (!tsconfigObjectLiteral) return undefined; + + const compilerOptionsProperty = findJsonProperty(tsconfigObjectLiteral, "compilerOptions"); + if (compilerOptionsProperty === undefined) { + changeTracker.insertNodeAtObjectStart(configFile, tsconfigObjectLiteral, createJsonPropertyAssignment( + "compilerOptions", + createObjectLiteral([ + createJsonPropertyAssignment(optionName, optionValue), + ]))); + return; + } + + const compilerOptions = compilerOptionsProperty.initializer; + if (!isObjectLiteralExpression(compilerOptions)) { + return; + } + + const optionProperty = findJsonProperty(compilerOptions, optionName); + + if (optionProperty === undefined) { + changeTracker.insertNodeAtObjectStart(configFile, compilerOptions, createJsonPropertyAssignment(optionName, optionValue)); + } + else { + changeTracker.replaceNode(configFile, optionProperty.initializer, optionValue); + } + } + + export function createJsonPropertyAssignment(name: string, initializer: Expression) { + return createPropertyAssignment(createStringLiteral(name), initializer); + } + + export function findJsonProperty(obj: ObjectLiteralExpression, name: string): PropertyAssignment | undefined { + return find(obj.properties, (p): p is PropertyAssignment => isPropertyAssignment(p) && !!p.name && isStringLiteral(p.name) && p.name.text === name); + } } From a0764178377441c1f4736b43e20b2aafa55504b1 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 11 Jan 2019 22:13:29 +0200 Subject: [PATCH 054/113] remove unused error message 2568 --- src/compiler/diagnosticMessages.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4abdf2b0bb7..a534e41992e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2056,10 +2056,6 @@ "category": "Error", "code": 2567 }, - "Type '{0}' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators.": { - "category": "Error", - "code": 2568 - }, "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.": { "category": "Error", "code": 2569 From b23664adf722f45fef4799342392bc43c70ec848 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 11 Jan 2019 10:57:53 -0800 Subject: [PATCH 055/113] Test to verify external source map range addition --- src/testRunner/unittests/customTransforms.ts | 35 ++++++++++++++++++- .../sourceMapExternalSourceFiles.js | 7 ++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js diff --git a/src/testRunner/unittests/customTransforms.ts b/src/testRunner/unittests/customTransforms.ts index 304c0a55c59..aef9ed745ec 100644 --- a/src/testRunner/unittests/customTransforms.ts +++ b/src/testRunner/unittests/customTransforms.ts @@ -95,6 +95,39 @@ namespace ts { module: ModuleKind.ES2015, emitDecoratorMetadata: true, experimentalDecorators: true - }); + }); + + emitsCorrectly("sourceMapExternalSourceFiles", + [ + { + file: "source.ts", + // The text of length 'changed' is made to be on two lines so we know the line map change + text: `\`multi + line\` +'change'` + }, + ], + { + before: [ + context => node => visitNode(node, function visitor(node: Node): Node { + if (isStringLiteral(node) && node.text === "change") { + const text = "'changed'"; + const lineMap = computeLineStarts(text); + setSourceMapRange(node, { + pos: 0, end: text.length, source: { + text, + fileName: "another.html", + lineMap, + getLineAndCharacterOfPosition: pos => computeLineAndCharacterOfPosition(lineMap, pos) + } + }); + return node; + } + return visitEachChild(node, visitor, context); + }) + ] + }, + { sourceMap: true } + ); }); } diff --git a/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js b/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js new file mode 100644 index 00000000000..69406cfe308 --- /dev/null +++ b/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js @@ -0,0 +1,7 @@ +// [source.js.map] +{"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts","another.html"],"names":[],"mappings":"AAAA,iCACyB,CAAA;ACDzB,QACE,CDCM"} + +// [source.js] +"multi\n line"; +'change'; +//# sourceMappingURL=source.js.map \ No newline at end of file From 021c63f1c365c54b6c061d8e4fd0c5cd9f796fa9 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 11 Jan 2019 12:24:33 -0800 Subject: [PATCH 056/113] Use the SourceMapSource to get line and column instead of current source file Fixes #29300 --- src/compiler/emitter.ts | 2 +- .../reference/customTransforms/sourceMapExternalSourceFiles.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 9c09ed79a77..0afd8ee761c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4389,7 +4389,7 @@ namespace ts { return; } - const { line: sourceLine, character: sourceCharacter } = getLineAndCharacterOfPosition(currentSourceFile!, pos); + const { line: sourceLine, character: sourceCharacter } = getLineAndCharacterOfPosition(sourceMapSource, pos); sourceMapGenerator!.addMapping( writer.getLine(), writer.getColumn(), diff --git a/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js b/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js index 69406cfe308..7191d615fc6 100644 --- a/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js +++ b/tests/baselines/reference/customTransforms/sourceMapExternalSourceFiles.js @@ -1,5 +1,5 @@ // [source.js.map] -{"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts","another.html"],"names":[],"mappings":"AAAA,iCACyB,CAAA;ACDzB,QACE,CDCM"} +{"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts","another.html"],"names":[],"mappings":"AAAA,iCACyB,CAAA;ACDzB,QAAS,CDED"} // [source.js] "multi\n line"; From fadd95f72b5ad7f7f1cffa2b6ac82f612694462c Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 11 Jan 2019 14:24:49 -0800 Subject: [PATCH 057/113] Fix unneeded cast lints (#29383) --- src/compiler/builder.ts | 3 ++- src/compiler/parser.ts | 13 +++++++------ src/harness/compiler.ts | 5 +++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 62dd670fbc5..06615b3a97f 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -78,7 +78,8 @@ namespace ts { if (useOldState) { // Verify the sanity of old state if (!oldState!.currentChangedFilePath) { - Debug.assert(!oldState!.affectedFiles && (!oldState!.currentAffectedFilesSignatures || !oldState!.currentAffectedFilesSignatures!.size), "Cannot reuse if only few affected files of currentChangedFile were iterated"); + const affectedSignatures = oldState!.currentAffectedFilesSignatures; + Debug.assert(!oldState!.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated"); } if (canCopySemanticDiagnostics) { Debug.assert(!forEachKey(oldState!.changedFilesSet, path => oldState!.semanticDiagnosticsPerFile!.has(path)), "Semantic diagnostics shouldnt be available for changed files"); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f976f77ea98..53e45505014 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -7774,17 +7774,18 @@ namespace ts { const libReferenceDirectives = context.libReferenceDirectives; forEach(toArray(entryOrList), (arg: PragmaPseudoMap["reference"]) => { // TODO: GH#18217 + const { types, lib, path } = arg!.arguments; if (arg!.arguments["no-default-lib"]) { context.hasNoDefaultLib = true; } - else if (arg!.arguments.types) { - typeReferenceDirectives.push({ pos: arg!.arguments.types!.pos, end: arg!.arguments.types!.end, fileName: arg!.arguments.types!.value }); + else if (types) { + typeReferenceDirectives.push({ pos: types.pos, end: types.end, fileName: types.value }); } - else if (arg!.arguments.lib) { - libReferenceDirectives.push({ pos: arg!.arguments.lib!.pos, end: arg!.arguments.lib!.end, fileName: arg!.arguments.lib!.value }); + else if (lib) { + libReferenceDirectives.push({ pos: lib.pos, end: lib.end, fileName: lib.value }); } - else if (arg!.arguments.path) { - referencedFiles.push({ pos: arg!.arguments.path!.pos, end: arg!.arguments.path!.end, fileName: arg!.arguments.path!.value }); + else if (path) { + referencedFiles.push({ pos: path.pos, end: path.end, fileName: path.value }); } else { reportDiagnostic(arg!.range.pos, arg!.range.end - arg!.range.pos, Diagnostics.Invalid_reference_directive_syntax); diff --git a/src/harness/compiler.ts b/src/harness/compiler.ts index 532a2d65578..70bda90ef32 100644 --- a/src/harness/compiler.ts +++ b/src/harness/compiler.ts @@ -183,8 +183,9 @@ namespace compiler { } public getSourceMapRecord(): string | undefined { - if (this.result!.sourceMaps && this.result!.sourceMaps!.length > 0) { - return Harness.SourceMapRecorder.getSourceMapRecord(this.result!.sourceMaps!, this.program!, Array.from(this.js.values()).filter(d => !ts.fileExtensionIs(d.file, ts.Extension.Json)), Array.from(this.dts.values())); + const maps = this.result!.sourceMaps; + if (maps && maps.length > 0) { + return Harness.SourceMapRecorder.getSourceMapRecord(maps, this.program!, Array.from(this.js.values()).filter(d => !ts.fileExtensionIs(d.file, ts.Extension.Json)), Array.from(this.dts.values())); } } From d029fae35ce6a49cf6eba6ea981d1d1299569fe2 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Fri, 11 Jan 2019 14:45:08 -0800 Subject: [PATCH 058/113] Add user preference to opt-in to renaming import paths --- src/harness/client.ts | 5 +++-- src/harness/fourslash.ts | 18 ++++++++++-------- src/harness/harnessLanguageService.ts | 4 ++-- src/server/protocol.ts | 1 + src/server/session.ts | 5 +++-- src/services/rename.ts | 8 ++++---- src/services/services.ts | 4 ++-- src/services/shims.ts | 6 +++--- src/services/types.ts | 6 +++++- src/testRunner/unittests/tsserver/rename.ts | 14 ++++++++++++-- .../reference/api/tsserverlibrary.d.ts | 6 +++++- tests/baselines/reference/api/typescript.d.ts | 5 ++++- .../findAllRefs_importType_exportEquals.ts | 1 + tests/cases/fourslash/fourslash.ts | 4 ++-- tests/cases/fourslash/renameImport.ts | 1 + 15 files changed, 58 insertions(+), 30 deletions(-) diff --git a/src/harness/client.ts b/src/harness/client.ts index 27365e3ecf1..937b859853b 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -384,7 +384,8 @@ namespace ts.server { return notImplemented(); } - getRenameInfo(fileName: string, position: number, findInStrings?: boolean, findInComments?: boolean): RenameInfo { + getRenameInfo(fileName: string, position: number, _options?: RenameInfoOptions, findInStrings?: boolean, findInComments?: boolean): RenameInfo { + // not using options they should be sent with a RenameInfo request, which this function does not perform const args: protocol.RenameRequestArgs = { ...this.createFileLocationRequestArgs(fileName, position), findInStrings, findInComments }; const request = this.processRequest(CommandNames.Rename, args); @@ -428,7 +429,7 @@ namespace ts.server { this.lastRenameEntry.inputs.position !== position || this.lastRenameEntry.inputs.findInStrings !== findInStrings || this.lastRenameEntry.inputs.findInComments !== findInComments) { - this.getRenameInfo(fileName, position, findInStrings, findInComments); + this.getRenameInfo(fileName, position, { allowRenameOfImportPath: true }, findInStrings, findInComments); } return this.lastRenameEntry!.locations; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index db1c326a504..fd11236501d 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1308,8 +1308,9 @@ Actual: ${stringify(fullActual)}`); } } - public verifyRenameInfoSucceeded(displayName: string | undefined, fullDisplayName: string | undefined, kind: string | undefined, kindModifiers: string | undefined, fileToRename: string | undefined, expectedRange: Range | undefined): void { - const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); + public verifyRenameInfoSucceeded(displayName: string | undefined, fullDisplayName: string | undefined, kind: string | undefined, kindModifiers: string | undefined, fileToRename: string | undefined, expectedRange: Range | undefined, allowRenameOfImportPath: boolean | undefined): void { + allowRenameOfImportPath = allowRenameOfImportPath === undefined ? true : allowRenameOfImportPath; + const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition, { allowRenameOfImportPath }); if (!renameInfo.canRename) { throw this.raiseError("Rename did not succeed"); } @@ -1334,8 +1335,9 @@ Actual: ${stringify(fullActual)}`); } } - public verifyRenameInfoFailed(message?: string) { - const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); + public verifyRenameInfoFailed(message?: string, allowRenameOfImportPath?: boolean) { + allowRenameOfImportPath = allowRenameOfImportPath === undefined ? true : allowRenameOfImportPath; + const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition, { allowRenameOfImportPath }); if (renameInfo.canRename) { throw this.raiseError("Rename was expected to fail"); } @@ -4091,12 +4093,12 @@ namespace FourSlashInterface { this.state.verifySemanticClassifications(classifications); } - public renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, expectedRange?: FourSlash.Range) { - this.state.verifyRenameInfoSucceeded(displayName, fullDisplayName, kind, kindModifiers, fileToRename, expectedRange); + public renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, expectedRange?: FourSlash.Range, allowRenameOfImportPath?: boolean) { + this.state.verifyRenameInfoSucceeded(displayName, fullDisplayName, kind, kindModifiers, fileToRename, expectedRange, allowRenameOfImportPath); } - public renameInfoFailed(message?: string) { - this.state.verifyRenameInfoFailed(message); + public renameInfoFailed(message?: string, allowRenameOfImportPath?: boolean) { + this.state.verifyRenameInfoFailed(message, allowRenameOfImportPath); } public renameLocations(startRanges: ArrayOrSingle, options: RenameLocationsOptions) { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 581d5cc045d..d233ddf4585 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -469,8 +469,8 @@ namespace Harness.LanguageService { getSignatureHelpItems(fileName: string, position: number, options: ts.SignatureHelpItemsOptions | undefined): ts.SignatureHelpItems { return unwrapJSONCallResult(this.shim.getSignatureHelpItems(fileName, position, options)); } - getRenameInfo(fileName: string, position: number): ts.RenameInfo { - return unwrapJSONCallResult(this.shim.getRenameInfo(fileName, position)); + getRenameInfo(fileName: string, position: number, options?: ts.RenameInfoOptions): ts.RenameInfo { + return unwrapJSONCallResult(this.shim.getRenameInfo(fileName, position, options)); } findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ts.RenameLocation[] { return unwrapJSONCallResult(this.shim.findRenameLocations(fileName, position, findInStrings, findInComments)); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 193621da82a..8b9df926d82 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2905,6 +2905,7 @@ namespace ts.server.protocol { readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; readonly lazyConfiguredProjectsFromExternalProject?: boolean; + readonly allowRenameOfImportPath?: boolean; } export interface CompilerOptions { diff --git a/src/server/session.ts b/src/server/session.ts index d534f445ee3..8c300b121e1 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1177,7 +1177,8 @@ namespace ts.server { private getRenameInfo(args: protocol.FileLocationRequestArgs): RenameInfo { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); - return project.getLanguageService().getRenameInfo(file, position); + const preferences = this.getHostPreferences(); + return project.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: preferences.allowRenameOfImportPath }); } private getProjects(args: protocol.FileRequestArgs, getScriptInfoEnsuringProjectsUptoDate?: boolean, ignoreNoProjectError?: boolean): Projects { @@ -1236,7 +1237,7 @@ namespace ts.server { if (!simplifiedResult) return locations; const defaultProject = this.getDefaultProject(args); - const renameInfo: protocol.RenameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position), Debug.assertDefined(this.projectService.getScriptInfo(file))); + const renameInfo: protocol.RenameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getHostPreferences().allowRenameOfImportPath }), Debug.assertDefined(this.projectService.getScriptInfo(file))); return { info: renameInfo, locs: this.toSpanGroups(locations) }; } diff --git a/src/services/rename.ts b/src/services/rename.ts index a51d79797bf..cef53d251ed 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -1,14 +1,14 @@ /* @internal */ namespace ts.Rename { - export function getRenameInfo(program: Program, sourceFile: SourceFile, position: number): RenameInfo { + export function getRenameInfo(program: Program, sourceFile: SourceFile, position: number, options?: RenameInfoOptions): RenameInfo { const node = getTouchingPropertyName(sourceFile, position); const renameInfo = node && nodeIsEligibleForRename(node) - ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, declaration => program.isSourceFileDefaultLibrary(declaration.getSourceFile())) + ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, options || {}, declaration => program.isSourceFileDefaultLibrary(declaration.getSourceFile())) : undefined; return renameInfo || getRenameInfoError(Diagnostics.You_cannot_rename_this_element); } - function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, isDefinedInLibraryFile: (declaration: Node) => boolean): RenameInfo | undefined { + function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, options: RenameInfoOptions, isDefinedInLibraryFile: (declaration: Node) => boolean): RenameInfo | undefined { const symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) return; // Only allow a symbol to be renamed if it actually has at least one declaration. @@ -26,7 +26,7 @@ namespace ts.Rename { } if (isStringLiteralLike(node) && tryGetImportFromModuleSpecifier(node)) { - return getRenameInfoForModule(node, sourceFile, symbol); + return options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } const kind = SymbolDisplay.getSymbolKind(typeChecker, symbol, node); diff --git a/src/services/services.ts b/src/services/services.ts index 15f9709cb38..6bf6566da36 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2062,9 +2062,9 @@ namespace ts { } } - function getRenameInfo(fileName: string, position: number): RenameInfo { + function getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo { synchronizeHostData(); - return Rename.getRenameInfo(program, getValidSourceFile(fileName), position); + return Rename.getRenameInfo(program, getValidSourceFile(fileName), position, options); } function getRefactorContext(file: SourceFile, positionOrRange: number | TextRange, preferences: UserPreferences, formatOptions?: FormatCodeSettings): RefactorContext { diff --git a/src/services/shims.ts b/src/services/shims.ts index ff66680bdbc..33ea4333e6f 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -164,7 +164,7 @@ namespace ts { * Returns a JSON-encoded value of the type: * { canRename: boolean, localizedErrorMessage: string, displayName: string, fullDisplayName: string, kind: string, kindModifiers: string, triggerSpan: { start; length } } */ - getRenameInfo(fileName: string, position: number): string; + getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): string; /** * Returns a JSON-encoded value of the type: @@ -831,10 +831,10 @@ namespace ts { ); } - public getRenameInfo(fileName: string, position: number): string { + public getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): string { return this.forwardJSONCall( `getRenameInfo('${fileName}', ${position})`, - () => this.languageService.getRenameInfo(fileName, position) + () => this.languageService.getRenameInfo(fileName, position, options) ); } diff --git a/src/services/types.ts b/src/services/types.ts index 5100a999306..b45a816d6e0 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -294,7 +294,7 @@ namespace ts { getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; - getRenameInfo(fileName: string, position: number): RenameInfo; + getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined; getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; @@ -848,6 +848,10 @@ namespace ts { localizedErrorMessage: string; } + export interface RenameInfoOptions { + readonly allowRenameOfImportPath?: boolean; + } + export interface SignatureHelpParameter { name: string; documentation: SymbolDisplayPart[]; diff --git a/src/testRunner/unittests/tsserver/rename.ts b/src/testRunner/unittests/tsserver/rename.ts index 75c08bb8bb0..4e95e79e31f 100644 --- a/src/testRunner/unittests/tsserver/rename.ts +++ b/src/testRunner/unittests/tsserver/rename.ts @@ -7,8 +7,18 @@ namespace ts.projectSystem { const session = createSession(createServerHost([aTs, bTs])); openFilesForSession([bTs], session); - const response = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";')); - assert.deepEqual(response, { + const response1 = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";')); + assert.deepEqual(response1, { + info: { + canRename: false, + localizedErrorMessage: "You cannot rename this element." + }, + locs: [{ file: bTs.path, locs: [protocolRenameSpanFromSubstring(bTs.content, "./a")] }], + }); + + session.getProjectService().setHostConfiguration({ preferences: { allowRenameOfImportPath: true } }); + const response2 = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";')); + assert.deepEqual(response2, { info: { canRename: true, fileToRename: aTs.path, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 91f492ddd1d..30effc9e91a 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4706,7 +4706,7 @@ declare namespace ts { getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; - getRenameInfo(fileName: string, position: number): RenameInfo; + getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined; getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; @@ -5150,6 +5150,9 @@ declare namespace ts { canRename: false; localizedErrorMessage: string; } + interface RenameInfoOptions { + readonly allowRenameOfImportPath?: boolean; + } interface SignatureHelpParameter { name: string; documentation: SymbolDisplayPart[]; @@ -7923,6 +7926,7 @@ declare namespace ts.server.protocol { readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; readonly lazyConfiguredProjectsFromExternalProject?: boolean; + readonly allowRenameOfImportPath?: boolean; } interface CompilerOptions { allowJs?: boolean; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 0e693f698f2..cd6d45a1647 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -4706,7 +4706,7 @@ declare namespace ts { getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; - getRenameInfo(fileName: string, position: number): RenameInfo; + getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined; getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; @@ -5150,6 +5150,9 @@ declare namespace ts { canRename: false; localizedErrorMessage: string; } + interface RenameInfoOptions { + readonly allowRenameOfImportPath?: boolean; + } interface SignatureHelpParameter { name: string; documentation: SymbolDisplayPart[]; diff --git a/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts b/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts index 496fa8a9d3b..3734b7a2e88 100644 --- a/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts +++ b/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts @@ -27,4 +27,5 @@ verify.renameLocations(r2, [r0, r1, r2]); for (const range of [r3b, r4b]) { goTo.rangeStart(range); verify.renameInfoSucceeded(/*displayName*/ "/a.ts", /*fullDisplayName*/ "/a.ts", /*kind*/ "module", /*kindModifiers*/ "", /*fileToRename*/ "/a.ts", range); + verify.renameInfoFailed("You cannot rename this element.", /*allowRenameOfImportPath*/ false); } diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 293c8d21574..ed71f8893b8 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -282,8 +282,8 @@ declare namespace FourSlashInterface { text: string; textSpan?: TextSpan; }[]): void; - renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, range?: Range): void; - renameInfoFailed(message?: string): void; + renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, range?: Range, allowRenameOfImportPath?: boolean): void; + renameInfoFailed(message?: string, allowRenameOfImportPath?: boolean): void; renameLocations(startRanges: ArrayOrSingle, options: RenameLocationsOptions): void; /** Verify the quick info available at the current marker. */ diff --git a/tests/cases/fourslash/renameImport.ts b/tests/cases/fourslash/renameImport.ts index 6fdef347205..8292da4013d 100644 --- a/tests/cases/fourslash/renameImport.ts +++ b/tests/cases/fourslash/renameImport.ts @@ -27,6 +27,7 @@ goTo.eachRange(range => { const name = target === "dir" ? "/dir" : target === "dir/index" ? "/dir/index.ts" : "/a.ts"; const kind = target === "dir" ? "directory" : "module"; verify.renameInfoSucceeded(/*displayName*/ name, /*fullDisplayName*/ name, /*kind*/ kind, /*kindModifiers*/ "", /*fileToRename*/ name, range); + verify.renameInfoFailed("You cannot rename this element.", /*allowRenameOfImportPath*/ false); }); goTo.marker("global"); From c88016d397b1fef00b6f4f39f0be1510e3d358ef Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Fri, 11 Jan 2019 14:52:47 -0800 Subject: [PATCH 059/113] Fix comment --- src/harness/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/client.ts b/src/harness/client.ts index 937b859853b..1c7c0adb834 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -385,7 +385,7 @@ namespace ts.server { } getRenameInfo(fileName: string, position: number, _options?: RenameInfoOptions, findInStrings?: boolean, findInComments?: boolean): RenameInfo { - // not using options they should be sent with a RenameInfo request, which this function does not perform + // Not passing along 'options' because server should already have those from the 'configure' command const args: protocol.RenameRequestArgs = { ...this.createFileLocationRequestArgs(fileName, position), findInStrings, findInComments }; const request = this.processRequest(CommandNames.Rename, args); From c909becdd5eba949cf48b4c0f8d89c783384d6a9 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 Jan 2019 12:40:50 -0800 Subject: [PATCH 060/113] 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 061/113] 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 dc0f4afe5e449bbc2eea7012c0260da080620d4e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 14 Jan 2019 13:53:04 -0800 Subject: [PATCH 062/113] Save & recalculate declare flag modifier on late printed statements (#29412) * Save & recalculate declre flag modifier on late printed statements * Accept related baseline updates --- src/compiler/transformers/declarations.ts | 3 + ...arationEmitLocalClassHasRequiredDeclare.js | 54 +++ ...onEmitLocalClassHasRequiredDeclare.symbols | 27 ++ ...tionEmitLocalClassHasRequiredDeclare.types | 23 ++ .../getEmitOutputWithEmitterErrors2.baseline | 2 +- .../moduleAugmentationImportsAndExports2.js | 2 +- .../moduleAugmentationImportsAndExports3.js | 2 +- .../moduleAugmentationImportsAndExports5.js | 45 +-- .../reference/privacyAccessorDeclFile.js | 273 +-------------- .../privacyFunctionParameterDeclFile.js | 293 +--------------- .../privacyFunctionReturnTypeDeclFile.js | 331 +----------------- ...yLocalInternalReferenceImportWithExport.js | 85 +---- ...calInternalReferenceImportWithoutExport.js | 81 +---- .../privacyTypeParameterOfFunctionDeclFile.js | 159 +-------- .../privacyTypeParametersOfClassDeclFile.js | 64 +--- ...rivacyTypeParametersOfInterfaceDeclFile.js | 109 +----- .../baselines/reference/privacyVarDeclFile.js | 213 +---------- ...arationEmitLocalClassHasRequiredDeclare.ts | 16 + 18 files changed, 137 insertions(+), 1645 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.js create mode 100644 tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.symbols create mode 100644 tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.types create mode 100644 tests/cases/compiler/declarationEmitLocalClassHasRequiredDeclare.ts diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index b54cf5bb858..d03c3b8d30b 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -634,7 +634,10 @@ namespace ts { if (!isLateVisibilityPaintedStatement(i)) { return Debug.fail(`Late replaced statement was found which is not handled by the declaration transformer!: ${(ts as any).SyntaxKind ? (ts as any).SyntaxKind[(i as any).kind] : (i as any).kind}`); } + const priorNeedsDeclare = needsDeclare; + needsDeclare = i.parent && isSourceFile(i.parent) && !(isExternalModule(i.parent) && isBundledEmit); const result = transformTopLevelDeclaration(i, /*privateDeclaration*/ true); + needsDeclare = priorNeedsDeclare; lateStatementReplacementMap.set("" + getOriginalNodeId(i), result); } diff --git a/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.js b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.js new file mode 100644 index 00000000000..4845bc413c4 --- /dev/null +++ b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.js @@ -0,0 +1,54 @@ +//// [declarationEmitLocalClassHasRequiredDeclare.ts] +export declare namespace A { + namespace X { } +} + +class X { } + +export class A { + static X = X; +} + +export declare namespace Y { + +} + +export class Y { } + +//// [declarationEmitLocalClassHasRequiredDeclare.js] +"use strict"; +exports.__esModule = true; +var X = /** @class */ (function () { + function X() { + } + return X; +}()); +var A = /** @class */ (function () { + function A() { + } + A.X = X; + return A; +}()); +exports.A = A; +var Y = /** @class */ (function () { + function Y() { + } + return Y; +}()); +exports.Y = Y; + + +//// [declarationEmitLocalClassHasRequiredDeclare.d.ts] +export declare namespace A { + namespace X { } +} +declare class X { +} +export declare class A { + static X: typeof X; +} +export declare namespace Y { +} +export declare class Y { +} +export {}; diff --git a/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.symbols b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.symbols new file mode 100644 index 00000000000..27cb72b00e0 --- /dev/null +++ b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/declarationEmitLocalClassHasRequiredDeclare.ts === +export declare namespace A { +>A : Symbol(A, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 0, 0), Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 4, 11)) + + namespace X { } +>X : Symbol(X, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 0, 28), Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 6, 16)) +} + +class X { } +>X : Symbol(X, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 2, 1)) + +export class A { +>A : Symbol(A, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 0, 0), Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 4, 11)) + + static X = X; +>X : Symbol(A.X, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 0, 28), Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 6, 16)) +>X : Symbol(X, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 2, 1)) +} + +export declare namespace Y { +>Y : Symbol(Y, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 8, 1), Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 12, 1)) + +} + +export class Y { } +>Y : Symbol(Y, Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 8, 1), Decl(declarationEmitLocalClassHasRequiredDeclare.ts, 12, 1)) + diff --git a/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.types b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.types new file mode 100644 index 00000000000..130f87cd013 --- /dev/null +++ b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/declarationEmitLocalClassHasRequiredDeclare.ts === +export declare namespace A { + namespace X { } +} + +class X { } +>X : X + +export class A { +>A : A + + static X = X; +>X : typeof X +>X : typeof X +} + +export declare namespace Y { + +} + +export class Y { } +>Y : Y + diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline index 46ba9652cc7..7ca62fca61e 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline @@ -16,7 +16,7 @@ define(["require", "exports"], function (require, exports) { }); FileName : /tests/cases/fourslash/inputFile.d.ts -class C { +declare class C { } export declare module M { var foo: C; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js index fcb68f78c15..9c07fcbd933 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js @@ -77,7 +77,7 @@ export declare class B { n: number; } //// [f3.d.ts] -namespace N { +declare namespace N { interface Ifc { a: any; } diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js index abfccd0d424..8229de12e5f 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js @@ -75,7 +75,7 @@ export declare class B { n: number; } //// [f3.d.ts] -namespace N { +declare namespace N { interface Ifc { a: any; } diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js index a1e63f7463c..aa6111a807e 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js @@ -80,7 +80,7 @@ export declare class B { } //// [f3.d.ts] import { B } from "./f2"; -namespace N { +declare namespace N { interface Ifc { a: number; } @@ -100,46 +100,3 @@ declare module "./f1" { export {}; //// [f4.d.ts] import "./f3"; - - -//// [DtsFileErrors] - - -tests/cases/compiler/f3.d.ts(2,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - - -==== tests/cases/compiler/f1.d.ts (0 errors) ==== - export declare class A { - } - -==== tests/cases/compiler/f2.d.ts (0 errors) ==== - export declare class B { - n: number; - } - -==== tests/cases/compiler/f3.d.ts (1 errors) ==== - import { B } from "./f2"; - namespace N { - ~~~~~~~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - interface Ifc { - a: number; - } - interface Cls { - b: number; - } - } - import I = N.Ifc; - import C = N.Cls; - declare module "./f1" { - interface A { - foo(): B; - bar(): I; - baz(): C; - } - } - export {}; - -==== tests/cases/compiler/f4.d.ts (0 errors) ==== - import "./f3"; - \ No newline at end of file diff --git a/tests/baselines/reference/privacyAccessorDeclFile.js b/tests/baselines/reference/privacyAccessorDeclFile.js index 0edef02a54d..8a3a7b2d2de 100644 --- a/tests/baselines/reference/privacyAccessorDeclFile.js +++ b/tests/baselines/reference/privacyAccessorDeclFile.js @@ -3557,7 +3557,7 @@ var publicModuleInGlobal; //// [privacyAccessorDeclFile_externalModule.d.ts] -class privateClass { +declare class privateClass { } export declare class publicClass { } @@ -3815,274 +3815,3 @@ declare module publicModuleInGlobal { myPublicMethod: privateModule.publicClass; } } - - -//// [DtsFileErrors] - - -tests/cases/compiler/privacyAccessorDeclFile_externalModule.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - - -==== tests/cases/compiler/privacyAccessorDeclFile_externalModule.d.ts (1 errors) ==== - class privateClass { - ~~~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - } - export declare class publicClass { - } - export declare class publicClassWithWithPrivateGetAccessorTypes { - static readonly myPublicStaticMethod: privateClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: privateClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: privateClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: privateClass; - private readonly myPrivateMethod1; - } - export declare class publicClassWithWithPublicGetAccessorTypes { - static readonly myPublicStaticMethod: publicClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: publicClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: publicClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: publicClass; - private readonly myPrivateMethod1; - } - export declare class publicClassWithWithPrivateSetAccessorTypes { - static myPublicStaticMethod: privateClass; - private static myPrivateStaticMethod; - myPublicMethod: privateClass; - private myPrivateMethod; - } - export declare class publicClassWithWithPublicSetAccessorTypes { - static myPublicStaticMethod: publicClass; - private static myPrivateStaticMethod; - myPublicMethod: publicClass; - private myPrivateMethod; - } - export declare class publicClassWithPrivateModuleGetAccessorTypes { - static readonly myPublicStaticMethod: privateModule.publicClass; - readonly myPublicMethod: privateModule.publicClass; - static readonly myPublicStaticMethod1: privateModule.publicClass; - readonly myPublicMethod1: privateModule.publicClass; - } - export declare class publicClassWithPrivateModuleSetAccessorTypes { - static myPublicStaticMethod: privateModule.publicClass; - myPublicMethod: privateModule.publicClass; - } - export declare module publicModule { - class privateClass { - } - class publicClass { - } - class publicClassWithWithPrivateGetAccessorTypes { - static readonly myPublicStaticMethod: privateClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: privateClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: privateClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: privateClass; - private readonly myPrivateMethod1; - } - class publicClassWithWithPublicGetAccessorTypes { - static readonly myPublicStaticMethod: publicClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: publicClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: publicClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: publicClass; - private readonly myPrivateMethod1; - } - class publicClassWithWithPrivateSetAccessorTypes { - static myPublicStaticMethod: privateClass; - private static myPrivateStaticMethod; - myPublicMethod: privateClass; - private myPrivateMethod; - } - class publicClassWithWithPublicSetAccessorTypes { - static myPublicStaticMethod: publicClass; - private static myPrivateStaticMethod; - myPublicMethod: publicClass; - private myPrivateMethod; - } - class publicClassWithPrivateModuleGetAccessorTypes { - static readonly myPublicStaticMethod: privateModule.publicClass; - readonly myPublicMethod: privateModule.publicClass; - static readonly myPublicStaticMethod1: privateModule.publicClass; - readonly myPublicMethod1: privateModule.publicClass; - } - class publicClassWithPrivateModuleSetAccessorTypes { - static myPublicStaticMethod: privateModule.publicClass; - myPublicMethod: privateModule.publicClass; - } - } - declare module privateModule { - class privateClass { - } - class publicClass { - } - class publicClassWithWithPrivateGetAccessorTypes { - static readonly myPublicStaticMethod: privateClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: privateClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: privateClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: privateClass; - private readonly myPrivateMethod1; - } - class publicClassWithWithPublicGetAccessorTypes { - static readonly myPublicStaticMethod: publicClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: publicClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: publicClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: publicClass; - private readonly myPrivateMethod1; - } - class publicClassWithWithPrivateSetAccessorTypes { - static myPublicStaticMethod: privateClass; - private static myPrivateStaticMethod; - myPublicMethod: privateClass; - private myPrivateMethod; - } - class publicClassWithWithPublicSetAccessorTypes { - static myPublicStaticMethod: publicClass; - private static myPrivateStaticMethod; - myPublicMethod: publicClass; - private myPrivateMethod; - } - class publicClassWithPrivateModuleGetAccessorTypes { - static readonly myPublicStaticMethod: privateModule.publicClass; - readonly myPublicMethod: privateModule.publicClass; - static readonly myPublicStaticMethod1: publicClass; - readonly myPublicMethod1: publicClass; - } - class publicClassWithPrivateModuleSetAccessorTypes { - static myPublicStaticMethod: privateModule.publicClass; - myPublicMethod: privateModule.publicClass; - } - } - export {}; - -==== tests/cases/compiler/privacyAccessorDeclFile_GlobalFile.d.ts (0 errors) ==== - declare class publicClassInGlobal { - } - declare class publicClassInGlobalWithPublicGetAccessorTypes { - static readonly myPublicStaticMethod: publicClassInGlobal; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: publicClassInGlobal; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: publicClassInGlobal; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: publicClassInGlobal; - private readonly myPrivateMethod1; - } - declare class publicClassInGlobalWithWithPublicSetAccessorTypes { - static myPublicStaticMethod: publicClassInGlobal; - private static myPrivateStaticMethod; - myPublicMethod: publicClassInGlobal; - private myPrivateMethod; - } - declare module publicModuleInGlobal { - class privateClass { - } - class publicClass { - } - module privateModule { - class privateClass { - } - class publicClass { - } - class publicClassWithWithPrivateGetAccessorTypes { - static readonly myPublicStaticMethod: privateClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: privateClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: privateClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: privateClass; - private readonly myPrivateMethod1; - } - class publicClassWithWithPublicGetAccessorTypes { - static readonly myPublicStaticMethod: publicClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: publicClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: publicClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: publicClass; - private readonly myPrivateMethod1; - } - class publicClassWithWithPrivateSetAccessorTypes { - static myPublicStaticMethod: privateClass; - private static myPrivateStaticMethod; - myPublicMethod: privateClass; - private myPrivateMethod; - } - class publicClassWithWithPublicSetAccessorTypes { - static myPublicStaticMethod: publicClass; - private static myPrivateStaticMethod; - myPublicMethod: publicClass; - private myPrivateMethod; - } - class publicClassWithPrivateModuleGetAccessorTypes { - static readonly myPublicStaticMethod: privateModule.publicClass; - readonly myPublicMethod: privateModule.publicClass; - static readonly myPublicStaticMethod1: publicClass; - readonly myPublicMethod1: publicClass; - } - class publicClassWithPrivateModuleSetAccessorTypes { - static myPublicStaticMethod: privateModule.publicClass; - myPublicMethod: privateModule.publicClass; - } - } - class publicClassWithWithPrivateGetAccessorTypes { - static readonly myPublicStaticMethod: privateClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: privateClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: privateClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: privateClass; - private readonly myPrivateMethod1; - } - class publicClassWithWithPublicGetAccessorTypes { - static readonly myPublicStaticMethod: publicClass; - private static readonly myPrivateStaticMethod; - readonly myPublicMethod: publicClass; - private readonly myPrivateMethod; - static readonly myPublicStaticMethod1: publicClass; - private static readonly myPrivateStaticMethod1; - readonly myPublicMethod1: publicClass; - private readonly myPrivateMethod1; - } - class publicClassWithWithPrivateSetAccessorTypes { - static myPublicStaticMethod: privateClass; - private static myPrivateStaticMethod; - myPublicMethod: privateClass; - private myPrivateMethod; - } - class publicClassWithWithPublicSetAccessorTypes { - static myPublicStaticMethod: publicClass; - private static myPrivateStaticMethod; - myPublicMethod: publicClass; - private myPrivateMethod; - } - class publicClassWithPrivateModuleGetAccessorTypes { - static readonly myPublicStaticMethod: privateModule.publicClass; - readonly myPublicMethod: privateModule.publicClass; - static readonly myPublicStaticMethod1: privateModule.publicClass; - readonly myPublicMethod1: privateModule.publicClass; - } - class publicClassWithPrivateModuleSetAccessorTypes { - static myPublicStaticMethod: privateModule.publicClass; - myPublicMethod: privateModule.publicClass; - } - } - \ No newline at end of file diff --git a/tests/baselines/reference/privacyFunctionParameterDeclFile.js b/tests/baselines/reference/privacyFunctionParameterDeclFile.js index b6827934bf2..e287ef7c3d5 100644 --- a/tests/baselines/reference/privacyFunctionParameterDeclFile.js +++ b/tests/baselines/reference/privacyFunctionParameterDeclFile.js @@ -1281,7 +1281,7 @@ var publicModuleInGlobal; //// [privacyFunctionParameterDeclFile_externalModule.d.ts] -class privateClass { +declare class privateClass { } export declare class publicClass { } @@ -1559,294 +1559,3 @@ declare module publicModuleInGlobal { function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; } - - -//// [DtsFileErrors] - - -tests/cases/compiler/privacyFunctionParameterDeclFile_externalModule.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - - -==== tests/cases/compiler/privacyFunctionParameterDeclFile_externalModule.d.ts (1 errors) ==== - class privateClass { - ~~~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - } - export declare class publicClass { - } - export interface publicInterfaceWithPrivateParmeterTypes { - new (param: privateClass): publicClass; - (param: privateClass): publicClass; - myMethod(param: privateClass): void; - } - export interface publicInterfaceWithPublicParmeterTypes { - new (param: publicClass): publicClass; - (param: publicClass): publicClass; - myMethod(param: publicClass): void; - } - export declare class publicClassWithWithPrivateParmeterTypes { - private param1; - param2: privateClass; - static myPublicStaticMethod(param: privateClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: privateClass): void; - private myPrivateMethod; - constructor(param: privateClass, param1: privateClass, param2: privateClass); - } - export declare class publicClassWithWithPublicParmeterTypes { - private param1; - param2: publicClass; - static myPublicStaticMethod(param: publicClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: publicClass): void; - private myPrivateMethod; - constructor(param: publicClass, param1: publicClass, param2: publicClass); - } - export declare function publicFunctionWithPrivateParmeterTypes(param: privateClass): void; - export declare function publicFunctionWithPublicParmeterTypes(param: publicClass): void; - export declare function publicAmbientFunctionWithPrivateParmeterTypes(param: privateClass): void; - export declare function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; - export interface publicInterfaceWithPrivateModuleParameterTypes { - new (param: privateModule.publicClass): publicClass; - (param: privateModule.publicClass): publicClass; - myMethod(param: privateModule.publicClass): void; - } - export declare class publicClassWithPrivateModuleParameterTypes { - private param1; - param2: privateModule.publicClass; - static myPublicStaticMethod(param: privateModule.publicClass): void; - myPublicMethod(param: privateModule.publicClass): void; - constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); - } - export declare function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - export declare module publicModule { - class privateClass { - } - class publicClass { - } - interface publicInterfaceWithPrivateParmeterTypes { - new (param: privateClass): publicClass; - (param: privateClass): publicClass; - myMethod(param: privateClass): void; - } - interface publicInterfaceWithPublicParmeterTypes { - new (param: publicClass): publicClass; - (param: publicClass): publicClass; - myMethod(param: publicClass): void; - } - class publicClassWithWithPrivateParmeterTypes { - private param1; - param2: privateClass; - static myPublicStaticMethod(param: privateClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: privateClass): void; - private myPrivateMethod; - constructor(param: privateClass, param1: privateClass, param2: privateClass); - } - class publicClassWithWithPublicParmeterTypes { - private param1; - param2: publicClass; - static myPublicStaticMethod(param: publicClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: publicClass): void; - private myPrivateMethod; - constructor(param: publicClass, param1: publicClass, param2: publicClass); - } - function publicFunctionWithPrivateParmeterTypes(param: privateClass): void; - function publicFunctionWithPublicParmeterTypes(param: publicClass): void; - function publicAmbientFunctionWithPrivateParmeterTypes(param: privateClass): void; - function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; - interface publicInterfaceWithPrivateModuleParameterTypes { - new (param: privateModule.publicClass): publicClass; - (param: privateModule.publicClass): publicClass; - myMethod(param: privateModule.publicClass): void; - } - class publicClassWithPrivateModuleParameterTypes { - private param1; - param2: privateModule.publicClass; - static myPublicStaticMethod(param: privateModule.publicClass): void; - myPublicMethod(param: privateModule.publicClass): void; - constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); - } - function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - } - declare module privateModule { - class privateClass { - } - class publicClass { - } - interface publicInterfaceWithPrivateParmeterTypes { - new (param: privateClass): publicClass; - (param: privateClass): publicClass; - myMethod(param: privateClass): void; - } - interface publicInterfaceWithPublicParmeterTypes { - new (param: publicClass): publicClass; - (param: publicClass): publicClass; - myMethod(param: publicClass): void; - } - class publicClassWithWithPrivateParmeterTypes { - private param1; - param2: privateClass; - static myPublicStaticMethod(param: privateClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: privateClass): void; - private myPrivateMethod; - constructor(param: privateClass, param1: privateClass, param2: privateClass); - } - class publicClassWithWithPublicParmeterTypes { - private param1; - param2: publicClass; - static myPublicStaticMethod(param: publicClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: publicClass): void; - private myPrivateMethod; - constructor(param: publicClass, param1: publicClass, param2: publicClass); - } - function publicFunctionWithPrivateParmeterTypes(param: privateClass): void; - function publicFunctionWithPublicParmeterTypes(param: publicClass): void; - function publicAmbientFunctionWithPrivateParmeterTypes(param: privateClass): void; - function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; - interface publicInterfaceWithPrivateModuleParameterTypes { - new (param: privateModule.publicClass): publicClass; - (param: privateModule.publicClass): publicClass; - myMethod(param: privateModule.publicClass): void; - } - class publicClassWithPrivateModuleParameterTypes { - private param1; - param2: privateModule.publicClass; - static myPublicStaticMethod(param: privateModule.publicClass): void; - myPublicMethod(param: privateModule.publicClass): void; - constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); - } - function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - } - export {}; - -==== tests/cases/compiler/privacyFunctionParameterDeclFile_GlobalFile.d.ts (0 errors) ==== - declare class publicClassInGlobal { - } - interface publicInterfaceWithPublicParmeterTypesInGlobal { - new (param: publicClassInGlobal): publicClassInGlobal; - (param: publicClassInGlobal): publicClassInGlobal; - myMethod(param: publicClassInGlobal): void; - } - declare class publicClassWithWithPublicParmeterTypesInGlobal { - private param1; - param2: publicClassInGlobal; - static myPublicStaticMethod(param: publicClassInGlobal): void; - private static myPrivateStaticMethod; - myPublicMethod(param: publicClassInGlobal): void; - private myPrivateMethod; - constructor(param: publicClassInGlobal, param1: publicClassInGlobal, param2: publicClassInGlobal); - } - declare function publicFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; - declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; - declare module publicModuleInGlobal { - class privateClass { - } - class publicClass { - } - module privateModule { - class privateClass { - } - class publicClass { - } - interface publicInterfaceWithPrivateParmeterTypes { - new (param: privateClass): publicClass; - (param: privateClass): publicClass; - myMethod(param: privateClass): void; - } - interface publicInterfaceWithPublicParmeterTypes { - new (param: publicClass): publicClass; - (param: publicClass): publicClass; - myMethod(param: publicClass): void; - } - class publicClassWithWithPrivateParmeterTypes { - private param1; - param2: privateClass; - static myPublicStaticMethod(param: privateClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: privateClass): void; - private myPrivateMethod; - constructor(param: privateClass, param1: privateClass, param2: privateClass); - } - class publicClassWithWithPublicParmeterTypes { - private param1; - param2: publicClass; - static myPublicStaticMethod(param: publicClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: publicClass): void; - private myPrivateMethod; - constructor(param: publicClass, param1: publicClass, param2: publicClass); - } - function publicFunctionWithPrivateParmeterTypes(param: privateClass): void; - function publicFunctionWithPublicParmeterTypes(param: publicClass): void; - function publicAmbientFunctionWithPrivateParmeterTypes(param: privateClass): void; - function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; - interface publicInterfaceWithPrivateModuleParameterTypes { - new (param: privateModule.publicClass): publicClass; - (param: privateModule.publicClass): publicClass; - myMethod(param: privateModule.publicClass): void; - } - class publicClassWithPrivateModuleParameterTypes { - private param1; - param2: privateModule.publicClass; - static myPublicStaticMethod(param: privateModule.publicClass): void; - myPublicMethod(param: privateModule.publicClass): void; - constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); - } - function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - } - interface publicInterfaceWithPrivateParmeterTypes { - new (param: privateClass): publicClass; - (param: privateClass): publicClass; - myMethod(param: privateClass): void; - } - interface publicInterfaceWithPublicParmeterTypes { - new (param: publicClass): publicClass; - (param: publicClass): publicClass; - myMethod(param: publicClass): void; - } - class publicClassWithWithPrivateParmeterTypes { - private param1; - param2: privateClass; - static myPublicStaticMethod(param: privateClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: privateClass): void; - private myPrivateMethod; - constructor(param: privateClass, param1: privateClass, param2: privateClass); - } - class publicClassWithWithPublicParmeterTypes { - private param1; - param2: publicClass; - static myPublicStaticMethod(param: publicClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: publicClass): void; - private myPrivateMethod; - constructor(param: publicClass, param1: publicClass, param2: publicClass); - } - function publicFunctionWithPrivateParmeterTypes(param: privateClass): void; - function publicFunctionWithPublicParmeterTypes(param: publicClass): void; - function publicAmbientFunctionWithPrivateParmeterTypes(param: privateClass): void; - function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; - interface publicInterfaceWithPrivateModuleParameterTypes { - new (param: privateModule.publicClass): publicClass; - (param: privateModule.publicClass): publicClass; - myMethod(param: privateModule.publicClass): void; - } - class publicClassWithPrivateModuleParameterTypes { - private param1; - param2: privateModule.publicClass; - static myPublicStaticMethod(param: privateModule.publicClass): void; - myPublicMethod(param: privateModule.publicClass): void; - constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); - } - function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - } - \ No newline at end of file diff --git a/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js b/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js index 1d10cb2083a..79b144d815e 100644 --- a/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js +++ b/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js @@ -2281,7 +2281,7 @@ var publicModuleInGlobal; //// [privacyFunctionReturnTypeDeclFile_externalModule.d.ts] -class privateClass { +declare class privateClass { } export declare class publicClass { } @@ -2597,332 +2597,3 @@ declare module publicModuleInGlobal { function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; } - - -//// [DtsFileErrors] - - -tests/cases/compiler/privacyFunctionReturnTypeDeclFile_externalModule.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - - -==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_externalModule.d.ts (1 errors) ==== - class privateClass { - ~~~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - } - export declare class publicClass { - } - export interface publicInterfaceWithPrivateParmeterTypes { - new (): privateClass; - (): privateClass; - [x: number]: privateClass; - myMethod(): privateClass; - } - export interface publicInterfaceWithPublicParmeterTypes { - new (): publicClass; - (): publicClass; - [x: number]: publicClass; - myMethod(): publicClass; - } - export declare class publicClassWithWithPrivateParmeterTypes { - static myPublicStaticMethod(): privateClass; - private static myPrivateStaticMethod; - myPublicMethod(): privateClass; - private myPrivateMethod; - static myPublicStaticMethod1(): privateClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): privateClass; - private myPrivateMethod1; - } - export declare class publicClassWithWithPublicParmeterTypes { - static myPublicStaticMethod(): publicClass; - private static myPrivateStaticMethod; - myPublicMethod(): publicClass; - private myPrivateMethod; - static myPublicStaticMethod1(): publicClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): publicClass; - private myPrivateMethod1; - } - export declare function publicFunctionWithPrivateParmeterTypes(): privateClass; - export declare function publicFunctionWithPublicParmeterTypes(): publicClass; - export declare function publicFunctionWithPrivateParmeterTypes1(): privateClass; - export declare function publicFunctionWithPublicParmeterTypes1(): publicClass; - export declare function publicAmbientFunctionWithPrivateParmeterTypes(): privateClass; - export declare function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; - export interface publicInterfaceWithPrivateModuleParameterTypes { - new (): privateModule.publicClass; - (): privateModule.publicClass; - [x: number]: privateModule.publicClass; - myMethod(): privateModule.publicClass; - } - export declare class publicClassWithPrivateModuleParameterTypes { - static myPublicStaticMethod(): privateModule.publicClass; - myPublicMethod(): privateModule.publicClass; - static myPublicStaticMethod1(): privateModule.publicClass; - myPublicMethod1(): privateModule.publicClass; - } - export declare function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - export declare function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; - export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - export declare module publicModule { - class privateClass { - } - class publicClass { - } - interface publicInterfaceWithPrivateParmeterTypes { - new (): privateClass; - (): privateClass; - [x: number]: privateClass; - myMethod(): privateClass; - } - interface publicInterfaceWithPublicParmeterTypes { - new (): publicClass; - (): publicClass; - [x: number]: publicClass; - myMethod(): publicClass; - } - class publicClassWithWithPrivateParmeterTypes { - static myPublicStaticMethod(): privateClass; - private static myPrivateStaticMethod; - myPublicMethod(): privateClass; - private myPrivateMethod; - static myPublicStaticMethod1(): privateClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): privateClass; - private myPrivateMethod1; - } - class publicClassWithWithPublicParmeterTypes { - static myPublicStaticMethod(): publicClass; - private static myPrivateStaticMethod; - myPublicMethod(): publicClass; - private myPrivateMethod; - static myPublicStaticMethod1(): publicClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): publicClass; - private myPrivateMethod1; - } - function publicFunctionWithPrivateParmeterTypes(): privateClass; - function publicFunctionWithPublicParmeterTypes(): publicClass; - function publicFunctionWithPrivateParmeterTypes1(): privateClass; - function publicFunctionWithPublicParmeterTypes1(): publicClass; - function publicAmbientFunctionWithPrivateParmeterTypes(): privateClass; - function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; - interface publicInterfaceWithPrivateModuleParameterTypes { - new (): privateModule.publicClass; - (): privateModule.publicClass; - [x: number]: privateModule.publicClass; - myMethod(): privateModule.publicClass; - } - class publicClassWithPrivateModuleParameterTypes { - static myPublicStaticMethod(): privateModule.publicClass; - myPublicMethod(): privateModule.publicClass; - static myPublicStaticMethod1(): privateModule.publicClass; - myPublicMethod1(): privateModule.publicClass; - } - function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; - function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - } - declare module privateModule { - class privateClass { - } - class publicClass { - } - interface publicInterfaceWithPrivateParmeterTypes { - new (): privateClass; - (): privateClass; - [x: number]: privateClass; - myMethod(): privateClass; - } - interface publicInterfaceWithPublicParmeterTypes { - new (): publicClass; - (): publicClass; - [x: number]: publicClass; - myMethod(): publicClass; - } - class publicClassWithWithPrivateParmeterTypes { - static myPublicStaticMethod(): privateClass; - private static myPrivateStaticMethod; - myPublicMethod(): privateClass; - private myPrivateMethod; - static myPublicStaticMethod1(): privateClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): privateClass; - private myPrivateMethod1; - } - class publicClassWithWithPublicParmeterTypes { - static myPublicStaticMethod(): publicClass; - private static myPrivateStaticMethod; - myPublicMethod(): publicClass; - private myPrivateMethod; - static myPublicStaticMethod1(): publicClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): publicClass; - private myPrivateMethod1; - } - function publicFunctionWithPrivateParmeterTypes(): privateClass; - function publicFunctionWithPublicParmeterTypes(): publicClass; - function publicFunctionWithPrivateParmeterTypes1(): privateClass; - function publicFunctionWithPublicParmeterTypes1(): publicClass; - function publicAmbientFunctionWithPrivateParmeterTypes(): privateClass; - function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; - interface publicInterfaceWithPrivateModuleParameterTypes { - new (): privateModule.publicClass; - (): privateModule.publicClass; - [x: number]: privateModule.publicClass; - myMethod(): privateModule.publicClass; - } - class publicClassWithPrivateModuleParameterTypes { - static myPublicStaticMethod(): privateModule.publicClass; - myPublicMethod(): privateModule.publicClass; - static myPublicStaticMethod1(): publicClass; - myPublicMethod1(): publicClass; - } - function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - function publicFunctionWithPrivateModuleParameterTypes1(): publicClass; - function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - } - export {}; - -==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts (0 errors) ==== - declare class publicClassInGlobal { - } - interface publicInterfaceWithPublicParmeterTypesInGlobal { - new (): publicClassInGlobal; - (): publicClassInGlobal; - [x: number]: publicClassInGlobal; - myMethod(): publicClassInGlobal; - } - declare class publicClassWithWithPublicParmeterTypesInGlobal { - static myPublicStaticMethod(): publicClassInGlobal; - private static myPrivateStaticMethod; - myPublicMethod(): publicClassInGlobal; - private myPrivateMethod; - static myPublicStaticMethod1(): publicClassInGlobal; - private static myPrivateStaticMethod1; - myPublicMethod1(): publicClassInGlobal; - private myPrivateMethod1; - } - declare function publicFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; - declare function publicFunctionWithPublicParmeterTypesInGlobal1(): publicClassInGlobal; - declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; - declare module publicModuleInGlobal { - class privateClass { - } - class publicClass { - } - module privateModule { - class privateClass { - } - class publicClass { - } - interface publicInterfaceWithPrivateParmeterTypes { - new (): privateClass; - (): privateClass; - [x: number]: privateClass; - myMethod(): privateClass; - } - interface publicInterfaceWithPublicParmeterTypes { - new (): publicClass; - (): publicClass; - [x: number]: publicClass; - myMethod(): publicClass; - } - class publicClassWithWithPrivateParmeterTypes { - static myPublicStaticMethod(): privateClass; - private static myPrivateStaticMethod; - myPublicMethod(): privateClass; - private myPrivateMethod; - static myPublicStaticMethod1(): privateClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): privateClass; - private myPrivateMethod1; - } - class publicClassWithWithPublicParmeterTypes { - static myPublicStaticMethod(): publicClass; - private static myPrivateStaticMethod; - myPublicMethod(): publicClass; - private myPrivateMethod; - static myPublicStaticMethod1(): publicClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): publicClass; - private myPrivateMethod1; - } - function publicFunctionWithPrivateParmeterTypes(): privateClass; - function publicFunctionWithPublicParmeterTypes(): publicClass; - function publicFunctionWithPrivateParmeterTypes1(): privateClass; - function publicFunctionWithPublicParmeterTypes1(): publicClass; - function publicAmbientFunctionWithPrivateParmeterTypes(): privateClass; - function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; - interface publicInterfaceWithPrivateModuleParameterTypes { - new (): privateModule.publicClass; - (): privateModule.publicClass; - [x: number]: privateModule.publicClass; - myMethod(): privateModule.publicClass; - } - class publicClassWithPrivateModuleParameterTypes { - static myPublicStaticMethod(): privateModule.publicClass; - myPublicMethod(): privateModule.publicClass; - static myPublicStaticMethod1(): publicClass; - myPublicMethod1(): publicClass; - } - function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - function publicFunctionWithPrivateModuleParameterTypes1(): publicClass; - function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - } - interface publicInterfaceWithPrivateParmeterTypes { - new (): privateClass; - (): privateClass; - [x: number]: privateClass; - myMethod(): privateClass; - } - interface publicInterfaceWithPublicParmeterTypes { - new (): publicClass; - (): publicClass; - [x: number]: publicClass; - myMethod(): publicClass; - } - class publicClassWithWithPrivateParmeterTypes { - static myPublicStaticMethod(): privateClass; - private static myPrivateStaticMethod; - myPublicMethod(): privateClass; - private myPrivateMethod; - static myPublicStaticMethod1(): privateClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): privateClass; - private myPrivateMethod1; - } - class publicClassWithWithPublicParmeterTypes { - static myPublicStaticMethod(): publicClass; - private static myPrivateStaticMethod; - myPublicMethod(): publicClass; - private myPrivateMethod; - static myPublicStaticMethod1(): publicClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): publicClass; - private myPrivateMethod1; - } - function publicFunctionWithPrivateParmeterTypes(): privateClass; - function publicFunctionWithPublicParmeterTypes(): publicClass; - function publicFunctionWithPrivateParmeterTypes1(): privateClass; - function publicFunctionWithPublicParmeterTypes1(): publicClass; - function publicAmbientFunctionWithPrivateParmeterTypes(): privateClass; - function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; - interface publicInterfaceWithPrivateModuleParameterTypes { - new (): privateModule.publicClass; - (): privateModule.publicClass; - [x: number]: privateModule.publicClass; - myMethod(): privateModule.publicClass; - } - class publicClassWithPrivateModuleParameterTypes { - static myPublicStaticMethod(): privateModule.publicClass; - myPublicMethod(): privateModule.publicClass; - static myPublicStaticMethod1(): privateModule.publicClass; - myPublicMethod1(): privateModule.publicClass; - } - function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; - function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - } - \ No newline at end of file diff --git a/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js b/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js index 5edf0f819b1..01841c7c44b 100644 --- a/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js +++ b/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js @@ -298,7 +298,7 @@ var import_private; //// [privacyLocalInternalReferenceImportWithExport.d.ts] -module m_private { +declare module m_private { class c_private { } enum e_private { @@ -369,86 +369,3 @@ export declare module import_public { var publicUse_im_public_mu_public: im_public_mu_public.i; } export {}; - - -//// [DtsFileErrors] - - -tests/cases/compiler/privacyLocalInternalReferenceImportWithExport.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - - -==== tests/cases/compiler/privacyLocalInternalReferenceImportWithExport.d.ts (1 errors) ==== - module m_private { - ~~~~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - class c_private { - } - enum e_private { - Happy = 0, - Grumpy = 1 - } - function f_private(): c_private; - var v_private: c_private; - interface i_private { - } - module mi_private { - class c { - } - } - module mu_private { - interface i { - } - } - } - export declare module m_public { - class c_public { - } - enum e_public { - Happy = 0, - Grumpy = 1 - } - function f_public(): c_public; - var v_public: number; - interface i_public { - } - module mi_public { - class c { - } - } - module mu_public { - interface i { - } - } - } - export declare module import_public { - export import im_public_c_private = m_private.c_private; - export import im_public_e_private = m_private.e_private; - export import im_public_f_private = m_private.f_private; - export import im_public_v_private = m_private.v_private; - export import im_public_i_private = m_private.i_private; - export import im_public_mi_private = m_private.mi_private; - export import im_public_mu_private = m_private.mu_private; - var publicUse_im_public_c_private: im_public_c_private; - var publicUse_im_public_e_private: im_public_e_private; - var publicUse_im_public_f_private: im_public_c_private; - var publicUse_im_public_v_private: im_public_c_private; - var publicUse_im_public_i_private: im_public_i_private; - var publicUse_im_public_mi_private: im_public_mi_private.c; - var publicUse_im_public_mu_private: im_public_mu_private.i; - export import im_public_c_public = m_public.c_public; - export import im_public_e_public = m_public.e_public; - export import im_public_f_public = m_public.f_public; - export import im_public_v_public = m_public.v_public; - export import im_public_i_public = m_public.i_public; - export import im_public_mi_public = m_public.mi_public; - export import im_public_mu_public = m_public.mu_public; - var publicUse_im_public_c_public: im_public_c_public; - var publicUse_im_public_e_public: im_public_e_public; - var publicUse_im_public_f_public: im_public_c_public; - var publicUse_im_public_v_public: number; - var publicUse_im_public_i_public: im_public_i_public; - var publicUse_im_public_mi_public: im_public_mi_public.c; - var publicUse_im_public_mu_public: im_public_mu_public.i; - } - export {}; - \ No newline at end of file diff --git a/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js b/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js index 73266bc1d02..35c047e0519 100644 --- a/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js +++ b/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js @@ -300,7 +300,7 @@ define(["require", "exports"], function (require, exports) { //// [privacyLocalInternalReferenceImportWithoutExport.d.ts] -module m_private { +declare module m_private { class c_private { } enum e_private { @@ -367,82 +367,3 @@ export declare module import_public { var publicUse_im_private_mu_public: im_private_mu_public.i; } export {}; - - -//// [DtsFileErrors] - - -tests/cases/compiler/privacyLocalInternalReferenceImportWithoutExport.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - - -==== tests/cases/compiler/privacyLocalInternalReferenceImportWithoutExport.d.ts (1 errors) ==== - module m_private { - ~~~~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - class c_private { - } - enum e_private { - Happy = 0, - Grumpy = 1 - } - function f_private(): c_private; - var v_private: c_private; - interface i_private { - } - module mi_private { - class c { - } - } - module mu_private { - interface i { - } - } - } - export declare module m_public { - class c_public { - } - enum e_public { - Happy = 0, - Grumpy = 1 - } - function f_public(): c_public; - var v_public: number; - interface i_public { - } - module mi_public { - class c { - } - } - module mu_public { - interface i { - } - } - } - export declare module import_public { - import im_private_c_private = m_private.c_private; - import im_private_e_private = m_private.e_private; - import im_private_i_private = m_private.i_private; - import im_private_mi_private = m_private.mi_private; - import im_private_mu_private = m_private.mu_private; - var publicUse_im_private_c_private: im_private_c_private; - var publicUse_im_private_e_private: im_private_e_private; - var publicUse_im_private_f_private: im_private_c_private; - var publicUse_im_private_v_private: im_private_c_private; - var publicUse_im_private_i_private: im_private_i_private; - var publicUse_im_private_mi_private: im_private_mi_private.c; - var publicUse_im_private_mu_private: im_private_mu_private.i; - import im_private_c_public = m_public.c_public; - import im_private_e_public = m_public.e_public; - import im_private_i_public = m_public.i_public; - import im_private_mi_public = m_public.mi_public; - import im_private_mu_public = m_public.mu_public; - var publicUse_im_private_c_public: im_private_c_public; - var publicUse_im_private_e_public: im_private_e_public; - var publicUse_im_private_f_public: im_private_c_public; - var publicUse_im_private_v_public: number; - var publicUse_im_private_i_public: im_private_i_public; - var publicUse_im_private_mi_public: im_private_mi_public.c; - var publicUse_im_private_mu_public: im_private_mu_public.i; - } - export {}; - \ No newline at end of file diff --git a/tests/baselines/reference/privacyTypeParameterOfFunctionDeclFile.js b/tests/baselines/reference/privacyTypeParameterOfFunctionDeclFile.js index 840255f7648..32425e9d9a4 100644 --- a/tests/baselines/reference/privacyTypeParameterOfFunctionDeclFile.js +++ b/tests/baselines/reference/privacyTypeParameterOfFunctionDeclFile.js @@ -819,7 +819,7 @@ var privateModule; //// [privacyTypeParameterOfFunctionDeclFile.d.ts] -class privateClass { +declare class privateClass { } export declare class publicClass { } @@ -964,160 +964,3 @@ declare module privateModule { function publicFunctionWithPublicTypeParametersWithoutExtends(): void; } export {}; - - -//// [DtsFileErrors] - - -tests/cases/compiler/privacyTypeParameterOfFunctionDeclFile.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - - -==== tests/cases/compiler/privacyTypeParameterOfFunctionDeclFile.d.ts (1 errors) ==== - class privateClass { - ~~~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - } - export declare class publicClass { - } - export interface publicInterfaceWithPrivateTypeParameters { - new (): privateClass; - (): privateClass; - myMethod(): privateClass; - } - export interface publicInterfaceWithPublicTypeParameters { - new (): publicClass; - (): publicClass; - myMethod(): publicClass; - } - export declare class publicClassWithWithPrivateTypeParameters { - static myPublicStaticMethod(): void; - private static myPrivateStaticMethod; - myPublicMethod(): void; - private myPrivateMethod; - } - export declare class publicClassWithWithPublicTypeParameters { - static myPublicStaticMethod(): void; - private static myPrivateStaticMethod; - myPublicMethod(): void; - private myPrivateMethod; - } - export declare function publicFunctionWithPrivateTypeParameters(): void; - export declare function publicFunctionWithPublicTypeParameters(): void; - export interface publicInterfaceWithPublicTypeParametersWithoutExtends { - new (): publicClass; - (): publicClass; - myMethod(): publicClass; - } - export declare class publicClassWithWithPublicTypeParametersWithoutExtends { - static myPublicStaticMethod(): void; - private static myPrivateStaticMethod; - myPublicMethod(): void; - private myPrivateMethod; - } - export declare function publicFunctionWithPublicTypeParametersWithoutExtends(): void; - export interface publicInterfaceWithPrivatModuleTypeParameters { - new (): privateModule.publicClass; - (): privateModule.publicClass; - myMethod(): privateModule.publicClass; - } - export declare class publicClassWithWithPrivateModuleTypeParameters { - static myPublicStaticMethod(): void; - myPublicMethod(): void; - } - export declare function publicFunctionWithPrivateMopduleTypeParameters(): void; - export declare module publicModule { - class privateClass { - } - class publicClass { - } - interface publicInterfaceWithPrivateTypeParameters { - new (): privateClass; - (): privateClass; - myMethod(): privateClass; - } - interface publicInterfaceWithPublicTypeParameters { - new (): publicClass; - (): publicClass; - myMethod(): publicClass; - } - class publicClassWithWithPrivateTypeParameters { - static myPublicStaticMethod(): void; - private static myPrivateStaticMethod; - myPublicMethod(): void; - private myPrivateMethod; - } - class publicClassWithWithPublicTypeParameters { - static myPublicStaticMethod(): void; - private static myPrivateStaticMethod; - myPublicMethod(): void; - private myPrivateMethod; - } - function publicFunctionWithPrivateTypeParameters(): void; - function publicFunctionWithPublicTypeParameters(): void; - interface publicInterfaceWithPublicTypeParametersWithoutExtends { - new (): publicClass; - (): publicClass; - myMethod(): publicClass; - } - class publicClassWithWithPublicTypeParametersWithoutExtends { - static myPublicStaticMethod(): void; - private static myPrivateStaticMethod; - myPublicMethod(): void; - private myPrivateMethod; - } - function publicFunctionWithPublicTypeParametersWithoutExtends(): void; - interface publicInterfaceWithPrivatModuleTypeParameters { - new (): privateModule.publicClass; - (): privateModule.publicClass; - myMethod(): privateModule.publicClass; - } - class publicClassWithWithPrivateModuleTypeParameters { - static myPublicStaticMethod(): void; - myPublicMethod(): void; - } - function publicFunctionWithPrivateMopduleTypeParameters(): void; - } - declare module privateModule { - class privateClass { - } - class publicClass { - } - interface publicInterfaceWithPrivateTypeParameters { - new (): privateClass; - (): privateClass; - myMethod(): privateClass; - } - interface publicInterfaceWithPublicTypeParameters { - new (): publicClass; - (): publicClass; - myMethod(): publicClass; - } - class publicClassWithWithPrivateTypeParameters { - static myPublicStaticMethod(): void; - private static myPrivateStaticMethod; - myPublicMethod(): void; - private myPrivateMethod; - } - class publicClassWithWithPublicTypeParameters { - static myPublicStaticMethod(): void; - private static myPrivateStaticMethod; - myPublicMethod(): void; - private myPrivateMethod; - } - function publicFunctionWithPrivateTypeParameters(): void; - function publicFunctionWithPublicTypeParameters(): void; - interface publicInterfaceWithPublicTypeParametersWithoutExtends { - new (): publicClass; - (): publicClass; - myMethod(): publicClass; - } - class publicClassWithWithPublicTypeParametersWithoutExtends { - static myPublicStaticMethod(): void; - private static myPrivateStaticMethod; - myPublicMethod(): void; - private myPrivateMethod; - } - function publicFunctionWithPublicTypeParametersWithoutExtends(): void; - } - export {}; - \ No newline at end of file diff --git a/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js b/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js index b0dfadfce12..bcf4c542fb7 100644 --- a/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js +++ b/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js @@ -386,7 +386,7 @@ var privateModule; //// [privacyTypeParametersOfClassDeclFile.d.ts] -class privateClass { +declare class privateClass { } export declare class publicClass { } @@ -436,65 +436,3 @@ declare module privateModule { } } export {}; - - -//// [DtsFileErrors] - - -tests/cases/compiler/privacyTypeParametersOfClassDeclFile.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - - -==== tests/cases/compiler/privacyTypeParametersOfClassDeclFile.d.ts (1 errors) ==== - class privateClass { - ~~~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - } - export declare class publicClass { - } - export declare class publicClassWithPrivateTypeParameters { - myMethod(val: T): T; - } - export declare class publicClassWithPublicTypeParameters { - myMethod(val: T): T; - } - export declare class publicClassWithPublicTypeParametersWithoutExtends { - myMethod(val: T): T; - } - export declare class publicClassWithTypeParametersFromPrivateModule { - myMethod(val: T): T; - } - export declare module publicModule { - class privateClassInPublicModule { - } - class publicClassInPublicModule { - } - class publicClassWithPrivateTypeParameters { - myMethod(val: T): T; - } - class publicClassWithPublicTypeParameters { - myMethod(val: T): T; - } - class publicClassWithPublicTypeParametersWithoutExtends { - myMethod(val: T): T; - } - class publicClassWithTypeParametersFromPrivateModule { - myMethod(val: T): T; - } - } - declare module privateModule { - class privateClassInPrivateModule { - } - class publicClassInPrivateModule { - } - class publicClassWithPrivateTypeParameters { - myMethod(val: T): T; - } - class publicClassWithPublicTypeParameters { - myMethod(val: T): T; - } - class publicClassWithPublicTypeParametersWithoutExtends { - myMethod(val: T): T; - } - } - export {}; - \ No newline at end of file diff --git a/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js b/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js index 25e327c42aa..2a7a83e4577 100644 --- a/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js +++ b/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js @@ -268,11 +268,11 @@ var privateModule; //// [privacyTypeParametersOfInterfaceDeclFile.d.ts] -class privateClass { +declare class privateClass { } export declare class publicClass { } -class privateClassT { +declare class privateClassT { } export declare class publicClassT { } @@ -361,108 +361,3 @@ declare module privateModule { } } export {}; - - -//// [DtsFileErrors] - - -tests/cases/compiler/privacyTypeParametersOfInterfaceDeclFile.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - - -==== tests/cases/compiler/privacyTypeParametersOfInterfaceDeclFile.d.ts (1 errors) ==== - class privateClass { - ~~~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - } - export declare class publicClass { - } - class privateClassT { - } - export declare class publicClassT { - } - export interface publicInterfaceWithPrivateTypeParameters { - myMethod(val: T): T; - myMethod0(): publicClassT; - myMethod1(): privateClassT; - myMethod2(): privateClassT; - myMethod3(): publicClassT; - myMethod4(): publicClassT; - } - export interface publicInterfaceWithPublicTypeParameters { - myMethod(val: T): T; - myMethod0(): publicClassT; - myMethod1(): privateClassT; - myMethod2(): privateClassT; - myMethod3(): publicClassT; - myMethod4(): publicClassT; - } - export interface publicInterfaceWithPublicTypeParametersWithoutExtends { - myMethod(val: T): T; - myMethod0(): publicClassT; - } - export interface publicInterfaceWithPrivateModuleTypeParameterConstraints { - } - export declare module publicModule { - class privateClassInPublicModule { - } - class publicClassInPublicModule { - } - class privateClassInPublicModuleT { - } - class publicClassInPublicModuleT { - } - interface publicInterfaceWithPrivateTypeParameters { - myMethod(val: T): T; - myMethod0(): publicClassInPublicModuleT; - myMethod1(): privateClassInPublicModuleT; - myMethod2(): privateClassInPublicModuleT; - myMethod3(): publicClassInPublicModuleT; - myMethod4(): publicClassInPublicModuleT; - } - interface publicInterfaceWithPublicTypeParameters { - myMethod(val: T): T; - myMethod0(): publicClassInPublicModuleT; - myMethod1(): privateClassInPublicModuleT; - myMethod2(): privateClassInPublicModuleT; - myMethod3(): publicClassInPublicModuleT; - myMethod4(): publicClassInPublicModuleT; - } - interface publicInterfaceWithPublicTypeParametersWithoutExtends { - myMethod(val: T): T; - myMethod0(): publicClassInPublicModuleT; - } - interface publicInterfaceWithPrivateModuleTypeParameterConstraints { - } - } - declare module privateModule { - class privateClassInPrivateModule { - } - class publicClassInPrivateModule { - } - class privateClassInPrivateModuleT { - } - class publicClassInPrivateModuleT { - } - interface publicInterfaceWithPrivateTypeParameters { - myMethod(val: T): T; - myMethod0(): publicClassInPrivateModuleT; - myMethod1(): privateClassInPrivateModuleT; - myMethod2(): privateClassInPrivateModuleT; - myMethod3(): publicClassInPrivateModuleT; - myMethod4(): publicClassInPrivateModuleT; - } - interface publicInterfaceWithPublicTypeParameters { - myMethod(val: T): T; - myMethod0(): publicClassInPrivateModuleT; - myMethod1(): privateClassInPrivateModuleT; - myMethod2(): privateClassInPrivateModuleT; - myMethod3(): publicClassInPrivateModuleT; - myMethod4(): publicClassInPrivateModuleT; - } - interface publicInterfaceWithPublicTypeParametersWithoutExtends { - myMethod(val: T): T; - myMethod0(): publicClassInPrivateModuleT; - } - } - export {}; - \ No newline at end of file diff --git a/tests/baselines/reference/privacyVarDeclFile.js b/tests/baselines/reference/privacyVarDeclFile.js index 016ccda1de7..f32b8707534 100644 --- a/tests/baselines/reference/privacyVarDeclFile.js +++ b/tests/baselines/reference/privacyVarDeclFile.js @@ -689,7 +689,7 @@ var publicModuleInGlobal; //// [privacyVarDeclFile_externalModule.d.ts] -class privateClass { +declare class privateClass { } export declare class publicClass { } @@ -887,214 +887,3 @@ declare module publicModuleInGlobal { var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; } - - -//// [DtsFileErrors] - - -tests/cases/compiler/privacyVarDeclFile_externalModule.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - - -==== tests/cases/compiler/privacyVarDeclFile_externalModule.d.ts (1 errors) ==== - class privateClass { - ~~~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. - } - export declare class publicClass { - } - export interface publicInterfaceWithPrivatePropertyTypes { - myProperty: privateClass; - } - export interface publicInterfaceWithPublicPropertyTypes { - myProperty: publicClass; - } - export declare class publicClassWithWithPrivatePropertyTypes { - static myPublicStaticProperty: privateClass; - private static myPrivateStaticProperty; - myPublicProperty: privateClass; - private myPrivateProperty; - } - export declare class publicClassWithWithPublicPropertyTypes { - static myPublicStaticProperty: publicClass; - private static myPrivateStaticProperty; - myPublicProperty: publicClass; - private myPrivateProperty; - } - export declare var publicVarWithPrivatePropertyTypes: privateClass; - export declare var publicVarWithPublicPropertyTypes: publicClass; - export declare var publicAmbientVarWithPrivatePropertyTypes: privateClass; - export declare var publicAmbientVarWithPublicPropertyTypes: publicClass; - export interface publicInterfaceWithPrivateModulePropertyTypes { - myProperty: privateModule.publicClass; - } - export declare class publicClassWithPrivateModulePropertyTypes { - static myPublicStaticProperty: privateModule.publicClass; - myPublicProperty: privateModule.publicClass; - } - export declare var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; - export declare var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; - export declare module publicModule { - class privateClass { - } - class publicClass { - } - interface publicInterfaceWithPrivatePropertyTypes { - myProperty: privateClass; - } - interface publicInterfaceWithPublicPropertyTypes { - myProperty: publicClass; - } - class publicClassWithWithPrivatePropertyTypes { - static myPublicStaticProperty: privateClass; - private static myPrivateStaticProperty; - myPublicProperty: privateClass; - private myPrivateProperty; - } - class publicClassWithWithPublicPropertyTypes { - static myPublicStaticProperty: publicClass; - private static myPrivateStaticProperty; - myPublicProperty: publicClass; - private myPrivateProperty; - } - var publicVarWithPrivatePropertyTypes: privateClass; - var publicVarWithPublicPropertyTypes: publicClass; - var publicAmbientVarWithPrivatePropertyTypes: privateClass; - var publicAmbientVarWithPublicPropertyTypes: publicClass; - interface publicInterfaceWithPrivateModulePropertyTypes { - myProperty: privateModule.publicClass; - } - class publicClassWithPrivateModulePropertyTypes { - static myPublicStaticProperty: privateModule.publicClass; - myPublicProperty: privateModule.publicClass; - } - var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; - var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; - } - declare module privateModule { - class privateClass { - } - class publicClass { - } - interface publicInterfaceWithPrivatePropertyTypes { - myProperty: privateClass; - } - interface publicInterfaceWithPublicPropertyTypes { - myProperty: publicClass; - } - class publicClassWithWithPrivatePropertyTypes { - static myPublicStaticProperty: privateClass; - private static myPrivateStaticProperty; - myPublicProperty: privateClass; - private myPrivateProperty; - } - class publicClassWithWithPublicPropertyTypes { - static myPublicStaticProperty: publicClass; - private static myPrivateStaticProperty; - myPublicProperty: publicClass; - private myPrivateProperty; - } - var publicVarWithPrivatePropertyTypes: privateClass; - var publicVarWithPublicPropertyTypes: publicClass; - var publicAmbientVarWithPrivatePropertyTypes: privateClass; - var publicAmbientVarWithPublicPropertyTypes: publicClass; - interface publicInterfaceWithPrivateModulePropertyTypes { - myProperty: privateModule.publicClass; - } - class publicClassWithPrivateModulePropertyTypes { - static myPublicStaticProperty: privateModule.publicClass; - myPublicProperty: privateModule.publicClass; - } - var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; - var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; - } - export {}; - -==== tests/cases/compiler/privacyVarDeclFile_GlobalFile.d.ts (0 errors) ==== - declare class publicClassInGlobal { - } - interface publicInterfaceWithPublicPropertyTypesInGlobal { - myProperty: publicClassInGlobal; - } - declare class publicClassWithWithPublicPropertyTypesInGlobal { - static myPublicStaticProperty: publicClassInGlobal; - private static myPrivateStaticProperty; - myPublicProperty: publicClassInGlobal; - private myPrivateProperty; - } - declare var publicVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; - declare var publicAmbientVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; - declare module publicModuleInGlobal { - class privateClass { - } - class publicClass { - } - module privateModule { - class privateClass { - } - class publicClass { - } - interface publicInterfaceWithPrivatePropertyTypes { - myProperty: privateClass; - } - interface publicInterfaceWithPublicPropertyTypes { - myProperty: publicClass; - } - class publicClassWithWithPrivatePropertyTypes { - static myPublicStaticProperty: privateClass; - private static myPrivateStaticProperty; - myPublicProperty: privateClass; - private myPrivateProperty; - } - class publicClassWithWithPublicPropertyTypes { - static myPublicStaticProperty: publicClass; - private static myPrivateStaticProperty; - myPublicProperty: publicClass; - private myPrivateProperty; - } - var publicVarWithPrivatePropertyTypes: privateClass; - var publicVarWithPublicPropertyTypes: publicClass; - var publicAmbientVarWithPrivatePropertyTypes: privateClass; - var publicAmbientVarWithPublicPropertyTypes: publicClass; - interface publicInterfaceWithPrivateModulePropertyTypes { - myProperty: privateModule.publicClass; - } - class publicClassWithPrivateModulePropertyTypes { - static myPublicStaticProperty: privateModule.publicClass; - myPublicProperty: privateModule.publicClass; - } - var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; - var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; - } - interface publicInterfaceWithPrivatePropertyTypes { - myProperty: privateClass; - } - interface publicInterfaceWithPublicPropertyTypes { - myProperty: publicClass; - } - class publicClassWithWithPrivatePropertyTypes { - static myPublicStaticProperty: privateClass; - private static myPrivateStaticProperty; - myPublicProperty: privateClass; - private myPrivateProperty; - } - class publicClassWithWithPublicPropertyTypes { - static myPublicStaticProperty: publicClass; - private static myPrivateStaticProperty; - myPublicProperty: publicClass; - private myPrivateProperty; - } - var publicVarWithPrivatePropertyTypes: privateClass; - var publicVarWithPublicPropertyTypes: publicClass; - var publicAmbientVarWithPrivatePropertyTypes: privateClass; - var publicAmbientVarWithPublicPropertyTypes: publicClass; - interface publicInterfaceWithPrivateModulePropertyTypes { - myProperty: privateModule.publicClass; - } - class publicClassWithPrivateModulePropertyTypes { - static myPublicStaticProperty: privateModule.publicClass; - myPublicProperty: privateModule.publicClass; - } - var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; - var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; - } - \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitLocalClassHasRequiredDeclare.ts b/tests/cases/compiler/declarationEmitLocalClassHasRequiredDeclare.ts new file mode 100644 index 00000000000..67bbc871545 --- /dev/null +++ b/tests/cases/compiler/declarationEmitLocalClassHasRequiredDeclare.ts @@ -0,0 +1,16 @@ +// @declaration: true +export declare namespace A { + namespace X { } +} + +class X { } + +export class A { + static X = X; +} + +export declare namespace Y { + +} + +export class Y { } \ No newline at end of file From 3d2bf6a75f87e08bb432ee03b70008bf914d4b7a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 14 Jan 2019 13:56:27 -0800 Subject: [PATCH 063/113] Fix implement interface quickfix import types (#29410) * Pass module specifier resolution host thru types constructed by implements quickfixes * Add regression test * Fix scope node for generated methods, fix lints --- src/compiler/types.ts | 2 + src/services/codefixes/fixAddMissingMember.ts | 2 +- ...sDoesntImplementInheritedAbstractMember.ts | 11 +++-- .../fixClassIncorrectlyImplementsInterface.ts | 14 +++--- src/services/codefixes/helpers.ts | 48 +++++++++++++++---- ...ClassImplementInterface_typeInOtherFile.ts | 4 +- .../codeFixUndeclaredAcrossFiles3.ts | 2 +- ...erfaceUnreachableTypeUsesRelativeImport.ts | 26 ++++++++++ 8 files changed, 83 insertions(+), 26 deletions(-) create mode 100644 tests/cases/fourslash/quickfixImplementInterfaceUnreachableTypeUsesRelativeImport.ts diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e46a3d70403..125c3297863 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3037,8 +3037,10 @@ namespace ts { /* @internal */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined; // tslint:disable-line unified-signatures /** Note that the resulting nodes cannot be checked. */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration & {typeArguments?: NodeArray} | undefined; + /* @internal */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): SignatureDeclaration & {typeArguments?: NodeArray} | undefined; // tslint:disable-line unified-signatures /** Note that the resulting nodes cannot be checked. */ indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration | undefined; + /* @internal */ indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): IndexSignatureDeclaration | undefined; // tslint:disable-line unified-signatures /** Note that the resulting nodes cannot be checked. */ symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): EntityName | undefined; /** Note that the resulting nodes cannot be checked. */ diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index bbad3e03824..98ddee61f8e 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -275,7 +275,7 @@ namespace ts.codefix { inJs: boolean, preferences: UserPreferences, ): void { - const methodDeclaration = createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, !isInterfaceDeclaration(typeDecl)); + const methodDeclaration = createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, typeDecl); const containingMethodDeclaration = getAncestor(callExpression, SyntaxKind.MethodDeclaration); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { diff --git a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts index 9d9972c03e8..d18bc50639a 100644 --- a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts +++ b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts @@ -8,9 +8,9 @@ namespace ts.codefix { registerCodeFix({ errorCodes, getCodeActions(context) { - const { program, sourceFile, span } = context; + const { sourceFile, span } = context; const changes = textChanges.ChangeTracker.with(context, t => - addMissingMembers(getClass(sourceFile, span.start), sourceFile, program.getTypeChecker(), t, context.preferences)); + addMissingMembers(getClass(sourceFile, span.start), sourceFile, context, t, context.preferences)); return changes.length === 0 ? undefined : [createCodeFixAction(fixId, changes, Diagnostics.Implement_inherited_abstract_class, fixId, Diagnostics.Implement_all_inherited_abstract_classes)]; }, fixIds: [fixId], @@ -19,7 +19,7 @@ namespace ts.codefix { return codeFixAll(context, errorCodes, (changes, diag) => { const classDeclaration = getClass(diag.file, diag.start); if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) { - addMissingMembers(classDeclaration, context.sourceFile, context.program.getTypeChecker(), changes, context.preferences); + addMissingMembers(classDeclaration, context.sourceFile, context, changes, context.preferences); } }); }, @@ -32,15 +32,16 @@ namespace ts.codefix { return cast(token.parent, isClassLike); } - function addMissingMembers(classDeclaration: ClassLikeDeclaration, sourceFile: SourceFile, checker: TypeChecker, changeTracker: textChanges.ChangeTracker, preferences: UserPreferences): void { + function addMissingMembers(classDeclaration: ClassLikeDeclaration, sourceFile: SourceFile, context: TypeConstructionContext, changeTracker: textChanges.ChangeTracker, preferences: UserPreferences): void { const extendsNode = getEffectiveBaseTypeNode(classDeclaration)!; + const checker = context.program.getTypeChecker(); const instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. const abstractAndNonPrivateExtendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType).filter(symbolPointsToNonPrivateAndAbstractMember); - createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, checker, preferences, member => changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member)); + createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, context, preferences, member => changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member)); } function symbolPointsToNonPrivateAndAbstractMember(symbol: Symbol): boolean { diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 4401625000a..59385f2e2e9 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -6,11 +6,10 @@ namespace ts.codefix { registerCodeFix({ errorCodes, getCodeActions(context) { - const { program, sourceFile, span } = context; + const { sourceFile, span } = context; const classDeclaration = getClass(sourceFile, span.start); - const checker = program.getTypeChecker(); return mapDefined(getClassImplementsHeritageClauseElements(classDeclaration), implementedTypeNode => { - const changes = textChanges.ChangeTracker.with(context, t => addMissingDeclarations(checker, implementedTypeNode, sourceFile, classDeclaration, t, context.preferences)); + const changes = textChanges.ChangeTracker.with(context, t => addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, t, context.preferences)); return changes.length === 0 ? undefined : createCodeFixAction(fixId, changes, [Diagnostics.Implement_interface_0, implementedTypeNode.getText(sourceFile)], fixId, Diagnostics.Implement_all_unimplemented_interfaces); }); }, @@ -21,7 +20,7 @@ namespace ts.codefix { const classDeclaration = getClass(diag.file, diag.start); if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) { for (const implementedTypeNode of getClassImplementsHeritageClauseElements(classDeclaration)!) { - addMissingDeclarations(context.program.getTypeChecker(), implementedTypeNode, diag.file, classDeclaration, changes, context.preferences); + addMissingDeclarations(context, implementedTypeNode, diag.file, classDeclaration, changes, context.preferences); } } }); @@ -37,13 +36,14 @@ namespace ts.codefix { } function addMissingDeclarations( - checker: TypeChecker, + context: TypeConstructionContext, implementedTypeNode: ExpressionWithTypeArguments, sourceFile: SourceFile, classDeclaration: ClassLikeDeclaration, changeTracker: textChanges.ChangeTracker, preferences: UserPreferences, ): void { + const checker = context.program.getTypeChecker(); const maybeHeritageClauseSymbol = getHeritageClauseSymbolTable(classDeclaration, checker); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. @@ -60,12 +60,12 @@ namespace ts.codefix { createMissingIndexSignatureDeclaration(implementedType, IndexKind.String); } - createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, checker, preferences, member => changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member)); + createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, context, preferences, member => changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member)); function createMissingIndexSignatureDeclaration(type: InterfaceType, kind: IndexKind): void { const indexInfoOfKind = checker.getIndexInfoOfType(type, kind); if (indexInfoOfKind) { - changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, checker.indexInfoToIndexSignatureDeclaration(indexInfoOfKind, kind, classDeclaration)!); + changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, checker.indexInfoToIndexSignatureDeclaration(indexInfoOfKind, kind, classDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context))!); } } } diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 66488d5d697..4309e6ec35d 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -6,23 +6,48 @@ namespace ts.codefix { * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. * @returns Empty string iff there are no member insertions. */ - export function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: ReadonlyArray, checker: TypeChecker, preferences: UserPreferences, out: (node: ClassElement) => void): void { + export function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: ReadonlyArray, context: TypeConstructionContext, preferences: UserPreferences, out: (node: ClassElement) => void): void { const classMembers = classDeclaration.symbol.members!; for (const symbol of possiblyMissingSymbols) { if (!classMembers.has(symbol.escapedName)) { - addNewNodeForMemberSymbol(symbol, classDeclaration, checker, preferences, out); + addNewNodeForMemberSymbol(symbol, classDeclaration, context, preferences, out); } } } + function getModuleSpecifierResolverHost(context: TypeConstructionContext): SymbolTracker["moduleResolverHost"] { + return { + directoryExists: context.host.directoryExists ? d => context.host.directoryExists!(d) : undefined, + fileExists: context.host.fileExists ? f => context.host.fileExists!(f) : undefined, + getCurrentDirectory: context.host.getCurrentDirectory ? () => context.host.getCurrentDirectory!() : undefined, + readFile: context.host.readFile ? f => context.host.readFile!(f) : undefined, + useCaseSensitiveFileNames: context.host.useCaseSensitiveFileNames ? () => context.host.useCaseSensitiveFileNames!() : undefined, + getSourceFiles: () => context.program.getSourceFiles(), + getCommonSourceDirectory: () => context.program.getCommonSourceDirectory(), + }; + } + + export function getNoopSymbolTrackerWithResolver(context: TypeConstructionContext): SymbolTracker { + return { + trackSymbol: noop, + moduleResolverHost: getModuleSpecifierResolverHost(context), + }; + } + + export interface TypeConstructionContext { + program: Program; + host: ModuleSpecifierResolutionHost; + } + /** * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. */ - function addNewNodeForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker, preferences: UserPreferences, out: (node: Node) => void): void { + function addNewNodeForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, context: TypeConstructionContext, preferences: UserPreferences, out: (node: Node) => void): void { const declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { return undefined; } + const checker = context.program.getTypeChecker(); const declaration = declarations[0]; const name = getSynthesizedDeepClone(getNameOfDeclaration(declaration), /*includeTrivia*/ false) as PropertyName; @@ -36,7 +61,7 @@ namespace ts.codefix { case SyntaxKind.SetAccessor: case SyntaxKind.PropertySignature: case SyntaxKind.PropertyDeclaration: - const typeNode = checker.typeToTypeNode(type, enclosingDeclaration); + const typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(createProperty( /*decorators*/undefined, modifiers, @@ -83,13 +108,13 @@ namespace ts.codefix { } function outputMethod(signature: Signature, modifiers: NodeArray | undefined, name: PropertyName, body?: Block): void { - const method = signatureToMethodDeclaration(checker, signature, enclosingDeclaration, modifiers, name, optional, body); + const method = signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body); if (method) out(method); } } function signatureToMethodDeclaration( - checker: TypeChecker, + context: TypeConstructionContext, signature: Signature, enclosingDeclaration: ClassLikeDeclaration, modifiers: NodeArray | undefined, @@ -97,7 +122,8 @@ namespace ts.codefix { optional: boolean, body: Block | undefined, ): MethodDeclaration | undefined { - const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration, NodeBuilderFlags.NoTruncation | NodeBuilderFlags.SuppressAnyReturnType); + const program = context.program; + const signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration, NodeBuilderFlags.NoTruncation | NodeBuilderFlags.SuppressAnyReturnType, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -117,18 +143,20 @@ namespace ts.codefix { inJs: boolean, makeStatic: boolean, preferences: UserPreferences, - body: boolean, + contextNode: Node, ): MethodDeclaration { + const body = !isInterfaceDeclaration(contextNode); const { typeArguments, arguments: args, parent } = call; const checker = context.program.getTypeChecker(); + const tracker = getNoopSymbolTrackerWithResolver(context); const types = map(args, arg => // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" - checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)))); + checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker)); const names = map(args, arg => isIdentifier(arg) ? arg.text : isPropertyAccessExpression(arg) ? arg.name.text : undefined); const contextualType = checker.getContextualType(call); - const returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, call) || createKeywordTypeNode(SyntaxKind.AnyKeyword); + const returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker) || createKeywordTypeNode(SyntaxKind.AnyKeyword); return createMethod( /*decorators*/ undefined, /*modifiers*/ makeStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined, diff --git a/tests/cases/fourslash/codeFixClassImplementInterface_typeInOtherFile.ts b/tests/cases/fourslash/codeFixClassImplementInterface_typeInOtherFile.ts index 712bf48e059..ed5d29cd767 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterface_typeInOtherFile.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterface_typeInOtherFile.ts @@ -17,8 +17,8 @@ verify.codeFix({ newFileContent: `import { I } from "./I"; export class C implements I { - x: import("/I").J; - m(): import("/I").J { + x: import("./I").J; + m(): import("./I").J { throw new Error("Method not implemented."); } }`, diff --git a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts index 2b07493f923..dcf5c999d6a 100644 --- a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts +++ b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts @@ -20,7 +20,7 @@ verify.getAndApplyCodeFix(/*errorCode*/ undefined, 0); verify.rangeIs(` - m0(arg0: D): any { + m0(arg0: import("./f2").D): any { throw new Error("Method not implemented."); } `); \ No newline at end of file diff --git a/tests/cases/fourslash/quickfixImplementInterfaceUnreachableTypeUsesRelativeImport.ts b/tests/cases/fourslash/quickfixImplementInterfaceUnreachableTypeUsesRelativeImport.ts new file mode 100644 index 00000000000..ba6cd702ea0 --- /dev/null +++ b/tests/cases/fourslash/quickfixImplementInterfaceUnreachableTypeUsesRelativeImport.ts @@ -0,0 +1,26 @@ +/// + +// @Filename: class.ts +////export class Class { } +// @Filename: interface.ts +////import { Class } from './class'; +//// +////export interface Foo { +//// x: Class; +////} +// @Filename: index.ts +////import { Foo } from './interface'; +//// +////class /*1*/X implements Foo {} +goTo.marker("1"); +verify.codeFix({ + index: 0, + description: "Implement interface 'Foo'", + newFileContent: { + "/tests/cases/fourslash/index.ts": `import { Foo } from './interface'; + +class X implements Foo { + x: import("./class").Class; +}` + } +}); From ff97d86cfabd038275a479c82887d6416302e81b Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 Jan 2019 13:40:54 -0800 Subject: [PATCH 064/113] 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 065/113] Fix typo --- src/compiler/tsbuild.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 60c61f2e62c..4395b302944 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -1422,7 +1422,7 @@ namespace ts { return first(outputs); } } - return Debug.fail(`project ${project.options.configFilePath} expected to have atleast one output`); + return Debug.fail(`project ${project.options.configFilePath} expected to have at least one output`); } export function formatUpToDateStatus(configFileName: string, status: UpToDateStatus, relName: (fileName: string) => string, formatMessage: (message: DiagnosticMessage, ...args: string[]) => T) { From 6e54cbdaff4d988a8bad6e63af8d91a1330b354b Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 Jan 2019 15:09:34 -0800 Subject: [PATCH 066/113] Handle generating action for export equals with anonymous symbol Fixes #28845 --- src/services/completions.ts | 4 ++- ...ompletionsImport_exportEquals_anonymous.ts | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 8203b66549b..f17ee862cca 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -367,7 +367,9 @@ namespace ts.Completions { } function getSymbolName(symbol: Symbol, origin: SymbolOriginInfo | undefined, target: ScriptTarget): string { - return origin && originIsExport(origin) && origin.isDefaultExport && symbol.escapedName === InternalSymbolName.Default + return origin && originIsExport(origin) && ( + (origin.isDefaultExport && symbol.escapedName === InternalSymbolName.Default) || + (symbol.escapedName === InternalSymbolName.ExportEquals)) // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase. ? firstDefined(symbol.declarations, d => isExportAssignment(d) && isIdentifier(d.expression) ? d.expression.text : undefined) || codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) diff --git a/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts b/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts new file mode 100644 index 00000000000..c5e87877cfb --- /dev/null +++ b/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts @@ -0,0 +1,28 @@ +/// + +// Use `/src` to test that directory names are not included in conversion from module path to identifier. +// @noLib: true + +// @Filename: /src/foo-bar.ts +////export = 0; + +// @Filename: /src/b.ts +////exp/*0*/ +////fooB/*1*/ + +goTo.marker("0"); +const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true }; +const exportEntry: FourSlashInterface.ExpectedCompletionEntryObject = { name: "fooBar", source: "/src/foo-bar", sourceDisplay: "./foo-bar", text: "(property) export=: 0", kind: "property", hasAction: true }; +verify.completions( + { marker: "0", exact: ["undefined", exportEntry, ...completion.statementKeywordsWithTypes], preferences }, + { marker: "1", includes: exportEntry, preferences } +); +verify.applyCodeActionFromCompletion("0", { + name: "fooBar", + source: "/src/foo-bar", + description: `Import 'fooBar' from module "./foo-bar"`, + newFileContent: `import fooBar = require("./foo-bar"); + +exp +fooB`, +}); \ No newline at end of file From 2c50ed30890c46d2671894eda21dbf2882166e0a Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Mon, 14 Jan 2019 17:05:25 -0800 Subject: [PATCH 067/113] Respond to CR --- src/harness/fourslash.ts | 9 ++++----- src/services/rename.ts | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index fd11236501d..1276de7de44 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1308,9 +1308,8 @@ Actual: ${stringify(fullActual)}`); } } - public verifyRenameInfoSucceeded(displayName: string | undefined, fullDisplayName: string | undefined, kind: string | undefined, kindModifiers: string | undefined, fileToRename: string | undefined, expectedRange: Range | undefined, allowRenameOfImportPath: boolean | undefined): void { - allowRenameOfImportPath = allowRenameOfImportPath === undefined ? true : allowRenameOfImportPath; - const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition, { allowRenameOfImportPath }); + public verifyRenameInfoSucceeded(displayName: string | undefined, fullDisplayName: string | undefined, kind: string | undefined, kindModifiers: string | undefined, fileToRename: string | undefined, expectedRange: Range | undefined, renameInfoOptions: ts.RenameInfoOptions | undefined): void { + const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition, renameInfoOptions || { allowRenameOfImportPath: true }); if (!renameInfo.canRename) { throw this.raiseError("Rename did not succeed"); } @@ -4093,8 +4092,8 @@ namespace FourSlashInterface { this.state.verifySemanticClassifications(classifications); } - public renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, expectedRange?: FourSlash.Range, allowRenameOfImportPath?: boolean) { - this.state.verifyRenameInfoSucceeded(displayName, fullDisplayName, kind, kindModifiers, fileToRename, expectedRange, allowRenameOfImportPath); + public renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, expectedRange?: FourSlash.Range, options?: ts.RenameInfoOptions) { + this.state.verifyRenameInfoSucceeded(displayName, fullDisplayName, kind, kindModifiers, fileToRename, expectedRange, options); } public renameInfoFailed(message?: string, allowRenameOfImportPath?: boolean) { diff --git a/src/services/rename.ts b/src/services/rename.ts index cef53d251ed..484349acc86 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -3,12 +3,12 @@ namespace ts.Rename { export function getRenameInfo(program: Program, sourceFile: SourceFile, position: number, options?: RenameInfoOptions): RenameInfo { const node = getTouchingPropertyName(sourceFile, position); const renameInfo = node && nodeIsEligibleForRename(node) - ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, options || {}, declaration => program.isSourceFileDefaultLibrary(declaration.getSourceFile())) + ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, declaration => program.isSourceFileDefaultLibrary(declaration.getSourceFile()), options) : undefined; return renameInfo || getRenameInfoError(Diagnostics.You_cannot_rename_this_element); } - function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, options: RenameInfoOptions, isDefinedInLibraryFile: (declaration: Node) => boolean): RenameInfo | undefined { + function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, isDefinedInLibraryFile: (declaration: Node) => boolean, options?: RenameInfoOptions): RenameInfo | undefined { const symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) return; // Only allow a symbol to be renamed if it actually has at least one declaration. @@ -26,7 +26,7 @@ namespace ts.Rename { } if (isStringLiteralLike(node) && tryGetImportFromModuleSpecifier(node)) { - return options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; + return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } const kind = SymbolDisplay.getSymbolKind(typeChecker, symbol, node); From 5763e2c3d436d516e1e2932ed16a61705ae15a69 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 14 Jan 2019 17:08:04 -0800 Subject: [PATCH 068/113] Remove overzealous simple relationship check for unique symbols --- src/compiler/checker.ts | 1 - tests/baselines/reference/uniqueSymbols.js | 7 + .../baselines/reference/uniqueSymbols.symbols | 797 +++++++++--------- tests/baselines/reference/uniqueSymbols.types | 7 + .../types/uniqueSymbol/uniqueSymbols.ts | 4 + 5 files changed, 419 insertions(+), 397 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b48ba6bbcd6..f365af51ac6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11667,7 +11667,6 @@ namespace ts { if (s & TypeFlags.Undefined && (!strictNullChecks || t & (TypeFlags.Undefined | TypeFlags.Void))) return true; if (s & TypeFlags.Null && (!strictNullChecks || t & TypeFlags.Null)) return true; if (s & TypeFlags.Object && t & TypeFlags.NonPrimitive) return true; - if (s & TypeFlags.UniqueESSymbol || t & TypeFlags.UniqueESSymbol) return false; if (relation === assignableRelation || relation === comparableRelation) { if (s & TypeFlags.Any) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any diff --git a/tests/baselines/reference/uniqueSymbols.js b/tests/baselines/reference/uniqueSymbols.js index 0e6bde4fe47..54f59e8e217 100644 --- a/tests/baselines/reference/uniqueSymbols.js +++ b/tests/baselines/reference/uniqueSymbols.js @@ -28,6 +28,10 @@ var varInitToConstDeclAmbient = constType; const constInitToConstCallWithTypeQuery: typeof constCall = constCall; const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; +// assignment from any +// https://github.com/Microsoft/TypeScript/issues/29108 +const fromAny: unique symbol = {} as any; + // function return inference function funcReturnConstCall() { return constCall; } function funcReturnLetCall() { return letCall; } @@ -286,6 +290,9 @@ var varInitToConstDeclAmbient = constType; // declaration from initializer with type query const constInitToConstCallWithTypeQuery = constCall; const constInitToConstDeclAmbientWithTypeQuery = constType; +// assignment from any +// https://github.com/Microsoft/TypeScript/issues/29108 +const fromAny = {}; // function return inference function funcReturnConstCall() { return constCall; } function funcReturnLetCall() { return letCall; } diff --git a/tests/baselines/reference/uniqueSymbols.symbols b/tests/baselines/reference/uniqueSymbols.symbols index 6fef1873082..d7da3595a59 100644 --- a/tests/baselines/reference/uniqueSymbols.symbols +++ b/tests/baselines/reference/uniqueSymbols.symbols @@ -81,717 +81,722 @@ const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; >constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) >constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) +// assignment from any +// https://github.com/Microsoft/TypeScript/issues/29108 +const fromAny: unique symbol = {} as any; +>fromAny : Symbol(fromAny, Decl(uniqueSymbols.ts, 31, 5)) + // function return inference function funcReturnConstCall() { return constCall; } ->funcReturnConstCall : Symbol(funcReturnConstCall, Decl(uniqueSymbols.ts, 27, 77)) +>funcReturnConstCall : Symbol(funcReturnConstCall, Decl(uniqueSymbols.ts, 31, 41)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) function funcReturnLetCall() { return letCall; } ->funcReturnLetCall : Symbol(funcReturnLetCall, Decl(uniqueSymbols.ts, 30, 52)) +>funcReturnLetCall : Symbol(funcReturnLetCall, Decl(uniqueSymbols.ts, 34, 52)) >letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) function funcReturnVarCall() { return varCall; } ->funcReturnVarCall : Symbol(funcReturnVarCall, Decl(uniqueSymbols.ts, 31, 48)) +>funcReturnVarCall : Symbol(funcReturnVarCall, Decl(uniqueSymbols.ts, 35, 48)) >varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) // function return value with type query function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; } ->funcReturnConstCallWithTypeQuery : Symbol(funcReturnConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 32, 48)) +>funcReturnConstCallWithTypeQuery : Symbol(funcReturnConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 36, 48)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) // generator function yield inference function* genFuncYieldConstCall() { yield constCall; } ->genFuncYieldConstCall : Symbol(genFuncYieldConstCall, Decl(uniqueSymbols.ts, 35, 83)) +>genFuncYieldConstCall : Symbol(genFuncYieldConstCall, Decl(uniqueSymbols.ts, 39, 83)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) function* genFuncYieldLetCall() { yield letCall; } ->genFuncYieldLetCall : Symbol(genFuncYieldLetCall, Decl(uniqueSymbols.ts, 38, 54)) +>genFuncYieldLetCall : Symbol(genFuncYieldLetCall, Decl(uniqueSymbols.ts, 42, 54)) >letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) function* genFuncYieldVarCall() { yield varCall; } ->genFuncYieldVarCall : Symbol(genFuncYieldVarCall, Decl(uniqueSymbols.ts, 39, 50)) +>genFuncYieldVarCall : Symbol(genFuncYieldVarCall, Decl(uniqueSymbols.ts, 43, 50)) >varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) // generator function yield with return type query function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } ->genFuncYieldConstCallWithTypeQuery : Symbol(genFuncYieldConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 40, 50)) +>genFuncYieldConstCallWithTypeQuery : Symbol(genFuncYieldConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 44, 50)) >IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) // async function return inference async function asyncFuncReturnConstCall() { return constCall; } ->asyncFuncReturnConstCall : Symbol(asyncFuncReturnConstCall, Decl(uniqueSymbols.ts, 43, 103)) +>asyncFuncReturnConstCall : Symbol(asyncFuncReturnConstCall, Decl(uniqueSymbols.ts, 47, 103)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) async function asyncFuncReturnLetCall() { return letCall; } ->asyncFuncReturnLetCall : Symbol(asyncFuncReturnLetCall, Decl(uniqueSymbols.ts, 46, 63)) +>asyncFuncReturnLetCall : Symbol(asyncFuncReturnLetCall, Decl(uniqueSymbols.ts, 50, 63)) >letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) async function asyncFuncReturnVarCall() { return varCall; } ->asyncFuncReturnVarCall : Symbol(asyncFuncReturnVarCall, Decl(uniqueSymbols.ts, 47, 59)) +>asyncFuncReturnVarCall : Symbol(asyncFuncReturnVarCall, Decl(uniqueSymbols.ts, 51, 59)) >varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) // async generator function yield inference async function* asyncGenFuncYieldConstCall() { yield constCall; } ->asyncGenFuncYieldConstCall : Symbol(asyncGenFuncYieldConstCall, Decl(uniqueSymbols.ts, 48, 59)) +>asyncGenFuncYieldConstCall : Symbol(asyncGenFuncYieldConstCall, Decl(uniqueSymbols.ts, 52, 59)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) async function* asyncGenFuncYieldLetCall() { yield letCall; } ->asyncGenFuncYieldLetCall : Symbol(asyncGenFuncYieldLetCall, Decl(uniqueSymbols.ts, 51, 65)) +>asyncGenFuncYieldLetCall : Symbol(asyncGenFuncYieldLetCall, Decl(uniqueSymbols.ts, 55, 65)) >letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) async function* asyncGenFuncYieldVarCall() { yield varCall; } ->asyncGenFuncYieldVarCall : Symbol(asyncGenFuncYieldVarCall, Decl(uniqueSymbols.ts, 52, 61)) +>asyncGenFuncYieldVarCall : Symbol(asyncGenFuncYieldVarCall, Decl(uniqueSymbols.ts, 56, 61)) >varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) // classes class C { ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) static readonly readonlyStaticCall = Symbol(); ->readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) static readonly readonlyStaticType: unique symbol; ->readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); ->readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) static readwriteStaticCall = Symbol(); ->readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) readonly readonlyCall = Symbol(); ->readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) readwriteCall = Symbol(); ->readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.symbol.d.ts, --, --)) } declare const c: C; ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) const constInitToCReadonlyStaticCall = C.readonlyStaticCall; ->constInitToCReadonlyStaticCall : Symbol(constInitToCReadonlyStaticCall, Decl(uniqueSymbols.ts, 67, 5)) ->C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>constInitToCReadonlyStaticCall : Symbol(constInitToCReadonlyStaticCall, Decl(uniqueSymbols.ts, 71, 5)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) const constInitToCReadonlyStaticType = C.readonlyStaticType; ->constInitToCReadonlyStaticType : Symbol(constInitToCReadonlyStaticType, Decl(uniqueSymbols.ts, 68, 5)) ->C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>constInitToCReadonlyStaticType : Symbol(constInitToCReadonlyStaticType, Decl(uniqueSymbols.ts, 72, 5)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; ->constInitToCReadonlyStaticTypeAndCall : Symbol(constInitToCReadonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 69, 5)) ->C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) +>constInitToCReadonlyStaticTypeAndCall : Symbol(constInitToCReadonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 73, 5)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) const constInitToCReadwriteStaticCall = C.readwriteStaticCall; ->constInitToCReadwriteStaticCall : Symbol(constInitToCReadwriteStaticCall, Decl(uniqueSymbols.ts, 70, 5)) ->C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) +>constInitToCReadwriteStaticCall : Symbol(constInitToCReadwriteStaticCall, Decl(uniqueSymbols.ts, 74, 5)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; ->constInitToCReadonlyStaticCallWithTypeQuery : Symbol(constInitToCReadonlyStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 72, 5)) ->C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) ->C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>constInitToCReadonlyStaticCallWithTypeQuery : Symbol(constInitToCReadonlyStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 76, 5)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 60, 9)) const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; ->constInitToCReadonlyStaticTypeWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeWithTypeQuery, Decl(uniqueSymbols.ts, 73, 5)) ->C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) ->C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>constInitToCReadonlyStaticTypeWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeWithTypeQuery, Decl(uniqueSymbols.ts, 77, 5)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 61, 50)) const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; ->constInitToCReadonlyStaticTypeAndCallWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeAndCallWithTypeQuery, Decl(uniqueSymbols.ts, 74, 5)) ->C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) ->C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) +>constInitToCReadonlyStaticTypeAndCallWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeAndCallWithTypeQuery, Decl(uniqueSymbols.ts, 78, 5)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 62, 54)) const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; ->constInitToCReadwriteStaticCallWithTypeQuery : Symbol(constInitToCReadwriteStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 75, 5)) ->C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) ->C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) +>constInitToCReadwriteStaticCallWithTypeQuery : Symbol(constInitToCReadwriteStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 79, 5)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 63, 72)) const constInitToCReadonlyCall = c.readonlyCall; ->constInitToCReadonlyCall : Symbol(constInitToCReadonlyCall, Decl(uniqueSymbols.ts, 77, 5)) ->c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>constInitToCReadonlyCall : Symbol(constInitToCReadonlyCall, Decl(uniqueSymbols.ts, 81, 5)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) const constInitToCReadwriteCall = c.readwriteCall; ->constInitToCReadwriteCall : Symbol(constInitToCReadwriteCall, Decl(uniqueSymbols.ts, 78, 5)) ->c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>constInitToCReadwriteCall : Symbol(constInitToCReadwriteCall, Decl(uniqueSymbols.ts, 82, 5)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall; ->constInitToCReadonlyCallWithTypeQuery : Symbol(constInitToCReadonlyCallWithTypeQuery, Decl(uniqueSymbols.ts, 79, 5)) ->c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) ->c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>constInitToCReadonlyCallWithTypeQuery : Symbol(constInitToCReadonlyCallWithTypeQuery, Decl(uniqueSymbols.ts, 83, 5)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall; ->constInitToCReadwriteCallWithTypeQuery : Symbol(constInitToCReadwriteCallWithTypeQuery, Decl(uniqueSymbols.ts, 80, 5)) ->c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) ->c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>constInitToCReadwriteCallWithTypeQuery : Symbol(constInitToCReadwriteCallWithTypeQuery, Decl(uniqueSymbols.ts, 84, 5)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall; ->constInitToCReadonlyCallWithIndexedAccess : Symbol(constInitToCReadonlyCallWithIndexedAccess, Decl(uniqueSymbols.ts, 81, 5)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>constInitToCReadonlyCallWithIndexedAccess : Symbol(constInitToCReadonlyCallWithIndexedAccess, Decl(uniqueSymbols.ts, 85, 5)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 64, 42)) const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall; ->constInitToCReadwriteCallWithIndexedAccess : Symbol(constInitToCReadwriteCallWithIndexedAccess, Decl(uniqueSymbols.ts, 82, 5)) ->C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) ->c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) ->c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) ->readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>constInitToCReadwriteCallWithIndexedAccess : Symbol(constInitToCReadwriteCallWithIndexedAccess, Decl(uniqueSymbols.ts, 86, 5)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 57, 61)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 69, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 66, 37)) // interfaces interface I { ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) readonly readonlyType: unique symbol; ->readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) } declare const i: I; ->i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 92, 13)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) const constInitToIReadonlyType = i.readonlyType; ->constInitToIReadonlyType : Symbol(constInitToIReadonlyType, Decl(uniqueSymbols.ts, 90, 5)) ->i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) ->i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) ->readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>constInitToIReadonlyType : Symbol(constInitToIReadonlyType, Decl(uniqueSymbols.ts, 94, 5)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 92, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; ->constInitToIReadonlyTypeWithTypeQuery : Symbol(constInitToIReadonlyTypeWithTypeQuery, Decl(uniqueSymbols.ts, 91, 5)) ->i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) ->i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) ->readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) ->i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) ->i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) ->readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>constInitToIReadonlyTypeWithTypeQuery : Symbol(constInitToIReadonlyTypeWithTypeQuery, Decl(uniqueSymbols.ts, 95, 5)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 92, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 92, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; ->constInitToIReadonlyTypeWithIndexedAccess : Symbol(constInitToIReadonlyTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 92, 5)) ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) ->i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) ->i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) ->readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>constInitToIReadonlyTypeWithIndexedAccess : Symbol(constInitToIReadonlyTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 96, 5)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 92, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 89, 13)) // type literals type L = { ->L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 96, 84)) readonly readonlyType: unique symbol; ->readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) nested: { ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) readonly readonlyNestedType: unique symbol; ->readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) } }; declare const l: L; ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 96, 84)) const constInitToLReadonlyType = l.readonlyType; ->constInitToLReadonlyType : Symbol(constInitToLReadonlyType, Decl(uniqueSymbols.ts, 103, 5)) ->l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>constInitToLReadonlyType : Symbol(constInitToLReadonlyType, Decl(uniqueSymbols.ts, 107, 5)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; ->constInitToLReadonlyNestedType : Symbol(constInitToLReadonlyNestedType, Decl(uniqueSymbols.ts, 104, 5)) ->l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>constInitToLReadonlyNestedType : Symbol(constInitToLReadonlyNestedType, Decl(uniqueSymbols.ts, 108, 5)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; ->constInitToLReadonlyTypeWithTypeQuery : Symbol(constInitToLReadonlyTypeWithTypeQuery, Decl(uniqueSymbols.ts, 105, 5)) ->l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) ->l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>constInitToLReadonlyTypeWithTypeQuery : Symbol(constInitToLReadonlyTypeWithTypeQuery, Decl(uniqueSymbols.ts, 109, 5)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; ->constInitToLReadonlyNestedTypeWithTypeQuery : Symbol(constInitToLReadonlyNestedTypeWithTypeQuery, Decl(uniqueSymbols.ts, 106, 5)) ->l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>constInitToLReadonlyNestedTypeWithTypeQuery : Symbol(constInitToLReadonlyNestedTypeWithTypeQuery, Decl(uniqueSymbols.ts, 110, 5)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; ->constInitToLReadonlyTypeWithIndexedAccess : Symbol(constInitToLReadonlyTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 107, 5)) ->L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) ->l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>constInitToLReadonlyTypeWithIndexedAccess : Symbol(constInitToLReadonlyTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 111, 5)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 96, 84)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 99, 10)) const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; ->constInitToLReadonlyNestedTypeWithIndexedAccess : Symbol(constInitToLReadonlyNestedTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 108, 5)) ->L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) ->l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) ->l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) ->nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) ->readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>constInitToLReadonlyNestedTypeWithIndexedAccess : Symbol(constInitToLReadonlyNestedTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 112, 5)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 96, 84)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 105, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 100, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 101, 13)) // type argument inference const promiseForConstCall = Promise.resolve(constCall); ->promiseForConstCall : Symbol(promiseForConstCall, Decl(uniqueSymbols.ts, 111, 5)) +>promiseForConstCall : Symbol(promiseForConstCall, Decl(uniqueSymbols.ts, 115, 5)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) const arrayOfConstCall = [constCall]; ->arrayOfConstCall : Symbol(arrayOfConstCall, Decl(uniqueSymbols.ts, 112, 5)) +>arrayOfConstCall : Symbol(arrayOfConstCall, Decl(uniqueSymbols.ts, 116, 5)) >constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) // unique symbol widening in expressions declare const s: unique symbol; ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) declare namespace N { const s: unique symbol; } ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 120, 27)) declare const o: { [s]: "a", [N.s]: "b" }; ->o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) ->[s] : Symbol([s], Decl(uniqueSymbols.ts, 117, 18)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->[N.s] : Symbol([N.s], Decl(uniqueSymbols.ts, 117, 28)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>o : Symbol(o, Decl(uniqueSymbols.ts, 121, 13)) +>[s] : Symbol([s], Decl(uniqueSymbols.ts, 121, 18)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>[N.s] : Symbol([N.s], Decl(uniqueSymbols.ts, 121, 28)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) declare function f(x: T): T; ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->T : Symbol(T, Decl(uniqueSymbols.ts, 118, 19)) ->x : Symbol(x, Decl(uniqueSymbols.ts, 118, 22)) ->T : Symbol(T, Decl(uniqueSymbols.ts, 118, 19)) ->T : Symbol(T, Decl(uniqueSymbols.ts, 118, 19)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>T : Symbol(T, Decl(uniqueSymbols.ts, 122, 19)) +>x : Symbol(x, Decl(uniqueSymbols.ts, 122, 22)) +>T : Symbol(T, Decl(uniqueSymbols.ts, 122, 19)) +>T : Symbol(T, Decl(uniqueSymbols.ts, 122, 19)) declare function g(x: typeof s): void; ->g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) ->x : Symbol(x, Decl(uniqueSymbols.ts, 119, 19)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>g : Symbol(g, Decl(uniqueSymbols.ts, 122, 31), Decl(uniqueSymbols.ts, 123, 38)) +>x : Symbol(x, Decl(uniqueSymbols.ts, 123, 19)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) declare function g(x: typeof N.s): void; ->g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) ->x : Symbol(x, Decl(uniqueSymbols.ts, 120, 19)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>g : Symbol(g, Decl(uniqueSymbols.ts, 122, 31), Decl(uniqueSymbols.ts, 123, 38)) +>x : Symbol(x, Decl(uniqueSymbols.ts, 124, 19)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // widening positions // argument inference f(s); ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) f(N.s); ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) f(N["s"]); ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // array literal elements [s]; ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) [N.s]; ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) [N["s"]]; ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // property assignments/methods const o2 = { ->o2 : Symbol(o2, Decl(uniqueSymbols.ts, 135, 5)) +>o2 : Symbol(o2, Decl(uniqueSymbols.ts, 139, 5)) a: s, ->a : Symbol(a, Decl(uniqueSymbols.ts, 135, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>a : Symbol(a, Decl(uniqueSymbols.ts, 139, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) b: N.s, ->b : Symbol(b, Decl(uniqueSymbols.ts, 136, 9)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>b : Symbol(b, Decl(uniqueSymbols.ts, 140, 9)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) c: N["s"], ->c : Symbol(c, Decl(uniqueSymbols.ts, 137, 11)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 141, 11)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) method1() { return s; }, ->method1 : Symbol(method1, Decl(uniqueSymbols.ts, 138, 14)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method1 : Symbol(method1, Decl(uniqueSymbols.ts, 142, 14)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) async method2() { return s; }, ->method2 : Symbol(method2, Decl(uniqueSymbols.ts, 140, 28)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method2 : Symbol(method2, Decl(uniqueSymbols.ts, 144, 28)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) async * method3() { yield s; }, ->method3 : Symbol(method3, Decl(uniqueSymbols.ts, 141, 34)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method3 : Symbol(method3, Decl(uniqueSymbols.ts, 145, 34)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) * method4() { yield s; }, ->method4 : Symbol(method4, Decl(uniqueSymbols.ts, 142, 35)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method4 : Symbol(method4, Decl(uniqueSymbols.ts, 146, 35)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) method5(p = s) { return p; }, ->method5 : Symbol(method5, Decl(uniqueSymbols.ts, 143, 29)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 144, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 144, 12)) +>method5 : Symbol(method5, Decl(uniqueSymbols.ts, 147, 29)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 148, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 148, 12)) }; // property initializers class C0 { ->C0 : Symbol(C0, Decl(uniqueSymbols.ts, 145, 2)) +>C0 : Symbol(C0, Decl(uniqueSymbols.ts, 149, 2)) static readonly a = s; ->a : Symbol(C0.a, Decl(uniqueSymbols.ts, 148, 10)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>a : Symbol(C0.a, Decl(uniqueSymbols.ts, 152, 10)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) static readonly b = N.s; ->b : Symbol(C0.b, Decl(uniqueSymbols.ts, 149, 26)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>b : Symbol(C0.b, Decl(uniqueSymbols.ts, 153, 26)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) static readonly c = N["s"]; ->c : Symbol(C0.c, Decl(uniqueSymbols.ts, 150, 28)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>c : Symbol(C0.c, Decl(uniqueSymbols.ts, 154, 28)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) static d = s; ->d : Symbol(C0.d, Decl(uniqueSymbols.ts, 151, 31)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>d : Symbol(C0.d, Decl(uniqueSymbols.ts, 155, 31)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) static e = N.s; ->e : Symbol(C0.e, Decl(uniqueSymbols.ts, 153, 17)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>e : Symbol(C0.e, Decl(uniqueSymbols.ts, 157, 17)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) static f = N["s"]; ->f : Symbol(C0.f, Decl(uniqueSymbols.ts, 154, 19)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>f : Symbol(C0.f, Decl(uniqueSymbols.ts, 158, 19)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) readonly a = s; ->a : Symbol(C0.a, Decl(uniqueSymbols.ts, 155, 22)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>a : Symbol(C0.a, Decl(uniqueSymbols.ts, 159, 22)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) readonly b = N.s; ->b : Symbol(C0.b, Decl(uniqueSymbols.ts, 157, 19)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>b : Symbol(C0.b, Decl(uniqueSymbols.ts, 161, 19)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) readonly c = N["s"]; ->c : Symbol(C0.c, Decl(uniqueSymbols.ts, 158, 21)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>c : Symbol(C0.c, Decl(uniqueSymbols.ts, 162, 21)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) d = s; ->d : Symbol(C0.d, Decl(uniqueSymbols.ts, 159, 24)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>d : Symbol(C0.d, Decl(uniqueSymbols.ts, 163, 24)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) e = N.s; ->e : Symbol(C0.e, Decl(uniqueSymbols.ts, 161, 10)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>e : Symbol(C0.e, Decl(uniqueSymbols.ts, 165, 10)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) f = N["s"]; ->f : Symbol(C0.f, Decl(uniqueSymbols.ts, 162, 12)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>f : Symbol(C0.f, Decl(uniqueSymbols.ts, 166, 12)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) method1() { return s; } ->method1 : Symbol(C0.method1, Decl(uniqueSymbols.ts, 163, 15)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method1 : Symbol(C0.method1, Decl(uniqueSymbols.ts, 167, 15)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) async method2() { return s; } ->method2 : Symbol(C0.method2, Decl(uniqueSymbols.ts, 165, 27)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method2 : Symbol(C0.method2, Decl(uniqueSymbols.ts, 169, 27)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) async * method3() { yield s; } ->method3 : Symbol(C0.method3, Decl(uniqueSymbols.ts, 166, 33)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method3 : Symbol(C0.method3, Decl(uniqueSymbols.ts, 170, 33)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) * method4() { yield s; } ->method4 : Symbol(C0.method4, Decl(uniqueSymbols.ts, 167, 34)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method4 : Symbol(C0.method4, Decl(uniqueSymbols.ts, 171, 34)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) method5(p = s) { return p; } ->method5 : Symbol(C0.method5, Decl(uniqueSymbols.ts, 168, 28)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 169, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 169, 12)) +>method5 : Symbol(C0.method5, Decl(uniqueSymbols.ts, 172, 28)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 173, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 173, 12)) } // non-widening positions // element access o[s]; ->o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>o : Symbol(o, Decl(uniqueSymbols.ts, 121, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) o[N.s]; ->o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>o : Symbol(o, Decl(uniqueSymbols.ts, 121, 13)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) o[N["s"]]; ->o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>o : Symbol(o, Decl(uniqueSymbols.ts, 121, 13)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // arguments (no-inference) f(s); ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) f(N.s); ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) f(N["s"]); ->f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>f : Symbol(f, Decl(uniqueSymbols.ts, 121, 42)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) g(s); ->g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>g : Symbol(g, Decl(uniqueSymbols.ts, 122, 31), Decl(uniqueSymbols.ts, 123, 38)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) g(N.s); ->g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>g : Symbol(g, Decl(uniqueSymbols.ts, 122, 31), Decl(uniqueSymbols.ts, 123, 38)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) g(N["s"]); ->g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>g : Symbol(g, Decl(uniqueSymbols.ts, 122, 31), Decl(uniqueSymbols.ts, 123, 38)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // falsy expressions s || ""; ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) N.s || ""; ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) N["s"] || ""; ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // conditionals Math.random() * 2 ? s : "a"; >Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) >Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) Math.random() * 2 ? N.s : "a"; >Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) >Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) Math.random() * 2 ? N["s"] : "a"; >Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) >Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) // computed property names ({ [s]: "a", ->[s] : Symbol([s], Decl(uniqueSymbols.ts, 198, 2)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>[s] : Symbol([s], Decl(uniqueSymbols.ts, 202, 2)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) [N.s]: "b", ->[N.s] : Symbol([N.s], Decl(uniqueSymbols.ts, 199, 13)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>[N.s] : Symbol([N.s], Decl(uniqueSymbols.ts, 203, 13)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) }); class C1 { ->C1 : Symbol(C1, Decl(uniqueSymbols.ts, 201, 3)) +>C1 : Symbol(C1, Decl(uniqueSymbols.ts, 205, 3)) static [s]: "a"; ->[s] : Symbol(C1[s], Decl(uniqueSymbols.ts, 203, 10)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>[s] : Symbol(C1[s], Decl(uniqueSymbols.ts, 207, 10)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) static [N.s]: "b"; ->[N.s] : Symbol(C1[N.s], Decl(uniqueSymbols.ts, 204, 20)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>[N.s] : Symbol(C1[N.s], Decl(uniqueSymbols.ts, 208, 20)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) [s]: "a"; ->[s] : Symbol(C1[s], Decl(uniqueSymbols.ts, 205, 22)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>[s] : Symbol(C1[s], Decl(uniqueSymbols.ts, 209, 22)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) [N.s]: "b"; ->[N.s] : Symbol(C1[N.s], Decl(uniqueSymbols.ts, 207, 13)) ->N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) ->N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) ->s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) +>[N.s] : Symbol(C1[N.s], Decl(uniqueSymbols.ts, 211, 13)) +>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 119, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.ts, 120, 27)) } // contextual types interface Context { ->Context : Symbol(Context, Decl(uniqueSymbols.ts, 209, 1)) +>Context : Symbol(Context, Decl(uniqueSymbols.ts, 213, 1)) method1(): typeof s; ->method1 : Symbol(Context.method1, Decl(uniqueSymbols.ts, 213, 19)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method1 : Symbol(Context.method1, Decl(uniqueSymbols.ts, 217, 19)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) method2(): Promise; ->method2 : Symbol(Context.method2, Decl(uniqueSymbols.ts, 214, 24)) +>method2 : Symbol(Context.method2, Decl(uniqueSymbols.ts, 218, 24)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) method3(): AsyncIterableIterator; ->method3 : Symbol(Context.method3, Decl(uniqueSymbols.ts, 215, 33)) +>method3 : Symbol(Context.method3, Decl(uniqueSymbols.ts, 219, 33)) >AsyncIterableIterator : Symbol(AsyncIterableIterator, Decl(lib.esnext.asynciterable.d.ts, --, --)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) method4(): IterableIterator; ->method4 : Symbol(Context.method4, Decl(uniqueSymbols.ts, 216, 47)) +>method4 : Symbol(Context.method4, Decl(uniqueSymbols.ts, 220, 47)) >IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) method5(p?: typeof s): typeof s; ->method5 : Symbol(Context.method5, Decl(uniqueSymbols.ts, 217, 42)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 218, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method5 : Symbol(Context.method5, Decl(uniqueSymbols.ts, 221, 42)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 222, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) } const o3: Context = { ->o3 : Symbol(o3, Decl(uniqueSymbols.ts, 221, 5)) ->Context : Symbol(Context, Decl(uniqueSymbols.ts, 209, 1)) +>o3 : Symbol(o3, Decl(uniqueSymbols.ts, 225, 5)) +>Context : Symbol(Context, Decl(uniqueSymbols.ts, 213, 1)) method1() { ->method1 : Symbol(method1, Decl(uniqueSymbols.ts, 221, 21)) +>method1 : Symbol(method1, Decl(uniqueSymbols.ts, 225, 21)) return s; // return type should not widen due to contextual type ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) }, async method2() { ->method2 : Symbol(method2, Decl(uniqueSymbols.ts, 224, 6)) +>method2 : Symbol(method2, Decl(uniqueSymbols.ts, 228, 6)) return s; // return type should not widen due to contextual type ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) }, async * method3() { ->method3 : Symbol(method3, Decl(uniqueSymbols.ts, 227, 6)) +>method3 : Symbol(method3, Decl(uniqueSymbols.ts, 231, 6)) yield s; // yield type should not widen due to contextual type ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) }, * method4() { ->method4 : Symbol(method4, Decl(uniqueSymbols.ts, 230, 6)) +>method4 : Symbol(method4, Decl(uniqueSymbols.ts, 234, 6)) yield s; // yield type should not widen due to contextual type ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) }, method5(p = s) { // parameter should not widen due to contextual type ->method5 : Symbol(method5, Decl(uniqueSymbols.ts, 233, 6)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 234, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method5 : Symbol(method5, Decl(uniqueSymbols.ts, 237, 6)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 238, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) return p; ->p : Symbol(p, Decl(uniqueSymbols.ts, 234, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 238, 12)) }, }; @@ -799,60 +804,60 @@ const o3: Context = { // allowed when not emitting declarations const o4 = { ->o4 : Symbol(o4, Decl(uniqueSymbols.ts, 241, 5)) +>o4 : Symbol(o4, Decl(uniqueSymbols.ts, 245, 5)) method1(p: typeof s): typeof s { ->method1 : Symbol(method1, Decl(uniqueSymbols.ts, 241, 12)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 242, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method1 : Symbol(method1, Decl(uniqueSymbols.ts, 245, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 246, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) return p; ->p : Symbol(p, Decl(uniqueSymbols.ts, 242, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 246, 12)) }, method2(p: I["readonlyType"]): I["readonlyType"] { ->method2 : Symbol(method2, Decl(uniqueSymbols.ts, 244, 6)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 245, 12)) ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) +>method2 : Symbol(method2, Decl(uniqueSymbols.ts, 248, 6)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 249, 12)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) return p; ->p : Symbol(p, Decl(uniqueSymbols.ts, 245, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 249, 12)) } }; const ce0 = class { ->ce0 : Symbol(ce0, Decl(uniqueSymbols.ts, 250, 5)) +>ce0 : Symbol(ce0, Decl(uniqueSymbols.ts, 254, 5)) method1(p: typeof s): typeof s { ->method1 : Symbol(ce0.method1, Decl(uniqueSymbols.ts, 250, 19)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 251, 12)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>method1 : Symbol(ce0.method1, Decl(uniqueSymbols.ts, 254, 19)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 255, 12)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) return p; ->p : Symbol(p, Decl(uniqueSymbols.ts, 251, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 255, 12)) } method2(p: I["readonlyType"]): I["readonlyType"] { ->method2 : Symbol(ce0.method2, Decl(uniqueSymbols.ts, 253, 5)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 254, 12)) ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) ->I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) +>method2 : Symbol(ce0.method2, Decl(uniqueSymbols.ts, 257, 5)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 258, 12)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 86, 87)) return p; ->p : Symbol(p, Decl(uniqueSymbols.ts, 254, 12)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 258, 12)) } }; function funcInferredReturnType(obj: { method(p: typeof s): void }) { ->funcInferredReturnType : Symbol(funcInferredReturnType, Decl(uniqueSymbols.ts, 257, 2)) ->obj : Symbol(obj, Decl(uniqueSymbols.ts, 259, 32)) ->method : Symbol(method, Decl(uniqueSymbols.ts, 259, 38)) ->p : Symbol(p, Decl(uniqueSymbols.ts, 259, 46)) ->s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>funcInferredReturnType : Symbol(funcInferredReturnType, Decl(uniqueSymbols.ts, 261, 2)) +>obj : Symbol(obj, Decl(uniqueSymbols.ts, 263, 32)) +>method : Symbol(method, Decl(uniqueSymbols.ts, 263, 38)) +>p : Symbol(p, Decl(uniqueSymbols.ts, 263, 46)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 119, 13)) return obj; ->obj : Symbol(obj, Decl(uniqueSymbols.ts, 259, 32)) +>obj : Symbol(obj, Decl(uniqueSymbols.ts, 263, 32)) } diff --git a/tests/baselines/reference/uniqueSymbols.types b/tests/baselines/reference/uniqueSymbols.types index 7bf4b7fdf4a..9ee3be1cb28 100644 --- a/tests/baselines/reference/uniqueSymbols.types +++ b/tests/baselines/reference/uniqueSymbols.types @@ -85,6 +85,13 @@ const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; >constType : unique symbol >constType : unique symbol +// assignment from any +// https://github.com/Microsoft/TypeScript/issues/29108 +const fromAny: unique symbol = {} as any; +>fromAny : unique symbol +>{} as any : any +>{} : {} + // function return inference function funcReturnConstCall() { return constCall; } >funcReturnConstCall : () => symbol diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts index 498a1c2904d..59d00a55ed9 100644 --- a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts @@ -31,6 +31,10 @@ var varInitToConstDeclAmbient = constType; const constInitToConstCallWithTypeQuery: typeof constCall = constCall; const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; +// assignment from any +// https://github.com/Microsoft/TypeScript/issues/29108 +const fromAny: unique symbol = {} as any; + // function return inference function funcReturnConstCall() { return constCall; } function funcReturnLetCall() { return letCall; } From 104434182b6bf0922920b935ad8a083201fd8ed7 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Mon, 14 Jan 2019 17:01:46 -0800 Subject: [PATCH 069/113] Harden telemetryOnOpenFile against disabled projects As for syntax-only servers, we can't meaningfully report open-file telemetry for projects with disabled language services. Hopefully, a deeper fix will follow, but this solves the immediate problem that VS disables the LS for all projects when it sees a failure in applyChangedToOpenFiles (because it assumes the server state is corrupt). --- src/server/editorServices.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index cd1c69a2d67..3e062efc272 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -2777,7 +2777,12 @@ namespace ts.server { return; } - const info: OpenFileInfo = { checkJs: !!scriptInfo.getDefaultProject().getSourceFile(scriptInfo.path)!.checkJsDirective }; + const project = scriptInfo.getDefaultProject(); + if (!project.languageServiceEnabled) { + return; + } + + const info: OpenFileInfo = { checkJs: !!project.getSourceFile(scriptInfo.path)!.checkJsDirective }; this.eventHandler({ eventName: OpenFileInfoTelemetryEvent, data: { info } }); } From b86cb27d0b222f1cadb00e391928923c26244257 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Mon, 14 Jan 2019 18:13:13 -0800 Subject: [PATCH 070/113] Fix trailing whitespace --- src/server/editorServices.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 3e062efc272..bc8197f9354 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -2780,7 +2780,7 @@ namespace ts.server { const project = scriptInfo.getDefaultProject(); if (!project.languageServiceEnabled) { return; - } + } const info: OpenFileInfo = { checkJs: !!project.getSourceFile(scriptInfo.path)!.checkJsDirective }; this.eventHandler({ eventName: OpenFileInfoTelemetryEvent, data: { info } }); From 520e33fa513a8c5ce17d2e9db390f1f9c241d555 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 Jan 2019 15:09:34 -0800 Subject: [PATCH 071/113] PR feedback --- src/compiler/watch.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index b92289635d3..6dbed259547 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -203,17 +203,14 @@ namespace ts { TypeRoots = "Type roots" } - interface WatchFactory extends ts.WatchFactory { - watchLogLevel: WatchLogLevel; + interface WatchFactory extends ts.WatchFactory { writeLog: (s: string) => void; } export function createWatchFactory(host: { trace?(s: string): void; }, options: { extendedDiagnostics?: boolean; diagnostics?: boolean; }) { - const watchLogLevel = host.trace ? options.extendedDiagnostics ? WatchLogLevel.Verbose : - options.diagnostics ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None; + const watchLogLevel = host.trace ? options.extendedDiagnostics ? WatchLogLevel.Verbose : options.diagnostics ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None; const writeLog: (s: string) => void = watchLogLevel !== WatchLogLevel.None ? (s => host.trace!(s)) : noop; const result = getWatchFactory(watchLogLevel, writeLog) as WatchFactory; - result.watchLogLevel = watchLogLevel; result.writeLog = writeLog; return result; } @@ -590,7 +587,7 @@ namespace ts { newLine = updateNewLine(); } - const { watchFile, watchFilePath, watchDirectory, watchLogLevel, writeLog } = createWatchFactory(host, compilerOptions); + const { watchFile, watchFilePath, watchDirectory, writeLog } = createWatchFactory(host, compilerOptions); const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); writeLog(`Current directory: ${currentDirectory} CaseSensitiveFileNames: ${useCaseSensitiveFileNames}`); @@ -685,11 +682,9 @@ namespace ts { function createNewProgram(program: Program, hasInvalidatedResolution: HasInvalidatedResolution) { // Compile the program - if (watchLogLevel !== WatchLogLevel.None) { - writeLog("CreatingProgramWith::"); - writeLog(` roots: ${JSON.stringify(rootFileNames)}`); - writeLog(` options: ${JSON.stringify(compilerOptions)}`); - } + writeLog("CreatingProgramWith::"); + writeLog(` roots: ${JSON.stringify(rootFileNames)}`); + writeLog(` options: ${JSON.stringify(compilerOptions)}`); const needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !program; hasChangedCompilerOptions = false; From 3fb09630a82c3f94e47ec37515cb0733b6cfcdb5 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 15 Jan 2019 10:55:15 -0800 Subject: [PATCH 072/113] Add regression test --- src/testRunner/unittests/tsserver/projects.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/testRunner/unittests/tsserver/projects.ts b/src/testRunner/unittests/tsserver/projects.ts index 00941a1d3c9..3a648c9189e 100644 --- a/src/testRunner/unittests/tsserver/projects.ts +++ b/src/testRunner/unittests/tsserver/projects.ts @@ -103,6 +103,30 @@ namespace ts.projectSystem { assert.isFalse(proj3.languageServiceEnabled); }); + it("should not crash when opening a file in a project with a disabled language service", () => { + const file1 = { + path: "/a/b/f1.js", + content: "let x =1;", + fileSize: 50 * 1024 * 1024 + }; + const file2 = { + path: "/a/b/f2.js", + content: "let x =1;", + fileSize: 100 + }; + + const projName = "proj1"; + + const host = createServerHost([file1, file2]); + const projectService = createProjectService(host, { useSingleInferredProject: true }, { eventHandler: noop }); + + projectService.openExternalProject({ rootFiles: toExternalFiles([file1.path, file2.path]), options: {}, projectFileName: projName }); + const proj1 = projectService.findProject(projName)!; + assert.isFalse(proj1.languageServiceEnabled); + + assert.doesNotThrow(() => projectService.openClientFile(file2.path)); + }); + describe("ignoreConfigFiles", () => { it("external project including config file", () => { const file1 = { From 49689894d747714d6b2b8461b9033020efec9625 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 15 Jan 2019 11:32:36 -0800 Subject: [PATCH 073/113] Elaborate jsx children elementwise (#29264) * Heavy WIP, but has good contextual typing fix * Add arity error, refine messages and spans * Small error message change * Better error messages, text-specific message --- src/compiler/checker.ts | 133 ++++++++++++- src/compiler/diagnosticMessages.json | 12 ++ src/compiler/utilities.ts | 3 +- .../checkJsxChildrenProperty14.errors.txt | 8 +- .../checkJsxChildrenProperty2.errors.txt | 40 +--- .../checkJsxChildrenProperty4.errors.txt | 27 ++- .../checkJsxChildrenProperty5.errors.txt | 22 +-- .../checkJsxChildrenProperty7.errors.txt | 40 +--- ...sxFactoryDeclarationsLocalTypes.errors.txt | 32 ++- ...xChildrenGenericContextualTypes.errors.txt | 30 +-- ...drenIndividualErrorElaborations.errors.txt | 128 ++++++++++++ .../jsxChildrenIndividualErrorElaborations.js | 119 ++++++++++++ ...hildrenIndividualErrorElaborations.symbols | 169 ++++++++++++++++ ...xChildrenIndividualErrorElaborations.types | 183 ++++++++++++++++++ ...jsxChildrenIndividualErrorElaborations.tsx | 78 ++++++++ 15 files changed, 883 insertions(+), 141 deletions(-) create mode 100644 tests/baselines/reference/jsxChildrenIndividualErrorElaborations.errors.txt create mode 100644 tests/baselines/reference/jsxChildrenIndividualErrorElaborations.js create mode 100644 tests/baselines/reference/jsxChildrenIndividualErrorElaborations.symbols create mode 100644 tests/baselines/reference/jsxChildrenIndividualErrorElaborations.types create mode 100644 tests/cases/compiler/jsxChildrenIndividualErrorElaborations.tsx diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f365af51ac6..ab460212d53 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11196,7 +11196,7 @@ namespace ts { case SyntaxKind.ArrayLiteralExpression: return elaborateArrayLiteral(node as ArrayLiteralExpression, source, target, relation); case SyntaxKind.JsxAttributes: - return elaborateJsxAttributes(node as JsxAttributes, source, target, relation); + return elaborateJsxComponents(node as JsxAttributes, source, target, relation); case SyntaxKind.ArrowFunction: return elaborateArrowFunction(node as ArrowFunction, source, target, relation); } @@ -11336,8 +11336,113 @@ namespace ts { } } - function elaborateJsxAttributes(node: JsxAttributes, source: Type, target: Type, relation: Map) { - return elaborateElementwise(generateJsxAttributes(node), source, target, relation); + function *generateJsxChildren(node: JsxElement, getInvalidTextDiagnostic: () => DiagnosticMessage): ElaborationIterator { + if (!length(node.children)) return; + let memberOffset = 0; + for (let i = 0; i < node.children.length; i++) { + const child = node.children[i]; + const nameType = getLiteralType(i - memberOffset); + const elem = getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic); + if (elem) { + yield elem; + } + else { + memberOffset++; + } + } + } + + function getElaborationElementForJsxChild(child: JsxChild, nameType: LiteralType, getInvalidTextDiagnostic: () => DiagnosticMessage) { + switch (child.kind) { + case SyntaxKind.JsxExpression: + // child is of the type of the expression + return { errorNode: child, innerExpression: child.expression, nameType }; + case SyntaxKind.JsxText: + if (child.containsOnlyWhiteSpaces) { + break; // Whitespace only jsx text isn't real jsx text + } + // child is a string + return { errorNode: child, innerExpression: undefined, nameType, errorMessage: getInvalidTextDiagnostic() }; + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxFragment: + // child is of type JSX.Element + return { errorNode: child, innerExpression: child, nameType }; + default: + return Debug.assertNever(child, "Found invalid jsx child"); + } + } + + function elaborateJsxComponents(node: JsxAttributes, source: Type, target: Type, relation: Map) { + let result = elaborateElementwise(generateJsxAttributes(node), source, target, relation); + let invalidTextDiagnostic: DiagnosticMessage | undefined; + if (isJsxOpeningElement(node.parent) && isJsxElement(node.parent.parent)) { + const containingElement = node.parent.parent; + const childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); + const childrenPropName = childPropName === undefined ? "children" : unescapeLeadingUnderscores(childPropName); + const childrenNameType = getLiteralType(childrenPropName); + const childrenTargetType = getIndexedAccessType(target, childrenNameType); + const validChildren = filter(containingElement.children, i => !isJsxText(i) || !i.containsOnlyWhiteSpaces); + if (!length(validChildren)) { + return result; + } + const moreThanOneRealChildren = length(validChildren) > 1; + const arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType); + const nonArrayLikeTargetParts = filterType(childrenTargetType, t => !isArrayOrTupleLikeType(t)); + if (moreThanOneRealChildren) { + if (arrayLikeTargetParts !== neverType) { + const realSource = createTupleType(checkJsxChildren(containingElement, CheckMode.Normal)); + result = elaborateElementwise(generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic), realSource, arrayLikeTargetParts, relation) || result; + } + else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) { + // arity mismatch + result = true; + error( + containingElement.openingElement.tagName, + Diagnostics.This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided, + childrenPropName, + typeToString(childrenTargetType) + ); + } + } + else { + if (nonArrayLikeTargetParts !== neverType) { + const child = validChildren[0]; + const elem = getElaborationElementForJsxChild(child, childrenNameType, getInvalidTextualChildDiagnostic); + if (elem) { + result = elaborateElementwise( + (function*() { yield elem; })(), + source, + target, + relation + ) || result; + } + } + else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) { + // arity mismatch + result = true; + error( + containingElement.openingElement.tagName, + Diagnostics.This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_provided, + childrenPropName, + typeToString(childrenTargetType) + ); + } + } + } + return result; + + function getInvalidTextualChildDiagnostic() { + if (!invalidTextDiagnostic) { + const tagNameText = getTextOfNode(node.parent.tagName); + const childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); + const childrenPropName = childPropName === undefined ? "children" : unescapeLeadingUnderscores(childPropName); + const childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); + const diagnostic = Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; + invalidTextDiagnostic = { ...diagnostic, key: "!!ALREADY FORMATTED!!", message: formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }; + } + return invalidTextDiagnostic; + } } function *generateLimitedTupleElements(node: ArrayLiteralExpression, target: Type): ElaborationIterator { @@ -13477,6 +13582,10 @@ namespace ts { return isTupleType(type) || !!getPropertyOfType(type, "0" as __String); } + function isArrayOrTupleLikeType(type: Type): boolean { + return isArrayLikeType(type) || isTupleLikeType(type); + } + function getTupleElementType(type: Type, index: number) { const propType = getTypeOfPropertyOfType(type, "" + index as __String); if (propType) { @@ -17492,11 +17601,23 @@ namespace ts { return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } - function getContextualTypeForChildJsxExpression(node: JsxElement) { + function getContextualTypeForChildJsxExpression(node: JsxElement, child: JsxChild) { const attributesType = getApparentTypeOfContextualType(node.openingElement.tagName); // JSX expression is in children of JSX Element, we will look for an "children" atttribute (we get the name from JSX.ElementAttributesProperty) const jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); - return attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName) : undefined; + if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) { + return undefined; + } + const childIndex = node.children.indexOf(child); + const childFieldType = getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName); + return childFieldType && mapType(childFieldType, t => { + if (isArrayLikeType(t)) { + return getIndexedAccessType(t, getLiteralType(childIndex)); + } + else { + return t; + } + }, /*noReductions*/ true); } function getContextualTypeForJsxExpression(node: JsxExpression): Type | undefined { @@ -17504,7 +17625,7 @@ namespace ts { return isJsxAttributeLike(exprParent) ? getContextualType(node) : isJsxElement(exprParent) - ? getContextualTypeForChildJsxExpression(exprParent) + ? getContextualTypeForChildJsxExpression(exprParent, node) : undefined; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4e99c001d80..a4bd48e8562 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2541,6 +2541,18 @@ "category": "Error", "code": 2744 }, + "This JSX tag's '{0}' prop expects type '{1}' which requires multiple children, but only a single child was provided.": { + "category": "Error", + "code": 2745 + }, + "This JSX tag's '{0}' prop expects a single child of type '{1}', but multiple children were provided.": { + "category": "Error", + "code": 2746 + }, + "'{0}' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of '{1}' is '{2}'.": { + "category": "Error", + "code": 2747 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9c6b27de13c..33a902b8035 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -888,7 +888,7 @@ namespace ts { } const isMissing = nodeIsMissing(errorNode); - const pos = isMissing + const pos = isMissing || isJsxText(node) ? errorNode.pos : skipTrivia(sourceFile.text, errorNode.pos); @@ -7024,6 +7024,7 @@ namespace ts { }; } + export function formatMessage(_dummy: any, message: DiagnosticMessage, ...args: (string | number | undefined)[]): string; export function formatMessage(_dummy: any, message: DiagnosticMessage): string { let text = getLocaleSpecificMessage(message); diff --git a/tests/baselines/reference/checkJsxChildrenProperty14.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty14.errors.txt index b401345a5e1..0f44d023a76 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty14.errors.txt +++ b/tests/baselines/reference/checkJsxChildrenProperty14.errors.txt @@ -1,6 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(42,11): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'SingleChildProp'. - Types of property 'children' are incompatible. - Type 'Element[]' is missing the following properties from type 'Element': type, props +tests/cases/conformance/jsx/file.tsx(42,11): error TS2746: This JSX tag's 'children' prop expects a single child of type 'Element', but multiple children were provided. ==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== @@ -47,6 +45,4 @@ tests/cases/conformance/jsx/file.tsx(42,11): error TS2322: Type '{ children: Ele // Error let k5 = <>