From 6afb15c19e51d2bf9cf9c6b644234af532d2af42 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Wed, 17 Jun 2015 21:22:16 -0700 Subject: [PATCH 01/41] CoreServicesShimHost and CoreServicesShimHostAdapter changes to support TSConfig exclude from the language service --- src/services/shims.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index 2e8b3eb774d..611d1dc8d29 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -61,8 +61,12 @@ namespace ts { /** Public interface of the the of a config service shim instance.*/ export interface CoreServicesShimHost extends Logger { - /** Returns a JSON-encoded value of the type: string[] */ - readDirectory(rootDir: string, extension: string): string; + /** Returns a JSON-encoded value of the type: string[] + * + * @param exclude A JSON encoded string[] containing the paths to exclude + * when enumerating the directory. + */ + readDirectory(rootDir: string, extension: string, exclude?: string): string; } /// @@ -351,8 +355,18 @@ namespace ts { constructor(private shimHost: CoreServicesShimHost) { } - public readDirectory(rootDir: string, extension: string): string[] { - var encoded = this.shimHost.readDirectory(rootDir, extension); + public readDirectory(rootDir: string, extension: string, exclude: string[]): string[] { + // Wrap the API changes for 1.5 release. This try/catch + // should be removed once TypeScript 1.5 has shipped. + // Also consider removing the optional designation for + // the exclude param at this time. + var encoded: string; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } return JSON.parse(encoded); } } From f848087db0082493458c9a1406d718cf802de7c5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 25 Jun 2015 11:59:45 -0400 Subject: [PATCH 02/41] Added failing tests. --- ...lRefsObjectBindingElementPropertyName01.ts | 19 +++++++++++++++++++ ...itionObjectBindingElementPropertyName01.ts | 14 ++++++++++++++ ...foForObjectBindingElementPropertyName01.ts | 12 ++++++++++++ ...enameObjectBindingElementPropertyName01.ts | 15 +++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts create mode 100644 tests/cases/fourslash/goToDefinitionObjectBindingElementPropertyName01.ts create mode 100644 tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName01.ts create mode 100644 tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts new file mode 100644 index 00000000000..0d03561515d --- /dev/null +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts @@ -0,0 +1,19 @@ +/// + +////interface I { +//// [|property1|]: number; +//// property2: string; +////} +//// +////var foo: I; +////var { [|property1|]: prop1 } = foo; + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedRange of ranges) { + verify.referencesAtPositionContains(expectedRange); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionObjectBindingElementPropertyName01.ts b/tests/cases/fourslash/goToDefinitionObjectBindingElementPropertyName01.ts new file mode 100644 index 00000000000..9348ba05678 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionObjectBindingElementPropertyName01.ts @@ -0,0 +1,14 @@ +/// + +////interface I { +//// /*def*/property1: number; +//// property2: string; +////} +//// +////var foo: I; +////var { /*use*/property1: prop1 } = foo; + +goTo.marker("use"); +verify.definitionLocationExists(); +goTo.definition(); +verify.caretAtMarker("def"); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName01.ts b/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName01.ts new file mode 100644 index 00000000000..72e742ba7af --- /dev/null +++ b/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName01.ts @@ -0,0 +1,12 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////var foo: I; +////var { /*use*/property1: prop1 } = foo; + +goTo.marker(); +verify.quickInfoIs("(property) I.property1: number"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts b/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts new file mode 100644 index 00000000000..34dcc1353d0 --- /dev/null +++ b/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts @@ -0,0 +1,15 @@ +/// + +////interface I { +//// /*1*/[|property1|]: number; +//// property2: string; +////} +//// +////var foo: I; +////var { /*2*/[|property1|]: prop1 } = foo; + +for (let m of test.markers()) { + goTo.position(m.position); + verify.renameInfoSucceeded("property1", "I.property1", "property"); + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file From cb48c041874bebbfbf78a46ed5d2aa5e0979cdf9 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 25 Jun 2015 12:18:06 -0400 Subject: [PATCH 03/41] Added failing tests for when RHS is a destructuring. --- ...lRefsObjectBindingElementPropertyName02.ts | 19 +++++++++++++++++++ ...foForObjectBindingElementPropertyName02.ts | 12 ++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts create mode 100644 tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName02.ts diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts new file mode 100644 index 00000000000..86514051557 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts @@ -0,0 +1,19 @@ +/// + +////interface I { +//// [|property1|]: number; +//// property2: string; +////} +//// +////var foo: I; +////var { [|property1|]: {} } = foo; + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedRange of ranges) { + verify.referencesAtPositionContains(expectedRange); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName02.ts b/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName02.ts new file mode 100644 index 00000000000..5a166037f1c --- /dev/null +++ b/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName02.ts @@ -0,0 +1,12 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////var foo: I; +////var { /**/property1: {} } = foo; + +goTo.marker(); +verify.quickInfoIs("(property) I.property1: number"); \ No newline at end of file From 70758e2920f6142d8dbcc02250129fa0f19a1d80 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 25 Jun 2015 14:24:13 -0400 Subject: [PATCH 04/41] Add two new tests to test for regression. --- .../quickInfoForObjectBindingElementName01.ts | 12 ++++++++++++ .../quickInfoForObjectBindingElementName02.ts | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/cases/fourslash/quickInfoForObjectBindingElementName01.ts create mode 100644 tests/cases/fourslash/quickInfoForObjectBindingElementName02.ts diff --git a/tests/cases/fourslash/quickInfoForObjectBindingElementName01.ts b/tests/cases/fourslash/quickInfoForObjectBindingElementName01.ts new file mode 100644 index 00000000000..5cba9554b80 --- /dev/null +++ b/tests/cases/fourslash/quickInfoForObjectBindingElementName01.ts @@ -0,0 +1,12 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////var foo: I; +////var { /**/property1 } = foo; + +goTo.marker(); +verify.quickInfoIs("var property1: number"); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoForObjectBindingElementName02.ts b/tests/cases/fourslash/quickInfoForObjectBindingElementName02.ts new file mode 100644 index 00000000000..e861d3db8fb --- /dev/null +++ b/tests/cases/fourslash/quickInfoForObjectBindingElementName02.ts @@ -0,0 +1,12 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////var foo: I; +////var { property1: /**/prop1 } = foo; + +goTo.marker(); +verify.quickInfoIs("var prop1: number"); \ No newline at end of file From 341ba747d0d62bb9ca21830e1491d4e2790822c3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 25 Jun 2015 14:25:51 -0400 Subject: [PATCH 05/41] Fix marker name. --- .../fourslash/quickInfoForObjectBindingElementPropertyName01.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName01.ts b/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName01.ts index 72e742ba7af..52a9af258b3 100644 --- a/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName01.ts +++ b/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName01.ts @@ -6,7 +6,7 @@ ////} //// ////var foo: I; -////var { /*use*/property1: prop1 } = foo; +////var { /**/property1: prop1 } = foo; goTo.marker(); verify.quickInfoIs("(property) I.property1: number"); \ No newline at end of file From 8ec4af546aad35e023a83e978ec5c833e74f2aa1 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 25 Jun 2015 15:50:25 -0400 Subject: [PATCH 06/41] Just use ranges, don't bother iwth renameInfoSucceeded. --- .../renameObjectBindingElementPropertyName01.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts b/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts index 34dcc1353d0..535dbd3d5a3 100644 --- a/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts +++ b/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts @@ -1,15 +1,14 @@ /// ////interface I { -//// /*1*/[|property1|]: number; +//// [|property1|]: number; //// property2: string; ////} //// ////var foo: I; -////var { /*2*/[|property1|]: prop1 } = foo; +////var { [|property1|]: prop1 } = foo; -for (let m of test.markers()) { - goTo.position(m.position); - verify.renameInfoSucceeded("property1", "I.property1", "property"); +for (let range of test.ranges()) { + goTo.position(range.start); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); } \ No newline at end of file From d7a4ac25f495d5ba78ff27b90fd4f23caf09abac Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 25 Jun 2015 15:52:10 -0400 Subject: [PATCH 07/41] Allow semantic operations to be performed on property names. Provide the property symbol of the type being destructured when referring to the property name. --- src/compiler/checker.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index efee668a24b..763e4173287 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12352,10 +12352,21 @@ namespace ts { return getSymbolOfNode(node.parent); } - if (node.kind === SyntaxKind.Identifier && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === SyntaxKind.ExportAssignment - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === SyntaxKind.Identifier) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === SyntaxKind.ExportAssignment + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === SyntaxKind.BindingElement && + node.parent.parent.kind === SyntaxKind.ObjectBindingPattern && + node === (node.parent).propertyName) { + let typeOfPattern = getTypeAtLocation(node.parent.parent); + let propertyDeclaration = getPropertyOfType(typeOfPattern, (node).text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { From a769e6747a0ead53cc8ca77c446de6cea5bc7c92 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 25 Jun 2015 15:57:30 -0400 Subject: [PATCH 08/41] Added one more test. --- ...lRefsObjectBindingElementPropertyName03.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts new file mode 100644 index 00000000000..304fa9e42e9 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts @@ -0,0 +1,19 @@ +/// + +////interface I { +//// [|property1|]: number; +//// property2: string; +////} +//// +////var foo: I; +////var [{ [|property1|]: prop1 }, { property1, property2 } ] = [foo, foo]; + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedRange of ranges) { + verify.referencesAtPositionContains(expectedRange); + } +} \ No newline at end of file From 5ee5ae11f99a8830af6fb4a94aca7f8ef2f68b94 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 25 Jun 2015 16:09:59 -0400 Subject: [PATCH 09/41] Check for definedness on the pattern's type. --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 763e4173287..64155fe7737 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12362,7 +12362,8 @@ namespace ts { node.parent.parent.kind === SyntaxKind.ObjectBindingPattern && node === (node.parent).propertyName) { let typeOfPattern = getTypeAtLocation(node.parent.parent); - let propertyDeclaration = getPropertyOfType(typeOfPattern, (node).text); + let propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, (node).text); + if (propertyDeclaration) { return propertyDeclaration; } From 475819e27cb84e007fae02e82a4dbaa7d6fa6e05 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 25 Jun 2015 16:18:51 -0400 Subject: [PATCH 10/41] Accepted new baselines. --- .../reference/declarationEmitDestructuring1.symbols | 1 + .../declarationEmitDestructuringArrayPattern2.symbols | 1 + ...larationEmitDestructuringObjectLiteralPattern.symbols | 9 +++++++++ ...arationEmitDestructuringObjectLiteralPattern1.symbols | 4 ++++ ...arationEmitDestructuringObjectLiteralPattern2.symbols | 5 +++++ ...ucturingObjectBindingPatternAndAssignment1ES5.symbols | 2 ++ ...ucturingObjectBindingPatternAndAssignment1ES6.symbols | 2 ++ .../destructuringVariableDeclaration1ES5.symbols | 6 ++++++ .../destructuringVariableDeclaration1ES6.symbols | 6 ++++++ tests/baselines/reference/downlevelLetConst12.symbols | 2 ++ tests/baselines/reference/downlevelLetConst13.symbols | 4 ++++ tests/baselines/reference/downlevelLetConst14.symbols | 4 ++++ tests/baselines/reference/downlevelLetConst15.symbols | 6 ++++++ .../emitArrowFunctionWhenUsingArguments18_ES6.symbols | 1 + tests/baselines/reference/for-of41.symbols | 2 ++ tests/baselines/reference/for-of42.symbols | 2 ++ .../reference/initializePropertiesWithRenamedLet.symbols | 1 + tests/baselines/reference/letInNonStrictMode.symbols | 1 + .../objectBindingPatternKeywordIdentifiers06.symbols | 1 + tests/baselines/reference/systemModule13.symbols | 3 +++ tests/baselines/reference/systemModule8.symbols | 3 +++ 21 files changed, 66 insertions(+) diff --git a/tests/baselines/reference/declarationEmitDestructuring1.symbols b/tests/baselines/reference/declarationEmitDestructuring1.symbols index 10920128eee..32755fdef35 100644 --- a/tests/baselines/reference/declarationEmitDestructuring1.symbols +++ b/tests/baselines/reference/declarationEmitDestructuring1.symbols @@ -23,6 +23,7 @@ function bar({a1, b1, c1}: { a1: number, b1: boolean, c1: string }): void { } function baz({a2, b2: {b1, c1}}: { a2: number, b2: { b1: boolean, c1: string } }): void { } >baz : Symbol(baz, Decl(declarationEmitDestructuring1.ts, 2, 77)) >a2 : Symbol(a2, Decl(declarationEmitDestructuring1.ts, 3, 14)) +>b2 : Symbol(b2, Decl(declarationEmitDestructuring1.ts, 3, 46)) >b1 : Symbol(b1, Decl(declarationEmitDestructuring1.ts, 3, 23)) >c1 : Symbol(c1, Decl(declarationEmitDestructuring1.ts, 3, 26)) >a2 : Symbol(a2, Decl(declarationEmitDestructuring1.ts, 3, 34)) diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.symbols b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.symbols index 9e0e48f89e8..0a3c6f4044d 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.symbols +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.symbols @@ -17,6 +17,7 @@ var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello" >a2 : Symbol(a2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 5)) >b2 : Symbol(b2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 10)) >x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 15)) +>y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 91)) >c2 : Symbol(c2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 20)) >x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 41)) >y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 50)) diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.symbols b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.symbols index 3cb4ef28c2b..0a57a93f3d0 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.symbols +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.symbols @@ -21,24 +21,33 @@ var { x6, y6 } = { x6: 5, y6: "hello" }; >y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 25)) var { x7: a1 } = { x7: 5, y7: "hello" }; +>x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 18)) >a1 : Symbol(a1, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 5)) >x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 18)) >y7 : Symbol(y7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 25)) var { y8: b1 } = { x8: 5, y8: "hello" }; +>y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 25)) >b1 : Symbol(b1, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 5)) >x8 : Symbol(x8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 18)) >y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 25)) var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; +>x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 26)) >a2 : Symbol(a2, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 5)) +>y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 33)) >b2 : Symbol(b2, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 13)) >x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 26)) >y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 33)) var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; +>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 46)) >x11 : Symbol(x11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 5)) +>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 52)) +>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 57)) >y11 : Symbol(y11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 18)) +>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 69)) +>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 74)) >z11 : Symbol(z11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 31)) >a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 46)) >b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 52)) diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.symbols b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.symbols index a4c43a07bc8..cac2431411e 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.symbols +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.symbols @@ -21,17 +21,21 @@ var { x6, y6 } = { x6: 5, y6: "hello" }; >y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 25)) var { x7: a1 } = { x7: 5, y7: "hello" }; +>x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 18)) >a1 : Symbol(a1, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 5)) >x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 18)) >y7 : Symbol(y7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 25)) var { y8: b1 } = { x8: 5, y8: "hello" }; +>y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 25)) >b1 : Symbol(b1, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 5)) >x8 : Symbol(x8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 18)) >y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 25)) var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; +>x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 26)) >a2 : Symbol(a2, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 5)) +>y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 33)) >b2 : Symbol(b2, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 13)) >x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 26)) >y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 33)) diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.symbols b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.symbols index 76440b60038..77e26e2c9b7 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.symbols +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.symbols @@ -1,8 +1,13 @@ === tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern2.ts === var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; +>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 46)) >x11 : Symbol(x11, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 5)) +>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 52)) +>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 57)) >y11 : Symbol(y11, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 18)) +>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 69)) +>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 74)) >z11 : Symbol(z11, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 31)) >a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 46)) >b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 52)) diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.symbols b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.symbols index 017a7f71e61..718af66047d 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.symbols +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.symbols @@ -19,6 +19,7 @@ var { b1, } = { b1:1, }; >b1 : Symbol(b1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 11, 15)) var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; +>b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 12, 44)) >b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 12, 11)) >b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 12, 21)) >b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 12, 44)) @@ -32,6 +33,7 @@ var {b4 = 1}: any = { b4: 100000 }; >b4 : Symbol(b4, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 14, 21)) var {b5: { b52 } } = { b5: { b52 } }; +>b5 : Symbol(b5, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 23)) >b52 : Symbol(b52, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 10)) >b5 : Symbol(b5, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 23)) >b52 : Symbol(b52, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 29)) diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.symbols b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.symbols index 11289210ee4..57d739cbbfc 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.symbols +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.symbols @@ -19,6 +19,7 @@ var { b1, } = { b1:1, }; >b1 : Symbol(b1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 11, 15)) var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; +>b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 12, 44)) >b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 12, 11)) >b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 12, 21)) >b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 12, 44)) @@ -32,6 +33,7 @@ var {b4 = 1}: any = { b4: 100000 }; >b4 : Symbol(b4, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 14, 21)) var {b5: { b52 } } = { b5: { b52 } }; +>b5 : Symbol(b5, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 23)) >b52 : Symbol(b52, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 10)) >b5 : Symbol(b5, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 23)) >b52 : Symbol(b52, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 29)) diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.symbols b/tests/baselines/reference/destructuringVariableDeclaration1ES5.symbols index 2a2f2a358ca..924527bf1b4 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5.symbols +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.symbols @@ -17,6 +17,7 @@ var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5.ts, 7, 44)) >b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5.ts, 7, 11)) >b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5.ts, 7, 21)) >b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5.ts, 7, 44)) @@ -74,6 +75,7 @@ var [d3, d4] = [1, "string", ...temp1]; // Combining both forms of destructuring, var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +>e : Symbol(e, Decl(destructuringVariableDeclaration1ES5.ts, 31, 49)) >e1 : Symbol(e1, Decl(destructuringVariableDeclaration1ES5.ts, 31, 9)) >e2 : Symbol(e2, Decl(destructuringVariableDeclaration1ES5.ts, 31, 12)) >e3 : Symbol(e3, Decl(destructuringVariableDeclaration1ES5.ts, 31, 16)) @@ -84,8 +86,10 @@ var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; >b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES5.ts, 31, 68)) var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; +>f : Symbol(f, Decl(destructuringVariableDeclaration1ES5.ts, 32, 41)) >f1 : Symbol(f1, Decl(destructuringVariableDeclaration1ES5.ts, 32, 9)) >f2 : Symbol(f2, Decl(destructuringVariableDeclaration1ES5.ts, 32, 12)) +>f3 : Symbol(f3, Decl(destructuringVariableDeclaration1ES5.ts, 32, 53)) >f4 : Symbol(f4, Decl(destructuringVariableDeclaration1ES5.ts, 32, 18)) >f5 : Symbol(f5, Decl(destructuringVariableDeclaration1ES5.ts, 32, 26)) >f : Symbol(f, Decl(destructuringVariableDeclaration1ES5.ts, 32, 41)) @@ -96,6 +100,7 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +>g : Symbol(g, Decl(destructuringVariableDeclaration1ES5.ts, 37, 36)) >g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5.ts, 37, 9)) >undefined : Symbol(undefined) >g : Symbol(g, Decl(destructuringVariableDeclaration1ES5.ts, 37, 36)) @@ -104,6 +109,7 @@ var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; >g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5.ts, 37, 64)) var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; +>h : Symbol(h, Decl(destructuringVariableDeclaration1ES5.ts, 38, 36)) >h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES5.ts, 38, 9)) >undefined : Symbol(undefined) >h : Symbol(h, Decl(destructuringVariableDeclaration1ES5.ts, 38, 36)) diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.symbols b/tests/baselines/reference/destructuringVariableDeclaration1ES6.symbols index 0350ff35251..ee4f391eb7a 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES6.symbols +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.symbols @@ -17,6 +17,7 @@ var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES6.ts, 7, 44)) >b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES6.ts, 7, 11)) >b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES6.ts, 7, 21)) >b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES6.ts, 7, 44)) @@ -74,6 +75,7 @@ var [d3, d4] = [1, "string", ...temp1]; // Combining both forms of destructuring, var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +>e : Symbol(e, Decl(destructuringVariableDeclaration1ES6.ts, 31, 49)) >e1 : Symbol(e1, Decl(destructuringVariableDeclaration1ES6.ts, 31, 9)) >e2 : Symbol(e2, Decl(destructuringVariableDeclaration1ES6.ts, 31, 12)) >e3 : Symbol(e3, Decl(destructuringVariableDeclaration1ES6.ts, 31, 16)) @@ -84,8 +86,10 @@ var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; >b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES6.ts, 31, 68)) var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; +>f : Symbol(f, Decl(destructuringVariableDeclaration1ES6.ts, 32, 41)) >f1 : Symbol(f1, Decl(destructuringVariableDeclaration1ES6.ts, 32, 9)) >f2 : Symbol(f2, Decl(destructuringVariableDeclaration1ES6.ts, 32, 12)) +>f3 : Symbol(f3, Decl(destructuringVariableDeclaration1ES6.ts, 32, 53)) >f4 : Symbol(f4, Decl(destructuringVariableDeclaration1ES6.ts, 32, 18)) >f5 : Symbol(f5, Decl(destructuringVariableDeclaration1ES6.ts, 32, 26)) >f : Symbol(f, Decl(destructuringVariableDeclaration1ES6.ts, 32, 41)) @@ -96,6 +100,7 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +>g : Symbol(g, Decl(destructuringVariableDeclaration1ES6.ts, 37, 36)) >g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES6.ts, 37, 9)) >undefined : Symbol(undefined) >g : Symbol(g, Decl(destructuringVariableDeclaration1ES6.ts, 37, 36)) @@ -104,6 +109,7 @@ var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; >g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES6.ts, 37, 64)) var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; +>h : Symbol(h, Decl(destructuringVariableDeclaration1ES6.ts, 38, 36)) >h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES6.ts, 38, 9)) >undefined : Symbol(undefined) >h : Symbol(h, Decl(destructuringVariableDeclaration1ES6.ts, 38, 36)) diff --git a/tests/baselines/reference/downlevelLetConst12.symbols b/tests/baselines/reference/downlevelLetConst12.symbols index d1c7fe3ea5b..97d6d5eebf8 100644 --- a/tests/baselines/reference/downlevelLetConst12.symbols +++ b/tests/baselines/reference/downlevelLetConst12.symbols @@ -12,6 +12,7 @@ let [baz] = []; >baz : Symbol(baz, Decl(downlevelLetConst12.ts, 6, 5)) let {a: baz2} = { a: 1 }; +>a : Symbol(a, Decl(downlevelLetConst12.ts, 7, 17)) >baz2 : Symbol(baz2, Decl(downlevelLetConst12.ts, 7, 5)) >a : Symbol(a, Decl(downlevelLetConst12.ts, 7, 17)) @@ -19,6 +20,7 @@ const [baz3] = [] >baz3 : Symbol(baz3, Decl(downlevelLetConst12.ts, 9, 7)) const {a: baz4} = { a: 1 }; +>a : Symbol(a, Decl(downlevelLetConst12.ts, 10, 19)) >baz4 : Symbol(baz4, Decl(downlevelLetConst12.ts, 10, 7)) >a : Symbol(a, Decl(downlevelLetConst12.ts, 10, 19)) diff --git a/tests/baselines/reference/downlevelLetConst13.symbols b/tests/baselines/reference/downlevelLetConst13.symbols index 1b06184f2b3..f8cd2e548a9 100644 --- a/tests/baselines/reference/downlevelLetConst13.symbols +++ b/tests/baselines/reference/downlevelLetConst13.symbols @@ -16,10 +16,12 @@ export const [bar2] = [2]; >bar2 : Symbol(bar2, Decl(downlevelLetConst13.ts, 7, 14)) export let {a: bar3} = { a: 1 }; +>a : Symbol(a, Decl(downlevelLetConst13.ts, 8, 24)) >bar3 : Symbol(bar3, Decl(downlevelLetConst13.ts, 8, 12)) >a : Symbol(a, Decl(downlevelLetConst13.ts, 8, 24)) export const {a: bar4} = { a: 1 }; +>a : Symbol(a, Decl(downlevelLetConst13.ts, 9, 26)) >bar4 : Symbol(bar4, Decl(downlevelLetConst13.ts, 9, 14)) >a : Symbol(a, Decl(downlevelLetConst13.ts, 9, 26)) @@ -39,10 +41,12 @@ export module M { >bar6 : Symbol(bar6, Decl(downlevelLetConst13.ts, 15, 18)) export let {a: bar7} = { a: 1 }; +>a : Symbol(a, Decl(downlevelLetConst13.ts, 16, 28)) >bar7 : Symbol(bar7, Decl(downlevelLetConst13.ts, 16, 16)) >a : Symbol(a, Decl(downlevelLetConst13.ts, 16, 28)) export const {a: bar8} = { a: 1 }; +>a : Symbol(a, Decl(downlevelLetConst13.ts, 17, 30)) >bar8 : Symbol(bar8, Decl(downlevelLetConst13.ts, 17, 18)) >a : Symbol(a, Decl(downlevelLetConst13.ts, 17, 30)) } diff --git a/tests/baselines/reference/downlevelLetConst14.symbols b/tests/baselines/reference/downlevelLetConst14.symbols index bf3450af71c..135f3c1417d 100644 --- a/tests/baselines/reference/downlevelLetConst14.symbols +++ b/tests/baselines/reference/downlevelLetConst14.symbols @@ -35,6 +35,7 @@ var z0, z1, z2, z3; >z1 : Symbol(z1, Decl(downlevelLetConst14.ts, 11, 9)) let {a: z2} = { a: 1 }; +>a : Symbol(a, Decl(downlevelLetConst14.ts, 13, 19)) >z2 : Symbol(z2, Decl(downlevelLetConst14.ts, 13, 9)) >a : Symbol(a, Decl(downlevelLetConst14.ts, 13, 19)) @@ -43,6 +44,7 @@ var z0, z1, z2, z3; >z2 : Symbol(z2, Decl(downlevelLetConst14.ts, 13, 9)) let {a: z3} = { a: 1 }; +>a : Symbol(a, Decl(downlevelLetConst14.ts, 15, 19)) >z3 : Symbol(z3, Decl(downlevelLetConst14.ts, 15, 9)) >a : Symbol(a, Decl(downlevelLetConst14.ts, 15, 19)) @@ -86,6 +88,7 @@ var y = true; >y : Symbol(y, Decl(downlevelLetConst14.ts, 29, 11)) let {a: z6} = {a: 1} +>a : Symbol(a, Decl(downlevelLetConst14.ts, 30, 23)) >z6 : Symbol(z6, Decl(downlevelLetConst14.ts, 30, 13)) >a : Symbol(a, Decl(downlevelLetConst14.ts, 30, 23)) @@ -129,6 +132,7 @@ var z5 = 1; >_z : Symbol(_z, Decl(downlevelLetConst14.ts, 46, 11)) let {a: _z5} = { a: 1 }; +>a : Symbol(a, Decl(downlevelLetConst14.ts, 47, 24)) >_z5 : Symbol(_z5, Decl(downlevelLetConst14.ts, 47, 13)) >a : Symbol(a, Decl(downlevelLetConst14.ts, 47, 24)) diff --git a/tests/baselines/reference/downlevelLetConst15.symbols b/tests/baselines/reference/downlevelLetConst15.symbols index 159e5a6d676..00c7e122eb2 100644 --- a/tests/baselines/reference/downlevelLetConst15.symbols +++ b/tests/baselines/reference/downlevelLetConst15.symbols @@ -28,6 +28,7 @@ var z0, z1, z2, z3; >z0 : Symbol(z0, Decl(downlevelLetConst15.ts, 9, 11)) const [{a: z1}] = [{a: 1}] +>a : Symbol(a, Decl(downlevelLetConst15.ts, 11, 24)) >z1 : Symbol(z1, Decl(downlevelLetConst15.ts, 11, 12)) >a : Symbol(a, Decl(downlevelLetConst15.ts, 11, 24)) @@ -36,6 +37,7 @@ var z0, z1, z2, z3; >z1 : Symbol(z1, Decl(downlevelLetConst15.ts, 11, 12)) const {a: z2} = { a: 1 }; +>a : Symbol(a, Decl(downlevelLetConst15.ts, 13, 21)) >z2 : Symbol(z2, Decl(downlevelLetConst15.ts, 13, 11)) >a : Symbol(a, Decl(downlevelLetConst15.ts, 13, 21)) @@ -44,6 +46,8 @@ var z0, z1, z2, z3; >z2 : Symbol(z2, Decl(downlevelLetConst15.ts, 13, 11)) const {a: {b: z3}} = { a: {b: 1} }; +>a : Symbol(a, Decl(downlevelLetConst15.ts, 15, 26)) +>b : Symbol(b, Decl(downlevelLetConst15.ts, 15, 31)) >z3 : Symbol(z3, Decl(downlevelLetConst15.ts, 15, 15)) >a : Symbol(a, Decl(downlevelLetConst15.ts, 15, 26)) >b : Symbol(b, Decl(downlevelLetConst15.ts, 15, 31)) @@ -88,6 +92,7 @@ var y = true; >y : Symbol(y, Decl(downlevelLetConst15.ts, 29, 13)) const {a: z6} = { a: 1 } +>a : Symbol(a, Decl(downlevelLetConst15.ts, 30, 25)) >z6 : Symbol(z6, Decl(downlevelLetConst15.ts, 30, 15)) >a : Symbol(a, Decl(downlevelLetConst15.ts, 30, 25)) @@ -131,6 +136,7 @@ var z5 = 1; >_z : Symbol(_z, Decl(downlevelLetConst15.ts, 46, 13)) const {a: _z5} = { a: 1 }; +>a : Symbol(a, Decl(downlevelLetConst15.ts, 47, 26)) >_z5 : Symbol(_z5, Decl(downlevelLetConst15.ts, 47, 15)) >a : Symbol(a, Decl(downlevelLetConst15.ts, 47, 26)) diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols index 4d0887c1ff8..eb24f638884 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols @@ -4,6 +4,7 @@ function f() { >f : Symbol(f, Decl(emitArrowFunctionWhenUsingArguments18_ES6.ts, 0, 0)) var { arguments: args } = { arguments }; +>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments18_ES6.ts, 2, 31)) >args : Symbol(args, Decl(emitArrowFunctionWhenUsingArguments18_ES6.ts, 2, 9)) >arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments18_ES6.ts, 2, 31)) diff --git a/tests/baselines/reference/for-of41.symbols b/tests/baselines/reference/for-of41.symbols index cf8db913919..046361653bb 100644 --- a/tests/baselines/reference/for-of41.symbols +++ b/tests/baselines/reference/for-of41.symbols @@ -6,7 +6,9 @@ var array = [{x: [0], y: {p: ""}}] >p : Symbol(p, Decl(for-of41.ts, 0, 26)) for (var {x: [a], y: {p}} of array) { +>x : Symbol(x, Decl(for-of41.ts, 0, 14)) >a : Symbol(a, Decl(for-of41.ts, 1, 14)) +>y : Symbol(y, Decl(for-of41.ts, 0, 21)) >p : Symbol(p, Decl(for-of41.ts, 1, 22)) >array : Symbol(array, Decl(for-of41.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of42.symbols b/tests/baselines/reference/for-of42.symbols index b310fb1044f..5310f4970b9 100644 --- a/tests/baselines/reference/for-of42.symbols +++ b/tests/baselines/reference/for-of42.symbols @@ -5,7 +5,9 @@ var array = [{ x: "", y: 0 }] >y : Symbol(y, Decl(for-of42.ts, 0, 21)) for (var {x: a, y: b} of array) { +>x : Symbol(x, Decl(for-of42.ts, 0, 14)) >a : Symbol(a, Decl(for-of42.ts, 1, 10)) +>y : Symbol(y, Decl(for-of42.ts, 0, 21)) >b : Symbol(b, Decl(for-of42.ts, 1, 15)) >array : Symbol(array, Decl(for-of42.ts, 0, 3)) diff --git a/tests/baselines/reference/initializePropertiesWithRenamedLet.symbols b/tests/baselines/reference/initializePropertiesWithRenamedLet.symbols index 203508ddf98..f16d8cfc9e0 100644 --- a/tests/baselines/reference/initializePropertiesWithRenamedLet.symbols +++ b/tests/baselines/reference/initializePropertiesWithRenamedLet.symbols @@ -24,6 +24,7 @@ var x, y, z; if (true) { let { x: x } = { x: 0 }; +>x : Symbol(x, Decl(initializePropertiesWithRenamedLet.ts, 10, 20)) >x : Symbol(x, Decl(initializePropertiesWithRenamedLet.ts, 10, 9)) >x : Symbol(x, Decl(initializePropertiesWithRenamedLet.ts, 10, 20)) diff --git a/tests/baselines/reference/letInNonStrictMode.symbols b/tests/baselines/reference/letInNonStrictMode.symbols index 2b854a8c03f..47ba4465d1b 100644 --- a/tests/baselines/reference/letInNonStrictMode.symbols +++ b/tests/baselines/reference/letInNonStrictMode.symbols @@ -3,6 +3,7 @@ let [x] = [1]; >x : Symbol(x, Decl(letInNonStrictMode.ts, 0, 5)) let {a: y} = {a: 1}; +>a : Symbol(a, Decl(letInNonStrictMode.ts, 1, 14)) >y : Symbol(y, Decl(letInNonStrictMode.ts, 1, 5)) >a : Symbol(a, Decl(letInNonStrictMode.ts, 1, 14)) diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.symbols b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.symbols index 7cee5f3009b..f0546012498 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.symbols +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.symbols @@ -1,6 +1,7 @@ === tests/cases/conformance/es6/destructuring/objectBindingPatternKeywordIdentifiers06.ts === var { as: as } = { as: 1 } +>as : Symbol(as, Decl(objectBindingPatternKeywordIdentifiers06.ts, 1, 18)) >as : Symbol(as, Decl(objectBindingPatternKeywordIdentifiers06.ts, 1, 5)) >as : Symbol(as, Decl(objectBindingPatternKeywordIdentifiers06.ts, 1, 18)) diff --git a/tests/baselines/reference/systemModule13.symbols b/tests/baselines/reference/systemModule13.symbols index d9e64335c2b..8245029e006 100644 --- a/tests/baselines/reference/systemModule13.symbols +++ b/tests/baselines/reference/systemModule13.symbols @@ -6,7 +6,10 @@ export let [x,y,z] = [1, 2, 3]; >z : Symbol(z, Decl(systemModule13.ts, 1, 16)) export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +>a : Symbol(a, Decl(systemModule13.ts, 2, 36)) >z0 : Symbol(z0, Decl(systemModule13.ts, 2, 14)) +>b : Symbol(b, Decl(systemModule13.ts, 2, 44)) +>c : Symbol(c, Decl(systemModule13.ts, 2, 49)) >z1 : Symbol(z1, Decl(systemModule13.ts, 2, 25)) >a : Symbol(a, Decl(systemModule13.ts, 2, 36)) >b : Symbol(b, Decl(systemModule13.ts, 2, 44)) diff --git a/tests/baselines/reference/systemModule8.symbols b/tests/baselines/reference/systemModule8.symbols index 3365ce7e37d..719d48e4592 100644 --- a/tests/baselines/reference/systemModule8.symbols +++ b/tests/baselines/reference/systemModule8.symbols @@ -78,7 +78,10 @@ export let [y] = [1]; >y : Symbol(y, Decl(systemModule8.ts, 27, 12)) export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +>a : Symbol(a, Decl(systemModule8.ts, 28, 36)) >z0 : Symbol(z0, Decl(systemModule8.ts, 28, 14)) +>b : Symbol(b, Decl(systemModule8.ts, 28, 44)) +>c : Symbol(c, Decl(systemModule8.ts, 28, 49)) >z1 : Symbol(z1, Decl(systemModule8.ts, 28, 25)) >a : Symbol(a, Decl(systemModule8.ts, 28, 36)) >b : Symbol(b, Decl(systemModule8.ts, 28, 44)) From c0faaeecbe045dd070f17d41fe314f6561f67ccc Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 1 Jul 2015 14:26:05 -0700 Subject: [PATCH 11/41] Added more test cases for object binding patterns. --- ...lRefsObjectBindingElementPropertyName04.ts | 21 +++++++++++++++++ ...lRefsObjectBindingElementPropertyName05.ts | 21 +++++++++++++++++ ...lRefsObjectBindingElementPropertyName06.ts | 23 +++++++++++++++++++ ...lRefsObjectBindingElementPropertyName07.ts | 15 ++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts create mode 100644 tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName05.ts create mode 100644 tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts create mode 100644 tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts new file mode 100644 index 00000000000..ad72bd99bb8 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts @@ -0,0 +1,21 @@ +/// + +////interface I { +//// [|property1|]: number; +//// property2: string; +////} +//// +////function f({ [|property1|]: p1 }: I, +//// { [|property1|] }: I, +//// { property1: p2 }) { +////} + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedRange of ranges) { + verify.referencesAtPositionContains(expectedRange); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName05.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName05.ts new file mode 100644 index 00000000000..aa6432fa62e --- /dev/null +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName05.ts @@ -0,0 +1,21 @@ +/// + +////interface I { +//// property1: number; +//// property2: string; +////} +//// +////function f({ [|property1|]: p }, { property1 }) { +//// let x = property1; +////} + +// Notice only one range. +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedRange of ranges) { + verify.referencesAtPositionContains(expectedRange); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts new file mode 100644 index 00000000000..4ce33f2b6ad --- /dev/null +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts @@ -0,0 +1,23 @@ +/// + +////interface I { +//// [|property1|]: number; +//// property2: string; +////} +//// +////for (let { [|property1|]: p } of []) { +////} +////for (let { [|property1|] } of []) { +////} +////for (var { [|property1|]: p } of []) { +////} + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedRange of ranges) { + verify.referencesAtPositionContains(expectedRange); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts new file mode 100644 index 00000000000..6448d2396b3 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts @@ -0,0 +1,15 @@ +/// + +////let p, b; +//// +////p, [{ [|a|]: p, b }] = [{ [|a|]: 10, b: true }]; + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedRange of ranges) { + verify.referencesAtPositionContains(expectedRange); + } +} \ No newline at end of file From 726eea2896e4c8054f0e162c10399e4b930c1845 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 30 Jun 2015 16:11:09 -0700 Subject: [PATCH 12/41] dispose script snapshots from the old source file --- src/services/services.ts | 13 +++++++++++++ src/services/shims.ts | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/src/services/services.ts b/src/services/services.ts index 521c6db155a..41996349fba 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -91,6 +91,9 @@ module ts { * not happen and the entire document will be re - parsed. */ getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; + + /** Releases all resources held by this script snapshot */ + dispose?(): void; } export module ScriptSnapshot { @@ -1873,6 +1876,16 @@ module ts { // after incremental parsing nameTable might not be up-to-date // drop it so it can be lazily recreated later newSourceFile.nameTable = undefined; + + // dispose all resources held by old script snapshot + if (sourceFile.scriptSnapshot) { + if (sourceFile.scriptSnapshot.dispose) { + sourceFile.scriptSnapshot.dispose(); + } + + sourceFile.scriptSnapshot = undefined; + } + return newSourceFile; } } diff --git a/src/services/shims.ts b/src/services/shims.ts index d6f9f7a968a..6743f48df1d 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -34,6 +34,9 @@ module ts { * Or undefined value if there was no change. */ getChangeRange(oldSnapshot: ScriptSnapshotShim): string; + + /** Releases all resources held by this script snapshot */ + dispose?(): void; } export interface Logger { @@ -242,6 +245,12 @@ module ts { return createTextChangeRange( createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); } + + public dispose(): void { + if ("dispose" in this.scriptSnapshotShim) { + this.scriptSnapshotShim.dispose(); + } + } } export class LanguageServiceShimHostAdapter implements LanguageServiceHost { From ee1350b40e6cdd4a49eb298f591ad62afb4f3993 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 1 Jul 2015 23:14:40 -0700 Subject: [PATCH 13/41] dispose snapshot only if new file differs from the old file --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 41996349fba..a446c45aa8f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1878,7 +1878,7 @@ module ts { newSourceFile.nameTable = undefined; // dispose all resources held by old script snapshot - if (sourceFile.scriptSnapshot) { + if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) { if (sourceFile.scriptSnapshot.dispose) { sourceFile.scriptSnapshot.dispose(); } From e190761d96beaa0aa39e84de010695c63b05e64d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 9 Jul 2015 13:13:49 -0700 Subject: [PATCH 14/41] addressed PR feedback: added comments --- src/services/shims.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/services/shims.ts b/src/services/shims.ts index 6743f48df1d..e583a0d3d18 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -247,6 +247,8 @@ module ts { } public dispose(): void { + // if scriptSnapshotShim is a COM object then property check becomes method call with no arguments + // 'in' does not have this effect if ("dispose" in this.scriptSnapshotShim) { this.scriptSnapshotShim.dispose(); } From 1066f0e3cca7b1ddcf219490487edb7b13631ab5 Mon Sep 17 00:00:00 2001 From: "shyyko.serhiy@gmail.com" Date: Tue, 14 Jul 2015 15:28:05 +0300 Subject: [PATCH 15/41] fixed issue #3454 --- src/compiler/emitter.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index fd0d4ad796e..1c032c0aa25 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4219,6 +4219,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + var startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); @@ -4253,7 +4254,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } emitTempDeclarations(/*newLine*/ true); writeLine(); From aec0fb4818b7031fc1474b5497f084287e303133 Mon Sep 17 00:00:00 2001 From: "shyyko.serhiy@gmail.com" Date: Tue, 14 Jul 2015 17:02:18 +0300 Subject: [PATCH 16/41] fixed strictModeInConstructor baseline reference --- tests/baselines/reference/strictModeInConstructor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselines/reference/strictModeInConstructor.js b/tests/baselines/reference/strictModeInConstructor.js index 7fd74aa108f..7d1adc48fa0 100644 --- a/tests/baselines/reference/strictModeInConstructor.js +++ b/tests/baselines/reference/strictModeInConstructor.js @@ -74,8 +74,8 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - this.s = 9; "use strict"; // No error + this.s = 9; _super.call(this); } return B; From 12809125f8eb406e7743b75425595c065e8e05af Mon Sep 17 00:00:00 2001 From: "shyyko.serhiy@gmail.com" Date: Tue, 14 Jul 2015 17:21:47 +0300 Subject: [PATCH 17/41] added comment --- src/compiler/emitter.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 1c032c0aa25..7b083ba7363 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4219,6 +4219,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). var startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } From a24aa6f57d281bafd3535f0f4c3f492364a8b4d6 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 14 Jul 2015 23:40:06 -0700 Subject: [PATCH 18/41] Update LKG --- bin/tsserver.js | 6 ++++++ bin/typescript.d.ts | 2 ++ bin/typescript.js | 14 ++++++++++++++ bin/typescriptServices.d.ts | 2 ++ bin/typescriptServices.js | 14 ++++++++++++++ 5 files changed, 38 insertions(+) diff --git a/bin/tsserver.js b/bin/tsserver.js index 040eac2ef75..d4ff3ea8a2b 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -31502,6 +31502,12 @@ var ts; var newSourceFile = ts.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); setSourceFileFields(newSourceFile, scriptSnapshot, version); newSourceFile.nameTable = undefined; + if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) { + if (sourceFile.scriptSnapshot.dispose) { + sourceFile.scriptSnapshot.dispose(); + } + sourceFile.scriptSnapshot = undefined; + } return newSourceFile; } } diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index 11169b6fa28..f560e5958cf 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -1375,6 +1375,8 @@ declare module "typescript" { * not happen and the entire document will be re - parsed. */ getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; + /** Releases all resources held by this script snapshot */ + dispose?(): void; } module ScriptSnapshot { function fromString(text: string): IScriptSnapshot; diff --git a/bin/typescript.js b/bin/typescript.js index c2f23126ea8..a3b921d2341 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -36867,6 +36867,13 @@ var ts; // after incremental parsing nameTable might not be up-to-date // drop it so it can be lazily recreated later newSourceFile.nameTable = undefined; + // dispose all resources held by old script snapshot + if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) { + if (sourceFile.scriptSnapshot.dispose) { + sourceFile.scriptSnapshot.dispose(); + } + sourceFile.scriptSnapshot = undefined; + } return newSourceFile; } } @@ -41947,6 +41954,13 @@ var ts; var decoded = JSON.parse(encoded); return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; + ScriptSnapshotShimAdapter.prototype.dispose = function () { + // if scriptSnapshotShim is a COM object then property check becomes method call with no arguments + // 'in' does not have this effect + if ("dispose" in this.scriptSnapshotShim) { + this.scriptSnapshotShim.dispose(); + } + }; return ScriptSnapshotShimAdapter; })(); var LanguageServiceShimHostAdapter = (function () { diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts index ae49ab102ad..e29f03ee3d8 100644 --- a/bin/typescriptServices.d.ts +++ b/bin/typescriptServices.d.ts @@ -1375,6 +1375,8 @@ declare module ts { * not happen and the entire document will be re - parsed. */ getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; + /** Releases all resources held by this script snapshot */ + dispose?(): void; } module ScriptSnapshot { function fromString(text: string): IScriptSnapshot; diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index c2f23126ea8..a3b921d2341 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -36867,6 +36867,13 @@ var ts; // after incremental parsing nameTable might not be up-to-date // drop it so it can be lazily recreated later newSourceFile.nameTable = undefined; + // dispose all resources held by old script snapshot + if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) { + if (sourceFile.scriptSnapshot.dispose) { + sourceFile.scriptSnapshot.dispose(); + } + sourceFile.scriptSnapshot = undefined; + } return newSourceFile; } } @@ -41947,6 +41954,13 @@ var ts; var decoded = JSON.parse(encoded); return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; + ScriptSnapshotShimAdapter.prototype.dispose = function () { + // if scriptSnapshotShim is a COM object then property check becomes method call with no arguments + // 'in' does not have this effect + if ("dispose" in this.scriptSnapshotShim) { + this.scriptSnapshotShim.dispose(); + } + }; return ScriptSnapshotShimAdapter; })(); var LanguageServiceShimHostAdapter = (function () { From 52423f0e6e98079e7d5629a30a44e5b63dccfcdb Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Wed, 17 Jun 2015 21:22:16 -0700 Subject: [PATCH 19/41] CoreServicesShimHost and CoreServicesShimHostAdapter changes to support TSConfig exclude from the language service --- src/services/shims.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index 84580470b27..362293c0c79 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -64,8 +64,12 @@ namespace ts { /** Public interface of the the of a config service shim instance.*/ export interface CoreServicesShimHost extends Logger { - /** Returns a JSON-encoded value of the type: string[] */ - readDirectory(rootDir: string, extension: string): string; + /** Returns a JSON-encoded value of the type: string[] + * + * @param exclude A JSON encoded string[] containing the paths to exclude + * when enumerating the directory. + */ + readDirectory(rootDir: string, extension: string, exclude?: string): string; } /// @@ -386,8 +390,18 @@ namespace ts { constructor(private shimHost: CoreServicesShimHost) { } - public readDirectory(rootDir: string, extension: string): string[] { - var encoded = this.shimHost.readDirectory(rootDir, extension); + public readDirectory(rootDir: string, extension: string, exclude: string[]): string[] { + // Wrap the API changes for 1.5 release. This try/catch + // should be removed once TypeScript 1.5 has shipped. + // Also consider removing the optional designation for + // the exclude param at this time. + var encoded: string; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } return JSON.parse(encoded); } } From dea66a66dc93118abdde6eec558d12d33c267829 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Wed, 15 Jul 2015 14:19:54 -0700 Subject: [PATCH 20/41] Fix comment spacing for readDirectory in shims.ts --- src/services/shims.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index 362293c0c79..e2055b3de77 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -64,7 +64,8 @@ namespace ts { /** Public interface of the the of a config service shim instance.*/ export interface CoreServicesShimHost extends Logger { - /** Returns a JSON-encoded value of the type: string[] + /** + * Returns a JSON-encoded value of the type: string[] * * @param exclude A JSON encoded string[] containing the paths to exclude * when enumerating the directory. From 95cd3c3d0ffa19a3bc987367115070f0858f2645 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 15 Jul 2015 14:41:24 -0700 Subject: [PATCH 21/41] Allow super element access --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 8c220604e89..127d1b58ee4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3295,7 +3295,7 @@ namespace ts { function parseSuperExpression(): MemberExpression { let expression = parseTokenNode(); - if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.DotToken) { + if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.DotToken || token === SyntaxKind.OpenBracketToken) { return expression; } From 75f97f302ac96c45d0c0fd2289d96e9fa9d4d1f9 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 15 Jul 2015 14:41:36 -0700 Subject: [PATCH 22/41] Add tests --- .../reference/superSymbolIndexedAccess1.js | 27 +++++++++++++++ .../superSymbolIndexedAccess1.symbols | 29 ++++++++++++++++ .../reference/superSymbolIndexedAccess1.types | 34 +++++++++++++++++++ .../reference/superSymbolIndexedAccess2.js | 25 ++++++++++++++ .../superSymbolIndexedAccess2.symbols | 30 ++++++++++++++++ .../reference/superSymbolIndexedAccess2.types | 33 ++++++++++++++++++ .../superSymbolIndexedAccess3.errors.txt | 19 +++++++++++ .../reference/superSymbolIndexedAccess3.js | 27 +++++++++++++++ .../superSymbolIndexedAccess4.errors.txt | 13 +++++++ .../reference/superSymbolIndexedAccess4.js | 16 +++++++++ .../superSymbolIndexedAccess1.ts | 14 ++++++++ .../superSymbolIndexedAccess2.ts | 13 +++++++ .../superSymbolIndexedAccess3.ts | 14 ++++++++ .../superSymbolIndexedAccess4.ts | 8 +++++ 14 files changed, 302 insertions(+) create mode 100644 tests/baselines/reference/superSymbolIndexedAccess1.js create mode 100644 tests/baselines/reference/superSymbolIndexedAccess1.symbols create mode 100644 tests/baselines/reference/superSymbolIndexedAccess1.types create mode 100644 tests/baselines/reference/superSymbolIndexedAccess2.js create mode 100644 tests/baselines/reference/superSymbolIndexedAccess2.symbols create mode 100644 tests/baselines/reference/superSymbolIndexedAccess2.types create mode 100644 tests/baselines/reference/superSymbolIndexedAccess3.errors.txt create mode 100644 tests/baselines/reference/superSymbolIndexedAccess3.js create mode 100644 tests/baselines/reference/superSymbolIndexedAccess4.errors.txt create mode 100644 tests/baselines/reference/superSymbolIndexedAccess4.js create mode 100644 tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess1.ts create mode 100644 tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess2.ts create mode 100644 tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts create mode 100644 tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess4.ts diff --git a/tests/baselines/reference/superSymbolIndexedAccess1.js b/tests/baselines/reference/superSymbolIndexedAccess1.js new file mode 100644 index 00000000000..411158bcc7d --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess1.js @@ -0,0 +1,27 @@ +//// [superSymbolIndexedAccess1.ts] +var symbol = Symbol.for('myThing'); + +class Foo { + [symbol]() { + return 0; + } +} + +class Bar extends Foo { + [symbol]() { + return super[symbol](); + } +} + +//// [superSymbolIndexedAccess1.js] +var symbol = Symbol.for('myThing'); +class Foo { + [symbol]() { + return 0; + } +} +class Bar extends Foo { + [symbol]() { + return super[symbol](); + } +} diff --git a/tests/baselines/reference/superSymbolIndexedAccess1.symbols b/tests/baselines/reference/superSymbolIndexedAccess1.symbols new file mode 100644 index 00000000000..818d0ac52af --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess1.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess1.ts === +var symbol = Symbol.for('myThing'); +>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess1.ts, 0, 3)) +>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) + +class Foo { +>Foo : Symbol(Foo, Decl(superSymbolIndexedAccess1.ts, 0, 35)) + + [symbol]() { +>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess1.ts, 0, 3)) + + return 0; + } +} + +class Bar extends Foo { +>Bar : Symbol(Bar, Decl(superSymbolIndexedAccess1.ts, 6, 1)) +>Foo : Symbol(Foo, Decl(superSymbolIndexedAccess1.ts, 0, 35)) + + [symbol]() { +>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess1.ts, 0, 3)) + + return super[symbol](); +>super : Symbol(Foo, Decl(superSymbolIndexedAccess1.ts, 0, 35)) +>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess1.ts, 0, 3)) + } +} diff --git a/tests/baselines/reference/superSymbolIndexedAccess1.types b/tests/baselines/reference/superSymbolIndexedAccess1.types new file mode 100644 index 00000000000..af2c6cab156 --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess1.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess1.ts === +var symbol = Symbol.for('myThing'); +>symbol : symbol +>Symbol.for('myThing') : symbol +>Symbol.for : (key: string) => symbol +>Symbol : SymbolConstructor +>for : (key: string) => symbol +>'myThing' : string + +class Foo { +>Foo : Foo + + [symbol]() { +>symbol : symbol + + return 0; +>0 : number + } +} + +class Bar extends Foo { +>Bar : Bar +>Foo : Foo + + [symbol]() { +>symbol : symbol + + return super[symbol](); +>super[symbol]() : any +>super[symbol] : any +>super : Foo +>symbol : symbol + } +} diff --git a/tests/baselines/reference/superSymbolIndexedAccess2.js b/tests/baselines/reference/superSymbolIndexedAccess2.js new file mode 100644 index 00000000000..bc42addc41f --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess2.js @@ -0,0 +1,25 @@ +//// [superSymbolIndexedAccess2.ts] + +class Foo { + [Symbol.isConcatSpreadable]() { + return 0; + } +} + +class Bar extends Foo { + [Symbol.isConcatSpreadable]() { + return super[Symbol.isConcatSpreadable](); + } +} + +//// [superSymbolIndexedAccess2.js] +class Foo { + [Symbol.isConcatSpreadable]() { + return 0; + } +} +class Bar extends Foo { + [Symbol.isConcatSpreadable]() { + return super[Symbol.isConcatSpreadable](); + } +} diff --git a/tests/baselines/reference/superSymbolIndexedAccess2.symbols b/tests/baselines/reference/superSymbolIndexedAccess2.symbols new file mode 100644 index 00000000000..3865b920647 --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess2.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess2.ts === + +class Foo { +>Foo : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0)) + + [Symbol.isConcatSpreadable]() { +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) + + return 0; + } +} + +class Bar extends Foo { +>Bar : Symbol(Bar, Decl(superSymbolIndexedAccess2.ts, 5, 1)) +>Foo : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0)) + + [Symbol.isConcatSpreadable]() { +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) + + return super[Symbol.isConcatSpreadable](); +>super : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) + } +} diff --git a/tests/baselines/reference/superSymbolIndexedAccess2.types b/tests/baselines/reference/superSymbolIndexedAccess2.types new file mode 100644 index 00000000000..72bb6914d3e --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess2.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess2.ts === + +class Foo { +>Foo : Foo + + [Symbol.isConcatSpreadable]() { +>Symbol.isConcatSpreadable : symbol +>Symbol : SymbolConstructor +>isConcatSpreadable : symbol + + return 0; +>0 : number + } +} + +class Bar extends Foo { +>Bar : Bar +>Foo : Foo + + [Symbol.isConcatSpreadable]() { +>Symbol.isConcatSpreadable : symbol +>Symbol : SymbolConstructor +>isConcatSpreadable : symbol + + return super[Symbol.isConcatSpreadable](); +>super[Symbol.isConcatSpreadable]() : number +>super[Symbol.isConcatSpreadable] : () => number +>super : Foo +>Symbol.isConcatSpreadable : symbol +>Symbol : SymbolConstructor +>isConcatSpreadable : symbol + } +} diff --git a/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt b/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt new file mode 100644 index 00000000000..7f25510e00b --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts(11,16): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. + + +==== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts (1 errors) ==== + var symbol = Symbol.for('myThing'); + + class Foo { + [symbol]() { + return 0; + } + } + + class Bar extends Foo { + [symbol]() { + return super[Bar](); + ~~~~~~~~~~ +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/superSymbolIndexedAccess3.js b/tests/baselines/reference/superSymbolIndexedAccess3.js new file mode 100644 index 00000000000..439a13c6e6e --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess3.js @@ -0,0 +1,27 @@ +//// [superSymbolIndexedAccess3.ts] +var symbol = Symbol.for('myThing'); + +class Foo { + [symbol]() { + return 0; + } +} + +class Bar extends Foo { + [symbol]() { + return super[Bar](); + } +} + +//// [superSymbolIndexedAccess3.js] +var symbol = Symbol.for('myThing'); +class Foo { + [symbol]() { + return 0; + } +} +class Bar extends Foo { + [symbol]() { + return super[Bar](); + } +} diff --git a/tests/baselines/reference/superSymbolIndexedAccess4.errors.txt b/tests/baselines/reference/superSymbolIndexedAccess4.errors.txt new file mode 100644 index 00000000000..dbf18c3d00d --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess4.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess4.ts(5,16): error TS2335: 'super' can only be referenced in a derived class. + + +==== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess4.ts (1 errors) ==== + var symbol = Symbol.for('myThing'); + + class Bar { + [symbol]() { + return super[symbol](); + ~~~~~ +!!! error TS2335: 'super' can only be referenced in a derived class. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/superSymbolIndexedAccess4.js b/tests/baselines/reference/superSymbolIndexedAccess4.js new file mode 100644 index 00000000000..8d966511fc6 --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess4.js @@ -0,0 +1,16 @@ +//// [superSymbolIndexedAccess4.ts] +var symbol = Symbol.for('myThing'); + +class Bar { + [symbol]() { + return super[symbol](); + } +} + +//// [superSymbolIndexedAccess4.js] +var symbol = Symbol.for('myThing'); +class Bar { + [symbol]() { + return super[symbol](); + } +} diff --git a/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess1.ts b/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess1.ts new file mode 100644 index 00000000000..160a76f5c61 --- /dev/null +++ b/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess1.ts @@ -0,0 +1,14 @@ +//@target: ES6 +var symbol = Symbol.for('myThing'); + +class Foo { + [symbol]() { + return 0; + } +} + +class Bar extends Foo { + [symbol]() { + return super[symbol](); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess2.ts b/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess2.ts new file mode 100644 index 00000000000..3f399d41629 --- /dev/null +++ b/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess2.ts @@ -0,0 +1,13 @@ +//@target: ES6 + +class Foo { + [Symbol.isConcatSpreadable]() { + return 0; + } +} + +class Bar extends Foo { + [Symbol.isConcatSpreadable]() { + return super[Symbol.isConcatSpreadable](); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts b/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts new file mode 100644 index 00000000000..2fbbbdc63e6 --- /dev/null +++ b/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts @@ -0,0 +1,14 @@ +//@target: ES6 +var symbol = Symbol.for('myThing'); + +class Foo { + [symbol]() { + return 0; + } +} + +class Bar extends Foo { + [symbol]() { + return super[Bar](); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess4.ts b/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess4.ts new file mode 100644 index 00000000000..095fcc1dbb7 --- /dev/null +++ b/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess4.ts @@ -0,0 +1,8 @@ +//@target: ES6 +var symbol = Symbol.for('myThing'); + +class Bar { + [symbol]() { + return super[symbol](); + } +} \ No newline at end of file From 8e5f34fb4b0dd515c77ab957b2ddaa7e0e40f17a Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 15 Jul 2015 15:04:24 -0700 Subject: [PATCH 23/41] Add downlevel emit tests --- .../reference/superSymbolIndexedAccess5.js | 40 +++++++++++++++++++ .../superSymbolIndexedAccess5.symbols | 26 ++++++++++++ .../reference/superSymbolIndexedAccess5.types | 29 ++++++++++++++ .../reference/superSymbolIndexedAccess6.js | 40 +++++++++++++++++++ .../superSymbolIndexedAccess6.symbols | 26 ++++++++++++ .../reference/superSymbolIndexedAccess6.types | 29 ++++++++++++++ .../superSymbolIndexedAccess5.ts | 14 +++++++ .../superSymbolIndexedAccess6.ts | 14 +++++++ 8 files changed, 218 insertions(+) create mode 100644 tests/baselines/reference/superSymbolIndexedAccess5.js create mode 100644 tests/baselines/reference/superSymbolIndexedAccess5.symbols create mode 100644 tests/baselines/reference/superSymbolIndexedAccess5.types create mode 100644 tests/baselines/reference/superSymbolIndexedAccess6.js create mode 100644 tests/baselines/reference/superSymbolIndexedAccess6.symbols create mode 100644 tests/baselines/reference/superSymbolIndexedAccess6.types create mode 100644 tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess5.ts create mode 100644 tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess6.ts diff --git a/tests/baselines/reference/superSymbolIndexedAccess5.js b/tests/baselines/reference/superSymbolIndexedAccess5.js new file mode 100644 index 00000000000..64a8ac5094c --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess5.js @@ -0,0 +1,40 @@ +//// [superSymbolIndexedAccess5.ts] +var symbol: any; + +class Foo { + [symbol]() { + return 0; + } +} + +class Bar extends Foo { + [symbol]() { + return super[symbol](); + } +} + +//// [superSymbolIndexedAccess5.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var symbol; +var Foo = (function () { + function Foo() { + } + Foo.prototype[symbol] = function () { + return 0; + }; + return Foo; +})(); +var Bar = (function (_super) { + __extends(Bar, _super); + function Bar() { + _super.apply(this, arguments); + } + Bar.prototype[symbol] = function () { + return _super.prototype[symbol](); + }; + return Bar; +})(Foo); diff --git a/tests/baselines/reference/superSymbolIndexedAccess5.symbols b/tests/baselines/reference/superSymbolIndexedAccess5.symbols new file mode 100644 index 00000000000..98ff04a25cd --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess5.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess5.ts === +var symbol: any; +>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess5.ts, 0, 3)) + +class Foo { +>Foo : Symbol(Foo, Decl(superSymbolIndexedAccess5.ts, 0, 16)) + + [symbol]() { +>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess5.ts, 0, 3)) + + return 0; + } +} + +class Bar extends Foo { +>Bar : Symbol(Bar, Decl(superSymbolIndexedAccess5.ts, 6, 1)) +>Foo : Symbol(Foo, Decl(superSymbolIndexedAccess5.ts, 0, 16)) + + [symbol]() { +>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess5.ts, 0, 3)) + + return super[symbol](); +>super : Symbol(Foo, Decl(superSymbolIndexedAccess5.ts, 0, 16)) +>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess5.ts, 0, 3)) + } +} diff --git a/tests/baselines/reference/superSymbolIndexedAccess5.types b/tests/baselines/reference/superSymbolIndexedAccess5.types new file mode 100644 index 00000000000..abc3ba364b0 --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess5.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess5.ts === +var symbol: any; +>symbol : any + +class Foo { +>Foo : Foo + + [symbol]() { +>symbol : any + + return 0; +>0 : number + } +} + +class Bar extends Foo { +>Bar : Bar +>Foo : Foo + + [symbol]() { +>symbol : any + + return super[symbol](); +>super[symbol]() : any +>super[symbol] : any +>super : Foo +>symbol : any + } +} diff --git a/tests/baselines/reference/superSymbolIndexedAccess6.js b/tests/baselines/reference/superSymbolIndexedAccess6.js new file mode 100644 index 00000000000..e014cf47c1a --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess6.js @@ -0,0 +1,40 @@ +//// [superSymbolIndexedAccess6.ts] +var symbol: any; + +class Foo { + static [symbol]() { + return 0; + } +} + +class Bar extends Foo { + static [symbol]() { + return super[symbol](); + } +} + +//// [superSymbolIndexedAccess6.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var symbol; +var Foo = (function () { + function Foo() { + } + Foo[symbol] = function () { + return 0; + }; + return Foo; +})(); +var Bar = (function (_super) { + __extends(Bar, _super); + function Bar() { + _super.apply(this, arguments); + } + Bar[symbol] = function () { + return _super[symbol](); + }; + return Bar; +})(Foo); diff --git a/tests/baselines/reference/superSymbolIndexedAccess6.symbols b/tests/baselines/reference/superSymbolIndexedAccess6.symbols new file mode 100644 index 00000000000..a79a6552674 --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess6.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess6.ts === +var symbol: any; +>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess6.ts, 0, 3)) + +class Foo { +>Foo : Symbol(Foo, Decl(superSymbolIndexedAccess6.ts, 0, 16)) + + static [symbol]() { +>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess6.ts, 0, 3)) + + return 0; + } +} + +class Bar extends Foo { +>Bar : Symbol(Bar, Decl(superSymbolIndexedAccess6.ts, 6, 1)) +>Foo : Symbol(Foo, Decl(superSymbolIndexedAccess6.ts, 0, 16)) + + static [symbol]() { +>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess6.ts, 0, 3)) + + return super[symbol](); +>super : Symbol(Foo, Decl(superSymbolIndexedAccess6.ts, 0, 16)) +>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess6.ts, 0, 3)) + } +} diff --git a/tests/baselines/reference/superSymbolIndexedAccess6.types b/tests/baselines/reference/superSymbolIndexedAccess6.types new file mode 100644 index 00000000000..830ade0c685 --- /dev/null +++ b/tests/baselines/reference/superSymbolIndexedAccess6.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess6.ts === +var symbol: any; +>symbol : any + +class Foo { +>Foo : Foo + + static [symbol]() { +>symbol : any + + return 0; +>0 : number + } +} + +class Bar extends Foo { +>Bar : Bar +>Foo : Foo + + static [symbol]() { +>symbol : any + + return super[symbol](); +>super[symbol]() : any +>super[symbol] : any +>super : typeof Foo +>symbol : any + } +} diff --git a/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess5.ts b/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess5.ts new file mode 100644 index 00000000000..3c1a376eab6 --- /dev/null +++ b/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess5.ts @@ -0,0 +1,14 @@ +//@target: ES5 +var symbol: any; + +class Foo { + [symbol]() { + return 0; + } +} + +class Bar extends Foo { + [symbol]() { + return super[symbol](); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess6.ts b/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess6.ts new file mode 100644 index 00000000000..3850821e9f3 --- /dev/null +++ b/tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess6.ts @@ -0,0 +1,14 @@ +//@target: ES5 +var symbol: any; + +class Foo { + static [symbol]() { + return 0; + } +} + +class Bar extends Foo { + static [symbol]() { + return super[symbol](); + } +} \ No newline at end of file From 873835b9e50354dc26f67e0f0ddbc336349fbf93 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 15 Jul 2015 15:07:04 -0700 Subject: [PATCH 24/41] Add tests. --- ...tifierDefinitionLocations_destructuring.ts | 2 +- ...lRefsObjectBindingElementPropertyName04.ts | 16 +++++++------- ...lRefsObjectBindingElementPropertyName05.ts | 14 +++---------- ...lRefsObjectBindingElementPropertyName06.ts | 13 +++++++++--- ...lRefsObjectBindingElementPropertyName09.ts | 21 +++++++++++++++++++ ...lRefsObjectBindingElementPropertyName10.ts | 21 +++++++++++++++++++ ...foForObjectBindingElementPropertyName03.ts | 14 +++++++++++++ ...foForObjectBindingElementPropertyName04.ts | 14 +++++++++++++ 8 files changed, 92 insertions(+), 23 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName09.ts create mode 100644 tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts create mode 100644 tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName03.ts create mode 100644 tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName04.ts diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts index 0812cb138d2..7f8ef32e1ad 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts @@ -16,7 +16,7 @@ //// function func2({ a, b/*parameter2*/ -test.markers().forEach((m) => { +test.markers().forEach(m => { goTo.position(m.position, m.fileName); verify.completionListIsEmpty(); }); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts index ad72bd99bb8..a72023a1028 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts @@ -5,17 +5,17 @@ //// property2: string; ////} //// -////function f({ [|property1|]: p1 }: I, +////function f({ /**/[|property1|]: p1 }: I, //// { [|property1|] }: I, //// { property1: p2 }) { +//// +//// return property1 + 1; ////} -let ranges = test.ranges(); -for (let range of ranges) { - goTo.position(range.start); +goTo.marker(); - verify.referencesCountIs(ranges.length); - for (let expectedRange of ranges) { - verify.referencesAtPositionContains(expectedRange); - } +let ranges = test.ranges(); +verify.referencesCountIs(ranges.length); +for (let expectedRange of ranges) { + verify.referencesAtPositionContains(expectedRange); } \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName05.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName05.ts index aa6432fa62e..f7e3b80fe45 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName05.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName05.ts @@ -5,17 +5,9 @@ //// property2: string; ////} //// -////function f({ [|property1|]: p }, { property1 }) { +////function f({ /**/property1: p }, { property1 }) { //// let x = property1; ////} -// Notice only one range. -let ranges = test.ranges(); -for (let range of ranges) { - goTo.position(range.start); - - verify.referencesCountIs(ranges.length); - for (let expectedRange of ranges) { - verify.referencesAtPositionContains(expectedRange); - } -} \ No newline at end of file +goTo.marker(); +verify.referencesCountIs(0); \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts index 4ce33f2b6ad..67c7029861e 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts @@ -5,12 +5,19 @@ //// property2: string; ////} //// -////for (let { [|property1|]: p } of []) { +////var elems: I[]; +////for (let { [|property1|]: p } of elems) { ////} -////for (let { [|property1|] } of []) { +////for (let { property1 } of elems) { ////} -////for (var { [|property1|]: p } of []) { +////for (var { [|property1|]: p1 } of elems) { ////} +////var p2; +////for ({ property1 : p2 } of elems) { +////} + +// Note: if this test ever changes, consider updating +// 'quickInfoForObjectBindingElementPropertyName05.ts' let ranges = test.ranges(); for (let range of ranges) { diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName09.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName09.ts new file mode 100644 index 00000000000..0b82c73e31d --- /dev/null +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName09.ts @@ -0,0 +1,21 @@ +/// + +////interface I { +//// [|property1|]: number; +//// property2: string; +////} +//// +////function f({ [|property1|]: p1 }: I, +//// { /**/[|property1|] }: I, +//// { property1: p2 }) { +//// +//// return [|property1|] + 1; +////} + +goTo.marker(); + +let ranges = test.ranges(); +verify.referencesCountIs(ranges.length); +for (let expectedRange of ranges) { + verify.referencesAtPositionContains(expectedRange); +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts new file mode 100644 index 00000000000..ea38f35d103 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts @@ -0,0 +1,21 @@ +/// + +////interface Recursive { +//// [|next|]?: Recursive; +//// value: any; +////} +//// +////function f ({ [|next|]: { [|next|]: x} }: Recursive) { +////} + +goTo.marker(); + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedRange of ranges) { + verify.referencesAtPositionContains(expectedRange); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName03.ts b/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName03.ts new file mode 100644 index 00000000000..cfdeef111dc --- /dev/null +++ b/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName03.ts @@ -0,0 +1,14 @@ +/// + +////interface Recursive { +//// next?: Recursive; +//// value: any; +////} +//// +////function f ({ /*1*/next: { /*2*/next: x} }: Recursive) { +////} + +for (let { position } of test.markers()) { + goTo.position(position) + verify.quickInfoIs("(property) Recursive.next: Recursive"); +} \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName04.ts b/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName04.ts new file mode 100644 index 00000000000..6a0a6cb792a --- /dev/null +++ b/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName04.ts @@ -0,0 +1,14 @@ +/// + +////interface Recursive { +//// next?: Recursive; +//// value: any; +////} +//// +////function f ({ /*1*/next: { /*2*/next: x} }) { +////} + +for (let { position } of test.markers()) { + goTo.position(position) + verify.quickInfoIs("(property) next: any"); +} \ No newline at end of file From 1f6e2ddeacbcd18763ee2c1ea9527dd240740cca Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 15 Jul 2015 15:53:11 -0700 Subject: [PATCH 25/41] Fixed reporting of problems with tests. --- src/harness/fourslash.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 208237b8b64..c90494ce8ed 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -670,20 +670,20 @@ module FourSlash { var completions = this.getCompletionListAtCaret(); if ((!completions || completions.entries.length === 0) && negative) { - this.raiseError("Completion list is empty at Caret"); - } else if ((completions && completions.entries.length !== 0) && !negative) { - - var errorMsg = "\n" + "Completion List contains: [" + completions.entries[0].name; + this.raiseError("Completion list is empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition); + } + else if (completions && completions.entries.length !== 0 && !negative) { + let errorMsg = "\n" + "Completion List contains: [" + completions.entries[0].name; for (var i = 1; i < completions.entries.length; i++) { errorMsg += ", " + completions.entries[i].name; } errorMsg += "]\n"; - Harness.IO.log(errorMsg); - this.raiseError("Completion list is not empty at Caret"); + this.raiseError("Completion list is not empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition + errorMsg); } } + public verifyCompletionListAllowsNewIdentifier(negative: boolean) { var completions = this.getCompletionListAtCaret(); From 5c6a3d73b9e9eb3ac44590b30573e05394fa1cbc Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 15 Jul 2015 15:53:42 -0700 Subject: [PATCH 26/41] Use type predicate for 'isVariableLike'. --- src/compiler/utilities.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e66e1925519..37a7552a3e7 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -566,7 +566,7 @@ namespace ts { } } - export function isVariableLike(node: Node): boolean { + export function isVariableLike(node: Node): node is VariableLikeDeclaration { if (node) { switch (node.kind) { case SyntaxKind.BindingElement: From fdd1f30a955ea2aa99dea761754bb12ee52cc32b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 15 Jul 2015 15:56:13 -0700 Subject: [PATCH 27/41] Enable retrieving the type of a binding property name when an initializer/type annotation is present. --- src/compiler/checker.ts | 19 ++++++++++++++----- src/services/services.ts | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8122ab3c983..38554f63b2a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2293,6 +2293,7 @@ namespace ts { if (declaration.parent.parent.kind === SyntaxKind.ForInStatement) { return anyType; } + if (declaration.parent.parent.kind === SyntaxKind.ForOfStatement) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like @@ -2300,13 +2301,16 @@ namespace ts { // or it may have led to an error inside getElementTypeOfIterable. return checkRightHandSideOfForOf((declaration.parent.parent).expression) || anyType; } + if (isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } + // Use type from type annotation if one is present if (declaration.type) { return getTypeFromTypeNode(declaration.type); } + if (declaration.kind === SyntaxKind.Parameter) { let func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present @@ -2322,14 +2326,22 @@ namespace ts { return type; } } + // Use the type of the initializer expression if one is present if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } + // If it is a short-hand property assignment, use the type of the identifier if (declaration.kind === SyntaxKind.ShorthandPropertyAssignment) { return checkIdentifier(declaration.name); } + + // If the declaration specifies a binding pattern, use the type implied by the binding pattern + if (isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name); + } + // No type specified and nothing can be inferred return undefined; } @@ -2415,13 +2427,10 @@ namespace ts { // tools see the actual type. return declaration.kind !== SyntaxKind.PropertyAssignment ? getWidenedType(type) : type; } - // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use - // the type implied by the binding pattern - if (isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); - } + // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; + // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { let root = getRootDeclaration(declaration); diff --git a/src/services/services.ts b/src/services/services.ts index d79436bb478..0a34ed0e1c0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3232,8 +3232,19 @@ namespace ts { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = (objectLikeContainer).elements; + let rootDeclaration = getRootDeclaration(objectLikeContainer.parent); + if (isVariableLike(rootDeclaration)) { + // We don't want to complete using the type acquired by the shape + // of the binding pattern; we are only interested in types acquired + // through type declaration or inference. + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = (objectLikeContainer).elements; + } + } + else { + Debug.fail("Root declaration is not variable-like.") + } } else { Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); From 5cd77167ec212f94ea2cc8783678440b8ffafd0b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 15 Jul 2015 15:57:01 -0700 Subject: [PATCH 28/41] Updated baselines. --- tests/baselines/reference/arrowFunctionExpressions.symbols | 2 ++ tests/baselines/reference/emitArrowFunctionES6.symbols | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/baselines/reference/arrowFunctionExpressions.symbols b/tests/baselines/reference/arrowFunctionExpressions.symbols index 28945e1179f..61c575933da 100644 --- a/tests/baselines/reference/arrowFunctionExpressions.symbols +++ b/tests/baselines/reference/arrowFunctionExpressions.symbols @@ -70,6 +70,7 @@ var p6 = ({ a }) => { }; var p7 = ({ a: { b } }) => { }; >p7 : Symbol(p7, Decl(arrowFunctionExpressions.ts, 21, 3)) +>a : Symbol(a) >b : Symbol(b, Decl(arrowFunctionExpressions.ts, 21, 16)) var p8 = ({ a = 1 }) => { }; @@ -78,6 +79,7 @@ var p8 = ({ a = 1 }) => { }; var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; >p9 : Symbol(p9, Decl(arrowFunctionExpressions.ts, 23, 3)) +>a : Symbol(a) >b : Symbol(b, Decl(arrowFunctionExpressions.ts, 23, 16)) >b : Symbol(b, Decl(arrowFunctionExpressions.ts, 23, 28)) diff --git a/tests/baselines/reference/emitArrowFunctionES6.symbols b/tests/baselines/reference/emitArrowFunctionES6.symbols index 06f83f7f6f0..8d1603cfd82 100644 --- a/tests/baselines/reference/emitArrowFunctionES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionES6.symbols @@ -56,6 +56,7 @@ var p6 = ({ a }) => { }; var p7 = ({ a: { b } }) => { }; >p7 : Symbol(p7, Decl(emitArrowFunctionES6.ts, 15, 3)) +>a : Symbol(a) >b : Symbol(b, Decl(emitArrowFunctionES6.ts, 15, 16)) var p8 = ({ a = 1 }) => { }; @@ -64,6 +65,7 @@ var p8 = ({ a = 1 }) => { }; var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; >p9 : Symbol(p9, Decl(emitArrowFunctionES6.ts, 17, 3)) +>a : Symbol(a) >b : Symbol(b, Decl(emitArrowFunctionES6.ts, 17, 16)) >b : Symbol(b, Decl(emitArrowFunctionES6.ts, 17, 28)) From 9233073d235b745b599a4b71dfebbb70749e1c0a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 15 Jul 2015 16:05:49 -0700 Subject: [PATCH 29/41] Fixed tests. --- .../findAllRefsObjectBindingElementPropertyName10.ts | 2 -- .../quickInfoForObjectBindingElementPropertyName04.ts | 11 +++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts index ea38f35d103..7b8be1aa91c 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts @@ -8,8 +8,6 @@ ////function f ({ [|next|]: { [|next|]: x} }: Recursive) { ////} -goTo.marker(); - let ranges = test.ranges(); for (let range of ranges) { goTo.position(range.start); diff --git a/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName04.ts b/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName04.ts index 6a0a6cb792a..8b152740861 100644 --- a/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName04.ts +++ b/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName04.ts @@ -8,7 +8,10 @@ ////function f ({ /*1*/next: { /*2*/next: x} }) { ////} -for (let { position } of test.markers()) { - goTo.position(position) - verify.quickInfoIs("(property) next: any"); -} \ No newline at end of file +goTo.marker("1"); +verify.quickInfoIs(`(property) next: { + next: any; +}`); + +goTo.marker("2"); +verify.quickInfoIs("(property) next: any"); \ No newline at end of file From c17934ed3d3d929ec6bf6daa0412bfbb6fa140e4 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 15 Jul 2015 16:21:31 -0700 Subject: [PATCH 30/41] Update LKG --- bin/tsc.js | 126 ++++++--- bin/tsserver.js | 552 ++++++++++++++++++++------------------ bin/typescript.js | 358 +++++++++++++++--------- bin/typescriptServices.js | 358 +++++++++++++++--------- 4 files changed, 839 insertions(+), 555 deletions(-) diff --git a/bin/tsc.js b/bin/tsc.js index f5a780a390d..185aca1ef44 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -933,7 +933,14 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - _fs.writeSync(1, s); + var buffer = new Buffer(s, 'utf8'); + var offset = 0; + var toWrite = buffer.length; + var written = 0; + while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { + offset += written; + toWrite -= written; + } }, readFile: readFile, writeFile: writeFile, @@ -1401,7 +1408,7 @@ var ts; Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, - Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type" }, + Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: ts.DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, @@ -9187,7 +9194,8 @@ var ts; } else { node.exportClause = parseNamedImportsOrExports(226); - if (parseOptional(130)) { + if (token === 130 || (token === 8 && !scanner.hasPrecedingLineBreak())) { + parseExpected(130); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -13263,7 +13271,7 @@ var ts; var id = getTypeListId(elementTypes); var type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(8192); + type = tupleTypes[id] = createObjectType(8192 | getWideningFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -14084,10 +14092,29 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1; var saveErrorInfo = errorInfo; + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + if (sourceSig && targetSig) { + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + if (sourceIsAbstract && !targetIsAbstract) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0; + } + } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { var t = targetSignatures[_i]; if (!t.hasStringLiterals || target.flags & 262144) { var localErrors = reportErrors; + var checkedAbstractAssignability = false; for (var _a = 0; _a < sourceSignatures.length; _a++) { var s = sourceSignatures[_a]; if (!s.hasStringLiterals || source.flags & 262144) { @@ -14135,12 +14162,12 @@ var ts; target = getErasedSignature(target); var result = -1; for (var i = 0; i < checkCount; i++) { - var s_1 = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t_1 = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); var saveErrorInfo = errorInfo; - var related = isRelatedTo(s_1, t_1, reportErrors); + var related = isRelatedTo(s, t, reportErrors); if (!related) { - related = isRelatedTo(t_1, s_1, false); + related = isRelatedTo(t, s, false); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); @@ -14178,11 +14205,11 @@ var ts; } return 0; } - var t = getReturnTypeOfSignature(target); - if (t === voidType) + var targetReturnType = getReturnTypeOfSignature(target); + if (targetReturnType === voidType) return result; - var s = getReturnTypeOfSignature(source); - return result & isRelatedTo(s, t, reportErrors); + var sourceReturnType = getReturnTypeOfSignature(source); + return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -14395,7 +14422,7 @@ var ts; return !!getPropertyOfType(type, "0"); } function isTupleType(type) { - return (type.flags & 8192) && !!type.elementTypes; + return !!(type.flags & 8192); } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); @@ -14437,25 +14464,36 @@ var ts; if (isArrayType(type)) { return createArrayType(getWidenedType(type.typeArguments[0])); } + if (isTupleType(type)) { + return createTupleType(ts.map(type.elementTypes, getWidenedType)); + } } return type; } function reportWideningErrorsInType(type) { + var errorReported = false; if (type.flags & 16384) { - var errorReported = false; - ts.forEach(type.types, function (t) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; if (reportWideningErrorsInType(t)) { errorReported = true; } - }); - return errorReported; + } } if (isArrayType(type)) { return reportWideningErrorsInType(type.typeArguments[0]); } + if (isTupleType(type)) { + for (var _b = 0, _c = type.elementTypes; _b < _c.length; _b++) { + var t = _c[_b]; + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } if (type.flags & 524288) { - var errorReported = false; - ts.forEach(getPropertiesOfObjectType(type), function (p) { + for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { + var p = _e[_d]; var t = getTypeOfSymbol(p); if (t.flags & 1048576) { if (!reportWideningErrorsInType(t)) { @@ -14463,10 +14501,9 @@ var ts; } errorReported = true; } - }); - return errorReported; + } } - return false; + return errorReported; } function reportImplicitAnyError(declaration, type) { var typeAsString = typeToString(getWidenedType(type)); @@ -14614,28 +14651,31 @@ var ts; inferFromTypes(sourceType, target); } } - else if (source.flags & 80896 && (target.flags & (4096 | 8192) || - (target.flags & 65536) && target.symbol && target.symbol.flags & (8192 | 2048 | 32))) { - if (isInProcess(source, target)) { - return; + else { + source = getApparentType(source); + if (source.flags & 80896 && (target.flags & (4096 | 8192) || + (target.flags & 65536) && target.symbol && target.symbol.flags & (8192 | 2048 | 32))) { + if (isInProcess(source, target)) { + return; + } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0); + inferFromSignatures(source, target, 1); + inferFromIndexTypes(source, target, 0, 0); + inferFromIndexTypes(source, target, 1, 1); + inferFromIndexTypes(source, target, 0, 1); + depth--; } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { - return; - } - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0); - inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target, 0, 0); - inferFromIndexTypes(source, target, 1, 1); - inferFromIndexTypes(source, target, 0, 1); - depth--; } } function inferFromProperties(source, target) { diff --git a/bin/tsserver.js b/bin/tsserver.js index bb420529a8c..9d582485e2f 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -933,7 +933,14 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - _fs.writeSync(1, s); + var buffer = new Buffer(s, 'utf8'); + var offset = 0; + var toWrite = buffer.length; + var written = 0; + while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { + offset += written; + toWrite -= written; + } }, readFile: readFile, writeFile: writeFile, @@ -1401,7 +1408,7 @@ var ts; Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, - Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type" }, + Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: ts.DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, @@ -8904,7 +8911,8 @@ var ts; } else { node.exportClause = parseNamedImportsOrExports(226); - if (parseOptional(130)) { + if (token === 130 || (token === 8 && !scanner.hasPrecedingLineBreak())) { + parseExpected(130); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -13686,7 +13694,7 @@ var ts; var id = getTypeListId(elementTypes); var type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(8192); + type = tupleTypes[id] = createObjectType(8192 | getWideningFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -14507,10 +14515,29 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1; var saveErrorInfo = errorInfo; + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + if (sourceSig && targetSig) { + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + if (sourceIsAbstract && !targetIsAbstract) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0; + } + } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { var t = targetSignatures[_i]; if (!t.hasStringLiterals || target.flags & 262144) { var localErrors = reportErrors; + var checkedAbstractAssignability = false; for (var _a = 0; _a < sourceSignatures.length; _a++) { var s = sourceSignatures[_a]; if (!s.hasStringLiterals || source.flags & 262144) { @@ -14558,12 +14585,12 @@ var ts; target = getErasedSignature(target); var result = -1; for (var i = 0; i < checkCount; i++) { - var s_1 = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t_1 = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); var saveErrorInfo = errorInfo; - var related = isRelatedTo(s_1, t_1, reportErrors); + var related = isRelatedTo(s, t, reportErrors); if (!related) { - related = isRelatedTo(t_1, s_1, false); + related = isRelatedTo(t, s, false); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); @@ -14601,11 +14628,11 @@ var ts; } return 0; } - var t = getReturnTypeOfSignature(target); - if (t === voidType) + var targetReturnType = getReturnTypeOfSignature(target); + if (targetReturnType === voidType) return result; - var s = getReturnTypeOfSignature(source); - return result & isRelatedTo(s, t, reportErrors); + var sourceReturnType = getReturnTypeOfSignature(source); + return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -14818,7 +14845,7 @@ var ts; return !!getPropertyOfType(type, "0"); } function isTupleType(type) { - return (type.flags & 8192) && !!type.elementTypes; + return !!(type.flags & 8192); } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); @@ -14860,25 +14887,36 @@ var ts; if (isArrayType(type)) { return createArrayType(getWidenedType(type.typeArguments[0])); } + if (isTupleType(type)) { + return createTupleType(ts.map(type.elementTypes, getWidenedType)); + } } return type; } function reportWideningErrorsInType(type) { + var errorReported = false; if (type.flags & 16384) { - var errorReported = false; - ts.forEach(type.types, function (t) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; if (reportWideningErrorsInType(t)) { errorReported = true; } - }); - return errorReported; + } } if (isArrayType(type)) { return reportWideningErrorsInType(type.typeArguments[0]); } + if (isTupleType(type)) { + for (var _b = 0, _c = type.elementTypes; _b < _c.length; _b++) { + var t = _c[_b]; + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } if (type.flags & 524288) { - var errorReported = false; - ts.forEach(getPropertiesOfObjectType(type), function (p) { + for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { + var p = _e[_d]; var t = getTypeOfSymbol(p); if (t.flags & 1048576) { if (!reportWideningErrorsInType(t)) { @@ -14886,10 +14924,9 @@ var ts; } errorReported = true; } - }); - return errorReported; + } } - return false; + return errorReported; } function reportImplicitAnyError(declaration, type) { var typeAsString = typeToString(getWidenedType(type)); @@ -15037,28 +15074,31 @@ var ts; inferFromTypes(sourceType, target); } } - else if (source.flags & 80896 && (target.flags & (4096 | 8192) || - (target.flags & 65536) && target.symbol && target.symbol.flags & (8192 | 2048 | 32))) { - if (isInProcess(source, target)) { - return; + else { + source = getApparentType(source); + if (source.flags & 80896 && (target.flags & (4096 | 8192) || + (target.flags & 65536) && target.symbol && target.symbol.flags & (8192 | 2048 | 32))) { + if (isInProcess(source, target)) { + return; + } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0); + inferFromSignatures(source, target, 1); + inferFromIndexTypes(source, target, 0, 0); + inferFromIndexTypes(source, target, 1, 1); + inferFromIndexTypes(source, target, 0, 1); + depth--; } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { - return; - } - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0); - inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target, 0, 0); - inferFromIndexTypes(source, target, 1, 1); - inferFromIndexTypes(source, target, 0, 1); - depth--; } } function inferFromProperties(source, target) { @@ -31937,15 +31977,15 @@ var ts; var t; var pos = scanner.getStartPos(); while (pos < endPos) { - var t_2 = scanner.getToken(); - if (!ts.isTrivia(t_2)) { + var t_1 = scanner.getToken(); + if (!ts.isTrivia(t_1)) { break; } scanner.scan(); var item = { pos: pos, end: scanner.getStartPos(), - kind: t_2 + kind: t_1 }; pos = scanner.getStartPos(); if (!leadingTrivia) { @@ -33289,6 +33329,8 @@ var ts; case 15: case 18: case 19: + case 16: + case 17: case 77: case 101: case 53: @@ -33390,7 +33432,7 @@ var ts; } else if (tokenInfo.token.kind === listStartToken) { startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; - var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1, parent, parentDynamicIndentation, startLine); + var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1, parent, parentDynamicIndentation, parentStartLine); listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); } @@ -35914,20 +35956,20 @@ var ts; } function tryGetGlobalSymbols() { var objectLikeContainer; - var importClause; + var namedImportsOrExports; var jsxContainer; if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { return tryGetObjectLikeCompletionSymbols(objectLikeContainer); } - if (importClause = ts.getAncestor(contextToken, 220)) { - return tryGetImportClauseCompletionSymbols(importClause); + if (namedImportsOrExports = tryGetNamedImportsOrExportsForCompletion(contextToken)) { + return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; if ((jsxContainer.kind === 231) || (jsxContainer.kind === 232)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { - symbols = filterJsxAttributes(jsxContainer.attributes, typeChecker.getPropertiesOfType(attrsType)); + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; isNewIdentifierLocation = false; return true; @@ -35957,19 +35999,11 @@ var ts; function isCompletionListBlocker(contextToken) { var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || - isIdentifierDefinitionLocation(contextToken) || + isSolelyIdentifierDefinitionLocation(contextToken) || isDotOfNumericLiteral(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } - function shouldShowCompletionsInImportsClause(node) { - if (node) { - if (node.kind === 14 || node.kind === 23) { - return node.parent.kind === 222; - } - } - return false; - } function isNewIdentifierDefinitionLocation(previousToken) { if (previousToken) { var containingNodeKind = previousToken.parent.kind; @@ -36061,23 +36095,23 @@ var ts; } return true; } - function tryGetImportClauseCompletionSymbols(importClause) { - if (shouldShowCompletionsInImportsClause(contextToken)) { - isMemberCompletion = true; - isNewIdentifierLocation = false; - var importDeclaration = importClause.parent; - ts.Debug.assert(importDeclaration !== undefined && importDeclaration.kind === 219); - var exports_2; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports_2 = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } - symbols = exports_2 ? filterModuleExports(exports_2, importDeclaration) : emptyArray; + function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { + var declarationKind = namedImportsOrExports.kind === 222 ? + 219 : + 225; + var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); + var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; + if (!moduleSpecifier) { + return false; } - else { - isMemberCompletion = false; - isNewIdentifierLocation = true; + isMemberCompletion = true; + isNewIdentifierLocation = false; + var exports; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); } + symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; return true; } function tryGetObjectLikeCompletionContainer(contextToken) { @@ -36094,6 +36128,20 @@ var ts; } return undefined; } + function tryGetNamedImportsOrExportsForCompletion(contextToken) { + if (contextToken) { + switch (contextToken.kind) { + case 14: + case 23: + switch (contextToken.parent.kind) { + case 222: + case 226: + return contextToken.parent; + } + } + } + return undefined; + } function tryGetContainingJsxElement(contextToken) { if (contextToken) { var parent_12 = contextToken.parent; @@ -36133,7 +36181,7 @@ var ts; } return false; } - function isIdentifierDefinitionLocation(contextToken) { + function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 23: @@ -36179,6 +36227,10 @@ var ts; case 107: case 108: return containingNodeKind === 135; + case 113: + containingNodeKind === 223 || + containingNodeKind === 227 || + containingNodeKind === 221; case 70: case 78: case 104: @@ -36214,25 +36266,20 @@ var ts; } return false; } - function filterModuleExports(exports, importDeclaration) { - var exisingImports = {}; - if (!importDeclaration.importClause) { - return exports; + function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { + var exisingImportsOrExports = {}; + for (var _i = 0; _i < namedImportsOrExports.length; _i++) { + var element = namedImportsOrExports[_i]; + if (element.getStart() <= position && position <= element.getEnd()) { + continue; + } + var name_31 = element.propertyName || element.name; + exisingImportsOrExports[name_31.text] = true; } - if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 222) { - ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { - if (el.getStart() <= position && position <= el.getEnd()) { - return; - } - var name = el.propertyName || el.name; - exisingImports[name.text] = true; - }); + if (ts.isEmpty(exisingImportsOrExports)) { + return exportsOfModule; } - if (ts.isEmpty(exisingImports)) { - return exports; - } - return ts.filter(exports, function (e) { return !ts.lookUp(exisingImports, e.name); }); + return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(exisingImportsOrExports, e.name); }); } function filterObjectMembersList(contextualMemberSymbols, existingMembers) { if (!existingMembers || existingMembers.length === 0) { @@ -36258,15 +36305,9 @@ var ts; } existingMemberNames[existingName] = true; } - var filteredMembers = []; - ts.forEach(contextualMemberSymbols, function (s) { - if (!existingMemberNames[s.name]) { - filteredMembers.push(s); - } - }); - return filteredMembers; + return ts.filter(contextualMemberSymbols, function (m) { return !ts.lookUp(existingMemberNames, m.name); }); } - function filterJsxAttributes(attributes, symbols) { + function filterJsxAttributes(symbols, attributes) { var seenNames = {}; for (var _i = 0; _i < attributes.length; _i++) { var attr = attributes[_i]; @@ -36277,14 +36318,7 @@ var ts; seenNames[attr.name.text] = true; } } - var result = []; - for (var _a = 0; _a < symbols.length; _a++) { - var sym = symbols[_a]; - if (!seenNames[sym.name]) { - result.push(sym); - } - } - return result; + return ts.filter(symbols, function (a) { return !ts.lookUp(seenNames, a.name); }); } } function getCompletionsAtPosition(fileName, position) { @@ -36316,10 +36350,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_31 in nameTable) { - if (!allNames[name_31]) { - allNames[name_31] = name_31; - var displayName = getCompletionEntryDisplayName(name_31, target, true); + for (var name_32 in nameTable) { + if (!allNames[name_32]) { + allNames[name_32] = name_32; + var displayName = getCompletionEntryDisplayName(name_32, target, true); if (displayName) { var entry = { name: displayName, @@ -37123,6 +37157,7 @@ var ts; if (hasKind(node.parent, 142) || hasKind(node.parent, 143)) { return getGetAndSetOccurrences(node.parent); } + break; default: if (ts.isModifier(node.kind) && node.parent && (ts.isDeclaration(node.parent) || node.parent.kind === 190)) { @@ -37222,12 +37257,13 @@ var ts; var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { if (!(container.kind === 211 || + container.kind === 183 || (declaration.kind === 135 && hasKind(container, 141)))) { return undefined; } } else if (modifier === 110) { - if (container.kind !== 211) { + if (!(container.kind === 211 || container.kind === 183)) { return undefined; } } @@ -37236,6 +37272,11 @@ var ts; return undefined; } } + else if (modifier === 112) { + if (!(container.kind === 211 || declaration.kind === 211)) { + return undefined; + } + } else { return undefined; } @@ -37245,12 +37286,18 @@ var ts; switch (container.kind) { case 216: case 245: - nodes = container.statements; + if (modifierFlag & 256) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } break; case 141: nodes = container.parameters.concat(container.parent.members); break; case 211: + case 183: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { @@ -37260,6 +37307,9 @@ var ts; nodes = nodes.concat(constructor.parameters); } } + else if (modifierFlag & 256) { + nodes = nodes.concat(container); + } break; default: ts.Debug.fail("Invalid container kind."); @@ -37284,6 +37334,8 @@ var ts; return 1; case 119: return 2; + case 112: + return 256; default: ts.Debug.fail(); } @@ -37981,17 +38033,17 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_32 = node.text; + var name_33 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(name_32); + var unionProperty = contextualType.getProperty(name_33); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_32); + var symbol = t.getProperty(name_33); if (symbol) { result_4.push(symbol); } @@ -38000,7 +38052,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_32); + var symbol_1 = contextualType.getProperty(name_33); if (symbol_1) { return [symbol_1]; } @@ -38599,7 +38651,7 @@ var ts; return; } } - return 9; + return 2; } } function processElement(element) { @@ -39343,10 +39395,113 @@ var ts; this.fileHash = {}; this.nextFileId = 1; this.changeSeq = 0; + this.handlers = (_a = {}, + _a[CommandNames.Exit] = function () { + _this.exit(); + return {}; + }, + _a[CommandNames.Definition] = function (request) { + var defArgs = request.arguments; + return { response: _this.getDefinition(defArgs.line, defArgs.offset, defArgs.file) }; + }, + _a[CommandNames.TypeDefinition] = function (request) { + var defArgs = request.arguments; + return { response: _this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file) }; + }, + _a[CommandNames.References] = function (request) { + var defArgs = request.arguments; + return { response: _this.getReferences(defArgs.line, defArgs.offset, defArgs.file) }; + }, + _a[CommandNames.Rename] = function (request) { + var renameArgs = request.arguments; + return { response: _this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings) }; + }, + _a[CommandNames.Open] = function (request) { + var openArgs = request.arguments; + _this.openClientFile(openArgs.file); + return {}; + }, + _a[CommandNames.Quickinfo] = function (request) { + var quickinfoArgs = request.arguments; + return { response: _this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file) }; + }, + _a[CommandNames.Format] = function (request) { + var formatArgs = request.arguments; + return { response: _this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file) }; + }, + _a[CommandNames.Formatonkey] = function (request) { + var formatOnKeyArgs = request.arguments; + return { response: _this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file) }; + }, + _a[CommandNames.Completions] = function (request) { + var completionsArgs = request.arguments; + return { response: _this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file) }; + }, + _a[CommandNames.CompletionDetails] = function (request) { + var completionDetailsArgs = request.arguments; + return { response: _this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file) }; + }, + _a[CommandNames.SignatureHelp] = function (request) { + var signatureHelpArgs = request.arguments; + return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file) }; + }, + _a[CommandNames.Geterr] = function (request) { + var geterrArgs = request.arguments; + return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; + }, + _a[CommandNames.Change] = function (request) { + var changeArgs = request.arguments; + _this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, changeArgs.insertString, changeArgs.file); + return { responseRequired: false }; + }, + _a[CommandNames.Configure] = function (request) { + var configureArgs = request.arguments; + _this.projectService.setHostConfiguration(configureArgs); + _this.output(undefined, CommandNames.Configure, request.seq); + return { responseRequired: false }; + }, + _a[CommandNames.Reload] = function (request) { + var reloadArgs = request.arguments; + _this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); + return { responseRequired: false }; + }, + _a[CommandNames.Saveto] = function (request) { + var savetoArgs = request.arguments; + _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); + return { responseRequired: false }; + }, + _a[CommandNames.Close] = function (request) { + var closeArgs = request.arguments; + _this.closeClientFile(closeArgs.file); + return { responseRequired: false }; + }, + _a[CommandNames.Navto] = function (request) { + var navtoArgs = request.arguments; + return { response: _this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount) }; + }, + _a[CommandNames.Brace] = function (request) { + var braceArguments = request.arguments; + return { response: _this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file) }; + }, + _a[CommandNames.NavBar] = function (request) { + var navBarArgs = request.arguments; + return { response: _this.getNavigationBarItems(navBarArgs.file) }; + }, + _a[CommandNames.Occurrences] = function (request) { + var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file; + return { response: _this.getOccurrences(line, offset, fileName) }; + }, + _a[CommandNames.ProjectInfo] = function (request) { + var _a = request.arguments, file = _a.file, needFileNameList = _a.needFileNameList; + return { response: _this.getProjectInfo(file, needFileNameList) }; + }, + _a + ); this.projectService = new server.ProjectService(host, logger, function (eventName, project, fileName) { _this.handleEvent(eventName, project, fileName); }); + var _a; } Session.prototype.handleEvent = function (eventName, project, fileName) { var _this = this; @@ -39963,6 +40118,23 @@ var ts; }; Session.prototype.exit = function () { }; + Session.prototype.addProtocolHandler = function (command, handler) { + if (this.handlers[command]) { + throw new Error("Protocol handler already exists for command \"" + command + "\""); + } + this.handlers[command] = handler; + }; + Session.prototype.executeCommand = function (request) { + var handler = this.handlers[request.command]; + if (handler) { + return handler(request); + } + else { + this.projectService.log("Unrecognized JSON command: " + JSON.stringify(request)); + this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); + return { responseRequired: false }; + } + }; Session.prototype.onMessage = function (message) { if (this.logger.isVerbose()) { this.logger.info("request: " + message); @@ -39970,140 +40142,7 @@ var ts; } try { var request = JSON.parse(message); - var response; - var errorMessage; - var responseRequired = true; - switch (request.command) { - case CommandNames.Exit: { - this.exit(); - responseRequired = false; - break; - } - case CommandNames.Definition: { - var defArgs = request.arguments; - response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file); - break; - } - case CommandNames.TypeDefinition: { - var defArgs = request.arguments; - response = this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file); - break; - } - case CommandNames.References: { - var refArgs = request.arguments; - response = this.getReferences(refArgs.line, refArgs.offset, refArgs.file); - break; - } - case CommandNames.Rename: { - var renameArgs = request.arguments; - response = this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings); - break; - } - case CommandNames.Open: { - var openArgs = request.arguments; - this.openClientFile(openArgs.file); - responseRequired = false; - break; - } - case CommandNames.Quickinfo: { - var quickinfoArgs = request.arguments; - response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file); - break; - } - case CommandNames.Format: { - var formatArgs = request.arguments; - response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file); - break; - } - case CommandNames.Formatonkey: { - var formatOnKeyArgs = request.arguments; - response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file); - break; - } - case CommandNames.Completions: { - var completionsArgs = request.arguments; - response = this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file); - break; - } - case CommandNames.CompletionDetails: { - var completionDetailsArgs = request.arguments; - response = - this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file); - break; - } - case CommandNames.SignatureHelp: { - var signatureHelpArgs = request.arguments; - response = this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file); - break; - } - case CommandNames.Geterr: { - var geterrArgs = request.arguments; - response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files); - responseRequired = false; - break; - } - case CommandNames.Change: { - var changeArgs = request.arguments; - this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, changeArgs.insertString, changeArgs.file); - responseRequired = false; - break; - } - case CommandNames.Configure: { - var configureArgs = request.arguments; - this.projectService.setHostConfiguration(configureArgs); - this.output(undefined, CommandNames.Configure, request.seq); - responseRequired = false; - break; - } - case CommandNames.Reload: { - var reloadArgs = request.arguments; - this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); - responseRequired = false; - break; - } - case CommandNames.Saveto: { - var savetoArgs = request.arguments; - this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); - responseRequired = false; - break; - } - case CommandNames.Close: { - var closeArgs = request.arguments; - this.closeClientFile(closeArgs.file); - responseRequired = false; - break; - } - case CommandNames.Navto: { - var navtoArgs = request.arguments; - response = this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount); - break; - } - case CommandNames.Brace: { - var braceArguments = request.arguments; - response = this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file); - break; - } - case CommandNames.NavBar: { - var navBarArgs = request.arguments; - response = this.getNavigationBarItems(navBarArgs.file); - break; - } - case CommandNames.Occurrences: { - var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file; - response = this.getOccurrences(line, offset, fileName); - break; - } - case CommandNames.ProjectInfo: { - var _b = request.arguments, file = _b.file, needFileNameList = _b.needFileNameList; - response = this.getProjectInfo(file, needFileNameList); - break; - } - default: { - this.projectService.log("Unrecognized JSON command: " + message); - this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); - break; - } - } + var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; if (this.logger.isVerbose()) { var elapsed = this.hrtime(start); var seconds = elapsed[0]; @@ -42033,6 +42072,11 @@ var ts; var decoded = JSON.parse(encoded); return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; + ScriptSnapshotShimAdapter.prototype.dispose = function () { + if ("dispose" in this.scriptSnapshotShim) { + this.scriptSnapshotShim.dispose(); + } + }; return ScriptSnapshotShimAdapter; })(); var LanguageServiceShimHostAdapter = (function () { diff --git a/bin/typescript.js b/bin/typescript.js index e3573e840e8..6035d71fa2b 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -1775,8 +1775,15 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { + var buffer = new Buffer(s, 'utf8'); + var offset = 0; + var toWrite = buffer.length; + var written = 0; // 1 is a standard descriptor for stdout - _fs.writeSync(1, s); + while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { + offset += written; + toWrite -= written; + } }, readFile: readFile, writeFile: writeFile, @@ -2247,7 +2254,7 @@ var ts; Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, - Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type" }, + Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: ts.DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, @@ -11517,7 +11524,11 @@ var ts; } else { node.exportClause = parseNamedImportsOrExports(226 /* NamedExports */); - if (parseOptional(130 /* FromKeyword */)) { + // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, + // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) + // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. + if (token === 130 /* FromKeyword */ || (token === 8 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(130 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -16299,7 +16310,7 @@ var ts; var id = getTypeListId(elementTypes); var type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(8192 /* Tuple */); + type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getWideningFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -17200,10 +17211,33 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1 /* True */; var saveErrorInfo = errorInfo; + // Because the "abstractness" of a class is the same across all construct signatures + // (internally we are checking the corresponding declaration), it is enough to perform + // the check and report an error once over all pairs of source and target construct signatures. + var sourceSig = sourceSignatures[0]; + // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. + var targetSig = targetSignatures[0]; + if (sourceSig && targetSig) { + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211 /* ClassDeclaration */); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211 /* ClassDeclaration */); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + if (sourceIsAbstract && !targetIsAbstract) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0 /* False */; + } + } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { var t = targetSignatures[_i]; if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { var localErrors = reportErrors; + var checkedAbstractAssignability = false; for (var _a = 0; _a < sourceSignatures.length; _a++) { var s = sourceSignatures[_a]; if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { @@ -17254,12 +17288,12 @@ var ts; target = getErasedSignature(target); var result = -1 /* True */; for (var i = 0; i < checkCount; i++) { - var s_1 = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t_1 = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); var saveErrorInfo = errorInfo; - var related = isRelatedTo(s_1, t_1, reportErrors); + var related = isRelatedTo(s, t, reportErrors); if (!related) { - related = isRelatedTo(t_1, s_1, false); + related = isRelatedTo(t, s, false); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); @@ -17297,11 +17331,11 @@ var ts; } return 0 /* False */; } - var t = getReturnTypeOfSignature(target); - if (t === voidType) + var targetReturnType = getReturnTypeOfSignature(target); + if (targetReturnType === voidType) return result; - var s = getReturnTypeOfSignature(source); - return result & isRelatedTo(s, t, reportErrors); + var sourceReturnType = getReturnTypeOfSignature(source); + return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -17537,7 +17571,7 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. */ function isTupleType(type) { - return (type.flags & 8192 /* Tuple */) && !!type.elementTypes; + return !!(type.flags & 8192 /* Tuple */); } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); @@ -17579,25 +17613,47 @@ var ts; if (isArrayType(type)) { return createArrayType(getWidenedType(type.typeArguments[0])); } + if (isTupleType(type)) { + return createTupleType(ts.map(type.elementTypes, getWidenedType)); + } } return type; } + /** + * Reports implicit any errors that occur as a result of widening 'null' and 'undefined' + * to 'any'. A call to reportWideningErrorsInType is normally accompanied by a call to + * getWidenedType. But in some cases getWidenedType is called without reporting errors + * (type argument inference is an example). + * + * The return value indicates whether an error was in fact reported. The particular circumstances + * are on a best effort basis. Currently, if the null or undefined that causes widening is inside + * an object literal property (arbitrarily deeply), this function reports an error. If no error is + * reported, reportImplicitAnyError is a suitable fallback to report a general error. + */ function reportWideningErrorsInType(type) { + var errorReported = false; if (type.flags & 16384 /* Union */) { - var errorReported = false; - ts.forEach(type.types, function (t) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; if (reportWideningErrorsInType(t)) { errorReported = true; } - }); - return errorReported; + } } if (isArrayType(type)) { return reportWideningErrorsInType(type.typeArguments[0]); } + if (isTupleType(type)) { + for (var _b = 0, _c = type.elementTypes; _b < _c.length; _b++) { + var t = _c[_b]; + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } if (type.flags & 524288 /* ObjectLiteral */) { - var errorReported = false; - ts.forEach(getPropertiesOfObjectType(type), function (p) { + for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { + var p = _e[_d]; var t = getTypeOfSymbol(p); if (t.flags & 1048576 /* ContainsUndefinedOrNull */) { if (!reportWideningErrorsInType(t)) { @@ -17605,10 +17661,9 @@ var ts; } errorReported = true; } - }); - return errorReported; + } } - return false; + return errorReported; } function reportImplicitAnyError(declaration, type) { var typeAsString = typeToString(getWidenedType(type)); @@ -17771,29 +17826,32 @@ var ts; inferFromTypes(sourceType, target); } } - else if (source.flags & 80896 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || - (target.flags & 65536 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */))) { - // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members - if (isInProcess(source, target)) { - return; + else { + source = getApparentType(source); + if (source.flags & 80896 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || + (target.flags & 65536 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */))) { + // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members + if (isInProcess(source, target)) { + return; + } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0 /* Call */); + inferFromSignatures(source, target, 1 /* Construct */); + inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); + inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); + inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); + depth--; } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { - return; - } - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); - inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); - inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); - depth--; } } function inferFromProperties(source, target) { @@ -37768,8 +37826,8 @@ var ts; var pos = scanner.getStartPos(); // Read leading trivia and token while (pos < endPos) { - var t_2 = scanner.getToken(); - if (!ts.isTrivia(t_2)) { + var t_1 = scanner.getToken(); + if (!ts.isTrivia(t_1)) { break; } // consume leading trivia @@ -37777,7 +37835,7 @@ var ts; var item = { pos: pos, end: scanner.getStartPos(), - kind: t_2 + kind: t_1 }; pos = scanner.getStartPos(); if (!leadingTrivia) { @@ -39359,6 +39417,8 @@ var ts; case 15 /* CloseBraceToken */: case 18 /* OpenBracketToken */: case 19 /* CloseBracketToken */: + case 16 /* OpenParenToken */: + case 17 /* CloseParenToken */: case 77 /* ElseKeyword */: case 101 /* WhileKeyword */: case 53 /* AtToken */: @@ -39483,7 +39543,7 @@ var ts; else if (tokenInfo.token.kind === listStartToken) { // consume list start token startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; - var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, startLine); + var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); } @@ -42417,15 +42477,15 @@ var ts; } function tryGetGlobalSymbols() { var objectLikeContainer; - var importClause; + var namedImportsOrExports; var jsxContainer; if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { return tryGetObjectLikeCompletionSymbols(objectLikeContainer); } - if (importClause = ts.getAncestor(contextToken, 220 /* ImportClause */)) { + if (namedImportsOrExports = tryGetNamedImportsOrExportsForCompletion(contextToken)) { // cursor is in an import clause // try to show exported member for imported module - return tryGetImportClauseCompletionSymbols(importClause); + return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; @@ -42433,7 +42493,7 @@ var ts; // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { - symbols = filterJsxAttributes(jsxContainer.attributes, typeChecker.getPropertiesOfType(attrsType)); + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; isNewIdentifierLocation = false; return true; @@ -42494,21 +42554,11 @@ var ts; function isCompletionListBlocker(contextToken) { var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || - isIdentifierDefinitionLocation(contextToken) || + isSolelyIdentifierDefinitionLocation(contextToken) || isDotOfNumericLiteral(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } - function shouldShowCompletionsInImportsClause(node) { - if (node) { - // import {| - // import {a,| - if (node.kind === 14 /* OpenBraceToken */ || node.kind === 23 /* CommaToken */) { - return node.parent.kind === 222 /* NamedImports */; - } - } - return false; - } function isNewIdentifierDefinitionLocation(previousToken) { if (previousToken) { var containingNodeKind = previousToken.parent.kind; @@ -42617,34 +42667,37 @@ var ts; return true; } /** - * Aggregates relevant symbols for completion in import clauses; for instance, + * Aggregates relevant symbols for completion in import clauses and export clauses + * whose declarations have a module specifier; for instance, symbols will be aggregated for * - * import { $ } from "moduleName"; + * import { | } from "moduleName"; + * export { a as foo, | } from "moduleName"; + * + * but not for + * + * export { | }; * * Relevant symbols are stored in the captured 'symbols' variable. * * @returns true if 'symbols' was successfully populated; false otherwise. */ - function tryGetImportClauseCompletionSymbols(importClause) { - // cursor is in import clause - // try to show exported member for imported module - if (shouldShowCompletionsInImportsClause(contextToken)) { - isMemberCompletion = true; - isNewIdentifierLocation = false; - var importDeclaration = importClause.parent; - ts.Debug.assert(importDeclaration !== undefined && importDeclaration.kind === 219 /* ImportDeclaration */); - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } - //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); - symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; + function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { + var declarationKind = namedImportsOrExports.kind === 222 /* NamedImports */ ? + 219 /* ImportDeclaration */ : + 225 /* ExportDeclaration */; + var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); + var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; + if (!moduleSpecifier) { + return false; } - else { - isMemberCompletion = false; - isNewIdentifierLocation = true; + isMemberCompletion = true; + isNewIdentifierLocation = false; + var exports; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); } + symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; return true; } /** @@ -42665,6 +42718,24 @@ var ts; } return undefined; } + /** + * Returns the containing list of named imports or exports of a context token, + * on the condition that one exists and that the context implies completion should be given. + */ + function tryGetNamedImportsOrExportsForCompletion(contextToken) { + if (contextToken) { + switch (contextToken.kind) { + case 14 /* OpenBraceToken */: // import { | + case 23 /* CommaToken */: + switch (contextToken.parent.kind) { + case 222 /* NamedImports */: + case 226 /* NamedExports */: + return contextToken.parent; + } + } + } + return undefined; + } function tryGetContainingJsxElement(contextToken) { if (contextToken) { var parent_12 = contextToken.parent; @@ -42707,7 +42778,10 @@ var ts; } return false; } - function isIdentifierDefinitionLocation(contextToken) { + /** + * @returns true if we are certain that the currently edited location must define a new location; false otherwise. + */ + function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 23 /* CommaToken */: @@ -42753,6 +42827,10 @@ var ts; case 107 /* PrivateKeyword */: case 108 /* ProtectedKeyword */: return containingNodeKind === 135 /* Parameter */; + case 113 /* AsKeyword */: + containingNodeKind === 223 /* ImportSpecifier */ || + containingNodeKind === 227 /* ExportSpecifier */ || + containingNodeKind === 221 /* NamespaceImport */; case 70 /* ClassKeyword */: case 78 /* EnumKeyword */: case 104 /* InterfaceKeyword */: @@ -42789,27 +42867,37 @@ var ts; } return false; } - function filterModuleExports(exports, importDeclaration) { - var exisingImports = {}; - if (!importDeclaration.importClause) { - return exports; + /** + * Filters out completion suggestions for named imports or exports. + * + * @param exportsOfModule The list of symbols which a module exposes. + * @param namedImportsOrExports The list of existing import/export specifiers in the import/export clause. + * + * @returns Symbols to be suggested at an import/export clause, barring those whose named imports/exports + * do not occur at the current position and have not otherwise been typed. + */ + function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { + var exisingImportsOrExports = {}; + for (var _i = 0; _i < namedImportsOrExports.length; _i++) { + var element = namedImportsOrExports[_i]; + // If this is the current item we are editing right now, do not filter it out + if (element.getStart() <= position && position <= element.getEnd()) { + continue; + } + var name_31 = element.propertyName || element.name; + exisingImportsOrExports[name_31.text] = true; } - if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 222 /* NamedImports */) { - ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { - // If this is the current item we are editing right now, do not filter it out - if (el.getStart() <= position && position <= el.getEnd()) { - return; - } - var name = el.propertyName || el.name; - exisingImports[name.text] = true; - }); + if (ts.isEmpty(exisingImportsOrExports)) { + return exportsOfModule; } - if (ts.isEmpty(exisingImports)) { - return exports; - } - return ts.filter(exports, function (e) { return !ts.lookUp(exisingImports, e.name); }); + return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(exisingImportsOrExports, e.name); }); } + /** + * Filters out completion suggestions for named imports or exports. + * + * @returns Symbols to be suggested in an object binding pattern or object literal expression, barring those whose declarations + * do not occur at the current position and have not otherwise been typed. + */ function filterObjectMembersList(contextualMemberSymbols, existingMembers) { if (!existingMembers || existingMembers.length === 0) { return contextualMemberSymbols; @@ -42839,15 +42927,15 @@ var ts; } existingMemberNames[existingName] = true; } - var filteredMembers = []; - ts.forEach(contextualMemberSymbols, function (s) { - if (!existingMemberNames[s.name]) { - filteredMembers.push(s); - } - }); - return filteredMembers; + return ts.filter(contextualMemberSymbols, function (m) { return !ts.lookUp(existingMemberNames, m.name); }); } - function filterJsxAttributes(attributes, symbols) { + /** + * Filters out completion suggestions from 'symbols' according to existing JSX attributes. + * + * @returns Symbols to be suggested in a JSX element, barring those whose attributes + * do not occur at the current position and have not otherwise been typed. + */ + function filterJsxAttributes(symbols, attributes) { var seenNames = {}; for (var _i = 0; _i < attributes.length; _i++) { var attr = attributes[_i]; @@ -42859,14 +42947,7 @@ var ts; seenNames[attr.name.text] = true; } } - var result = []; - for (var _a = 0; _a < symbols.length; _a++) { - var sym = symbols[_a]; - if (!seenNames[sym.name]) { - result.push(sym); - } - } - return result; + return ts.filter(symbols, function (a) { return !ts.lookUp(seenNames, a.name); }); } } function getCompletionsAtPosition(fileName, position) { @@ -42899,10 +42980,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_31 in nameTable) { - if (!allNames[name_31]) { - allNames[name_31] = name_31; - var displayName = getCompletionEntryDisplayName(name_31, target, true); + for (var name_32 in nameTable) { + if (!allNames[name_32]) { + allNames[name_32] = name_32; + var displayName = getCompletionEntryDisplayName(name_32, target, true); if (displayName) { var entry = { name: displayName, @@ -43771,6 +43852,7 @@ var ts; if (hasKind(node.parent, 142 /* GetAccessor */) || hasKind(node.parent, 143 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } + break; default: if (ts.isModifier(node.kind) && node.parent && (ts.isDeclaration(node.parent) || node.parent.kind === 190 /* VariableStatement */)) { @@ -43886,12 +43968,13 @@ var ts; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { if (!(container.kind === 211 /* ClassDeclaration */ || + container.kind === 183 /* ClassExpression */ || (declaration.kind === 135 /* Parameter */ && hasKind(container, 141 /* Constructor */)))) { return undefined; } } else if (modifier === 110 /* StaticKeyword */) { - if (container.kind !== 211 /* ClassDeclaration */) { + if (!(container.kind === 211 /* ClassDeclaration */ || container.kind === 183 /* ClassExpression */)) { return undefined; } } @@ -43900,6 +43983,11 @@ var ts; return undefined; } } + else if (modifier === 112 /* AbstractKeyword */) { + if (!(container.kind === 211 /* ClassDeclaration */ || declaration.kind === 211 /* ClassDeclaration */)) { + return undefined; + } + } else { // unsupported modifier return undefined; @@ -43910,12 +43998,19 @@ var ts; switch (container.kind) { case 216 /* ModuleBlock */: case 245 /* SourceFile */: - nodes = container.statements; + // Container is either a class declaration or the declaration is a classDeclaration + if (modifierFlag & 256 /* Abstract */) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } break; case 141 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. @@ -43927,6 +44022,9 @@ var ts; nodes = nodes.concat(constructor.parameters); } } + else if (modifierFlag & 256 /* Abstract */) { + nodes = nodes.concat(container); + } break; default: ts.Debug.fail("Invalid container kind."); @@ -43951,6 +44049,8 @@ var ts; return 1 /* Export */; case 119 /* DeclareKeyword */: return 2 /* Ambient */; + case 112 /* AbstractKeyword */: + return 256 /* Abstract */; default: ts.Debug.fail(); } @@ -44768,19 +44868,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_32 = node.text; + var name_33 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_32); + var unionProperty = contextualType.getProperty(name_33); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_32); + var symbol = t.getProperty(name_33); if (symbol) { result_4.push(symbol); } @@ -44789,7 +44889,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_32); + var symbol_1 = contextualType.getProperty(name_33); if (symbol_1) { return [symbol_1]; } @@ -45471,7 +45571,7 @@ var ts; return; } } - return 9 /* text */; + return 2 /* identifier */; } } function processElement(element) { diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index e3573e840e8..6035d71fa2b 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -1775,8 +1775,15 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { + var buffer = new Buffer(s, 'utf8'); + var offset = 0; + var toWrite = buffer.length; + var written = 0; // 1 is a standard descriptor for stdout - _fs.writeSync(1, s); + while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { + offset += written; + toWrite -= written; + } }, readFile: readFile, writeFile: writeFile, @@ -2247,7 +2254,7 @@ var ts; Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, - Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type" }, + Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: ts.DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, @@ -11517,7 +11524,11 @@ var ts; } else { node.exportClause = parseNamedImportsOrExports(226 /* NamedExports */); - if (parseOptional(130 /* FromKeyword */)) { + // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, + // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) + // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. + if (token === 130 /* FromKeyword */ || (token === 8 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(130 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -16299,7 +16310,7 @@ var ts; var id = getTypeListId(elementTypes); var type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(8192 /* Tuple */); + type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getWideningFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -17200,10 +17211,33 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1 /* True */; var saveErrorInfo = errorInfo; + // Because the "abstractness" of a class is the same across all construct signatures + // (internally we are checking the corresponding declaration), it is enough to perform + // the check and report an error once over all pairs of source and target construct signatures. + var sourceSig = sourceSignatures[0]; + // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. + var targetSig = targetSignatures[0]; + if (sourceSig && targetSig) { + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211 /* ClassDeclaration */); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211 /* ClassDeclaration */); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + if (sourceIsAbstract && !targetIsAbstract) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0 /* False */; + } + } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { var t = targetSignatures[_i]; if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { var localErrors = reportErrors; + var checkedAbstractAssignability = false; for (var _a = 0; _a < sourceSignatures.length; _a++) { var s = sourceSignatures[_a]; if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { @@ -17254,12 +17288,12 @@ var ts; target = getErasedSignature(target); var result = -1 /* True */; for (var i = 0; i < checkCount; i++) { - var s_1 = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t_1 = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); + var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); + var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); var saveErrorInfo = errorInfo; - var related = isRelatedTo(s_1, t_1, reportErrors); + var related = isRelatedTo(s, t, reportErrors); if (!related) { - related = isRelatedTo(t_1, s_1, false); + related = isRelatedTo(t, s, false); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); @@ -17297,11 +17331,11 @@ var ts; } return 0 /* False */; } - var t = getReturnTypeOfSignature(target); - if (t === voidType) + var targetReturnType = getReturnTypeOfSignature(target); + if (targetReturnType === voidType) return result; - var s = getReturnTypeOfSignature(source); - return result & isRelatedTo(s, t, reportErrors); + var sourceReturnType = getReturnTypeOfSignature(source); + return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -17537,7 +17571,7 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. */ function isTupleType(type) { - return (type.flags & 8192 /* Tuple */) && !!type.elementTypes; + return !!(type.flags & 8192 /* Tuple */); } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); @@ -17579,25 +17613,47 @@ var ts; if (isArrayType(type)) { return createArrayType(getWidenedType(type.typeArguments[0])); } + if (isTupleType(type)) { + return createTupleType(ts.map(type.elementTypes, getWidenedType)); + } } return type; } + /** + * Reports implicit any errors that occur as a result of widening 'null' and 'undefined' + * to 'any'. A call to reportWideningErrorsInType is normally accompanied by a call to + * getWidenedType. But in some cases getWidenedType is called without reporting errors + * (type argument inference is an example). + * + * The return value indicates whether an error was in fact reported. The particular circumstances + * are on a best effort basis. Currently, if the null or undefined that causes widening is inside + * an object literal property (arbitrarily deeply), this function reports an error. If no error is + * reported, reportImplicitAnyError is a suitable fallback to report a general error. + */ function reportWideningErrorsInType(type) { + var errorReported = false; if (type.flags & 16384 /* Union */) { - var errorReported = false; - ts.forEach(type.types, function (t) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; if (reportWideningErrorsInType(t)) { errorReported = true; } - }); - return errorReported; + } } if (isArrayType(type)) { return reportWideningErrorsInType(type.typeArguments[0]); } + if (isTupleType(type)) { + for (var _b = 0, _c = type.elementTypes; _b < _c.length; _b++) { + var t = _c[_b]; + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } if (type.flags & 524288 /* ObjectLiteral */) { - var errorReported = false; - ts.forEach(getPropertiesOfObjectType(type), function (p) { + for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { + var p = _e[_d]; var t = getTypeOfSymbol(p); if (t.flags & 1048576 /* ContainsUndefinedOrNull */) { if (!reportWideningErrorsInType(t)) { @@ -17605,10 +17661,9 @@ var ts; } errorReported = true; } - }); - return errorReported; + } } - return false; + return errorReported; } function reportImplicitAnyError(declaration, type) { var typeAsString = typeToString(getWidenedType(type)); @@ -17771,29 +17826,32 @@ var ts; inferFromTypes(sourceType, target); } } - else if (source.flags & 80896 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || - (target.flags & 65536 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */))) { - // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members - if (isInProcess(source, target)) { - return; + else { + source = getApparentType(source); + if (source.flags & 80896 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || + (target.flags & 65536 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */))) { + // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members + if (isInProcess(source, target)) { + return; + } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, 0 /* Call */); + inferFromSignatures(source, target, 1 /* Construct */); + inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); + inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); + inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); + depth--; } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { - return; - } - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); - inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); - inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); - depth--; } } function inferFromProperties(source, target) { @@ -37768,8 +37826,8 @@ var ts; var pos = scanner.getStartPos(); // Read leading trivia and token while (pos < endPos) { - var t_2 = scanner.getToken(); - if (!ts.isTrivia(t_2)) { + var t_1 = scanner.getToken(); + if (!ts.isTrivia(t_1)) { break; } // consume leading trivia @@ -37777,7 +37835,7 @@ var ts; var item = { pos: pos, end: scanner.getStartPos(), - kind: t_2 + kind: t_1 }; pos = scanner.getStartPos(); if (!leadingTrivia) { @@ -39359,6 +39417,8 @@ var ts; case 15 /* CloseBraceToken */: case 18 /* OpenBracketToken */: case 19 /* CloseBracketToken */: + case 16 /* OpenParenToken */: + case 17 /* CloseParenToken */: case 77 /* ElseKeyword */: case 101 /* WhileKeyword */: case 53 /* AtToken */: @@ -39483,7 +39543,7 @@ var ts; else if (tokenInfo.token.kind === listStartToken) { // consume list start token startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; - var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, startLine); + var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); } @@ -42417,15 +42477,15 @@ var ts; } function tryGetGlobalSymbols() { var objectLikeContainer; - var importClause; + var namedImportsOrExports; var jsxContainer; if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { return tryGetObjectLikeCompletionSymbols(objectLikeContainer); } - if (importClause = ts.getAncestor(contextToken, 220 /* ImportClause */)) { + if (namedImportsOrExports = tryGetNamedImportsOrExportsForCompletion(contextToken)) { // cursor is in an import clause // try to show exported member for imported module - return tryGetImportClauseCompletionSymbols(importClause); + return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; @@ -42433,7 +42493,7 @@ var ts; // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { - symbols = filterJsxAttributes(jsxContainer.attributes, typeChecker.getPropertiesOfType(attrsType)); + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; isNewIdentifierLocation = false; return true; @@ -42494,21 +42554,11 @@ var ts; function isCompletionListBlocker(contextToken) { var start = new Date().getTime(); var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || - isIdentifierDefinitionLocation(contextToken) || + isSolelyIdentifierDefinitionLocation(contextToken) || isDotOfNumericLiteral(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } - function shouldShowCompletionsInImportsClause(node) { - if (node) { - // import {| - // import {a,| - if (node.kind === 14 /* OpenBraceToken */ || node.kind === 23 /* CommaToken */) { - return node.parent.kind === 222 /* NamedImports */; - } - } - return false; - } function isNewIdentifierDefinitionLocation(previousToken) { if (previousToken) { var containingNodeKind = previousToken.parent.kind; @@ -42617,34 +42667,37 @@ var ts; return true; } /** - * Aggregates relevant symbols for completion in import clauses; for instance, + * Aggregates relevant symbols for completion in import clauses and export clauses + * whose declarations have a module specifier; for instance, symbols will be aggregated for * - * import { $ } from "moduleName"; + * import { | } from "moduleName"; + * export { a as foo, | } from "moduleName"; + * + * but not for + * + * export { | }; * * Relevant symbols are stored in the captured 'symbols' variable. * * @returns true if 'symbols' was successfully populated; false otherwise. */ - function tryGetImportClauseCompletionSymbols(importClause) { - // cursor is in import clause - // try to show exported member for imported module - if (shouldShowCompletionsInImportsClause(contextToken)) { - isMemberCompletion = true; - isNewIdentifierLocation = false; - var importDeclaration = importClause.parent; - ts.Debug.assert(importDeclaration !== undefined && importDeclaration.kind === 219 /* ImportDeclaration */); - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } - //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); - symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; + function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { + var declarationKind = namedImportsOrExports.kind === 222 /* NamedImports */ ? + 219 /* ImportDeclaration */ : + 225 /* ExportDeclaration */; + var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); + var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; + if (!moduleSpecifier) { + return false; } - else { - isMemberCompletion = false; - isNewIdentifierLocation = true; + isMemberCompletion = true; + isNewIdentifierLocation = false; + var exports; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); } + symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; return true; } /** @@ -42665,6 +42718,24 @@ var ts; } return undefined; } + /** + * Returns the containing list of named imports or exports of a context token, + * on the condition that one exists and that the context implies completion should be given. + */ + function tryGetNamedImportsOrExportsForCompletion(contextToken) { + if (contextToken) { + switch (contextToken.kind) { + case 14 /* OpenBraceToken */: // import { | + case 23 /* CommaToken */: + switch (contextToken.parent.kind) { + case 222 /* NamedImports */: + case 226 /* NamedExports */: + return contextToken.parent; + } + } + } + return undefined; + } function tryGetContainingJsxElement(contextToken) { if (contextToken) { var parent_12 = contextToken.parent; @@ -42707,7 +42778,10 @@ var ts; } return false; } - function isIdentifierDefinitionLocation(contextToken) { + /** + * @returns true if we are certain that the currently edited location must define a new location; false otherwise. + */ + function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 23 /* CommaToken */: @@ -42753,6 +42827,10 @@ var ts; case 107 /* PrivateKeyword */: case 108 /* ProtectedKeyword */: return containingNodeKind === 135 /* Parameter */; + case 113 /* AsKeyword */: + containingNodeKind === 223 /* ImportSpecifier */ || + containingNodeKind === 227 /* ExportSpecifier */ || + containingNodeKind === 221 /* NamespaceImport */; case 70 /* ClassKeyword */: case 78 /* EnumKeyword */: case 104 /* InterfaceKeyword */: @@ -42789,27 +42867,37 @@ var ts; } return false; } - function filterModuleExports(exports, importDeclaration) { - var exisingImports = {}; - if (!importDeclaration.importClause) { - return exports; + /** + * Filters out completion suggestions for named imports or exports. + * + * @param exportsOfModule The list of symbols which a module exposes. + * @param namedImportsOrExports The list of existing import/export specifiers in the import/export clause. + * + * @returns Symbols to be suggested at an import/export clause, barring those whose named imports/exports + * do not occur at the current position and have not otherwise been typed. + */ + function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { + var exisingImportsOrExports = {}; + for (var _i = 0; _i < namedImportsOrExports.length; _i++) { + var element = namedImportsOrExports[_i]; + // If this is the current item we are editing right now, do not filter it out + if (element.getStart() <= position && position <= element.getEnd()) { + continue; + } + var name_31 = element.propertyName || element.name; + exisingImportsOrExports[name_31.text] = true; } - if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 222 /* NamedImports */) { - ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { - // If this is the current item we are editing right now, do not filter it out - if (el.getStart() <= position && position <= el.getEnd()) { - return; - } - var name = el.propertyName || el.name; - exisingImports[name.text] = true; - }); + if (ts.isEmpty(exisingImportsOrExports)) { + return exportsOfModule; } - if (ts.isEmpty(exisingImports)) { - return exports; - } - return ts.filter(exports, function (e) { return !ts.lookUp(exisingImports, e.name); }); + return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(exisingImportsOrExports, e.name); }); } + /** + * Filters out completion suggestions for named imports or exports. + * + * @returns Symbols to be suggested in an object binding pattern or object literal expression, barring those whose declarations + * do not occur at the current position and have not otherwise been typed. + */ function filterObjectMembersList(contextualMemberSymbols, existingMembers) { if (!existingMembers || existingMembers.length === 0) { return contextualMemberSymbols; @@ -42839,15 +42927,15 @@ var ts; } existingMemberNames[existingName] = true; } - var filteredMembers = []; - ts.forEach(contextualMemberSymbols, function (s) { - if (!existingMemberNames[s.name]) { - filteredMembers.push(s); - } - }); - return filteredMembers; + return ts.filter(contextualMemberSymbols, function (m) { return !ts.lookUp(existingMemberNames, m.name); }); } - function filterJsxAttributes(attributes, symbols) { + /** + * Filters out completion suggestions from 'symbols' according to existing JSX attributes. + * + * @returns Symbols to be suggested in a JSX element, barring those whose attributes + * do not occur at the current position and have not otherwise been typed. + */ + function filterJsxAttributes(symbols, attributes) { var seenNames = {}; for (var _i = 0; _i < attributes.length; _i++) { var attr = attributes[_i]; @@ -42859,14 +42947,7 @@ var ts; seenNames[attr.name.text] = true; } } - var result = []; - for (var _a = 0; _a < symbols.length; _a++) { - var sym = symbols[_a]; - if (!seenNames[sym.name]) { - result.push(sym); - } - } - return result; + return ts.filter(symbols, function (a) { return !ts.lookUp(seenNames, a.name); }); } } function getCompletionsAtPosition(fileName, position) { @@ -42899,10 +42980,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_31 in nameTable) { - if (!allNames[name_31]) { - allNames[name_31] = name_31; - var displayName = getCompletionEntryDisplayName(name_31, target, true); + for (var name_32 in nameTable) { + if (!allNames[name_32]) { + allNames[name_32] = name_32; + var displayName = getCompletionEntryDisplayName(name_32, target, true); if (displayName) { var entry = { name: displayName, @@ -43771,6 +43852,7 @@ var ts; if (hasKind(node.parent, 142 /* GetAccessor */) || hasKind(node.parent, 143 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } + break; default: if (ts.isModifier(node.kind) && node.parent && (ts.isDeclaration(node.parent) || node.parent.kind === 190 /* VariableStatement */)) { @@ -43886,12 +43968,13 @@ var ts; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { if (!(container.kind === 211 /* ClassDeclaration */ || + container.kind === 183 /* ClassExpression */ || (declaration.kind === 135 /* Parameter */ && hasKind(container, 141 /* Constructor */)))) { return undefined; } } else if (modifier === 110 /* StaticKeyword */) { - if (container.kind !== 211 /* ClassDeclaration */) { + if (!(container.kind === 211 /* ClassDeclaration */ || container.kind === 183 /* ClassExpression */)) { return undefined; } } @@ -43900,6 +43983,11 @@ var ts; return undefined; } } + else if (modifier === 112 /* AbstractKeyword */) { + if (!(container.kind === 211 /* ClassDeclaration */ || declaration.kind === 211 /* ClassDeclaration */)) { + return undefined; + } + } else { // unsupported modifier return undefined; @@ -43910,12 +43998,19 @@ var ts; switch (container.kind) { case 216 /* ModuleBlock */: case 245 /* SourceFile */: - nodes = container.statements; + // Container is either a class declaration or the declaration is a classDeclaration + if (modifierFlag & 256 /* Abstract */) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } break; case 141 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. @@ -43927,6 +44022,9 @@ var ts; nodes = nodes.concat(constructor.parameters); } } + else if (modifierFlag & 256 /* Abstract */) { + nodes = nodes.concat(container); + } break; default: ts.Debug.fail("Invalid container kind."); @@ -43951,6 +44049,8 @@ var ts; return 1 /* Export */; case 119 /* DeclareKeyword */: return 2 /* Ambient */; + case 112 /* AbstractKeyword */: + return 256 /* Abstract */; default: ts.Debug.fail(); } @@ -44768,19 +44868,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_32 = node.text; + var name_33 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_32); + var unionProperty = contextualType.getProperty(name_33); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_32); + var symbol = t.getProperty(name_33); if (symbol) { result_4.push(symbol); } @@ -44789,7 +44889,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_32); + var symbol_1 = contextualType.getProperty(name_33); if (symbol_1) { return [symbol_1]; } @@ -45471,7 +45571,7 @@ var ts; return; } } - return 9 /* text */; + return 2 /* identifier */; } } function processElement(element) { From 4c483e5517bc4ef57e46cbf9e204b1623c14d106 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 15 Jul 2015 16:32:02 -0700 Subject: [PATCH 31/41] Make tests intentionally expect wrong results until we do "smarter" things for object binding elements. --- .../findAllRefsObjectBindingElementPropertyName04.ts | 4 +++- .../findAllRefsObjectBindingElementPropertyName09.ts | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts index a72023a1028..bdb37525f71 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts @@ -6,12 +6,14 @@ ////} //// ////function f({ /**/[|property1|]: p1 }: I, -//// { [|property1|] }: I, +//// { /*SHOULD_BE_A_REFERENCE*/property1 }: I, //// { property1: p2 }) { //// //// return property1 + 1; ////} +// NOTE: In the future, the identifier at +// SHOULD_BE_A_REFERENCE should be in the set of ranges. goTo.marker(); let ranges = test.ranges(); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName09.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName09.ts index 0b82c73e31d..e45359bcf1c 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName09.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName09.ts @@ -1,17 +1,19 @@ /// ////interface I { -//// [|property1|]: number; +//// /*SHOULD_BE_A_REFERENCE1*/property1: number; //// property2: string; ////} //// -////function f({ [|property1|]: p1 }: I, +////function f({ /*SHOULD_BE_A_REFERENCE2*/property1: p1 }: I, //// { /**/[|property1|] }: I, //// { property1: p2 }) { //// //// return [|property1|] + 1; ////} +// NOTE: In the future, the identifiers at +// SHOULD_BE_A_REFERENCE[1/2] should be in the set of ranges. goTo.marker(); let ranges = test.ranges(); From 4cd7f079e3f1e1aac59c424d8090baefdfe2f1cb Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 15 Jul 2015 16:43:13 -0700 Subject: [PATCH 32/41] Move startIndex declaration to the top --- src/compiler/emitter.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 7b083ba7363..9c8438565e7 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4215,13 +4215,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } + let startIndex = 0; + write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). - var startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); From 61ca65f22fe4045536f35499e461f5c53582c39a Mon Sep 17 00:00:00 2001 From: Dirk Baeumer Date: Thu, 16 Jul 2015 10:40:06 +0200 Subject: [PATCH 33/41] Fixed #3887 tsserver drops responses --- src/server/session.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/server/session.ts b/src/server/session.ts index e0c540db18b..d2ac429aa3c 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -842,53 +842,53 @@ namespace ts.server { private handlers : Map<(request: protocol.Request) => {response?: any, responseRequired?: boolean}> = { [CommandNames.Exit]: () => { this.exit(); - return {}; + return { responseRequired: false}; }, [CommandNames.Definition]: (request: protocol.Request) => { var defArgs = request.arguments; - return {response: this.getDefinition(defArgs.line, defArgs.offset, defArgs.file)}; + return {response: this.getDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true}; }, [CommandNames.TypeDefinition]: (request: protocol.Request) => { var defArgs = request.arguments; - return {response: this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file)}; + return {response: this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true}; }, [CommandNames.References]: (request: protocol.Request) => { var defArgs = request.arguments; - return {response: this.getReferences(defArgs.line, defArgs.offset, defArgs.file)}; + return {response: this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true}; }, [CommandNames.Rename]: (request: protocol.Request) => { var renameArgs = request.arguments; - return {response: this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings)} + return {response: this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings), responseRequired: true} }, [CommandNames.Open]: (request: protocol.Request) => { var openArgs = request.arguments; this.openClientFile(openArgs.file); - return {} + return {responseRequired: false} }, [CommandNames.Quickinfo]: (request: protocol.Request) => { var quickinfoArgs = request.arguments; - return {response: this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file)}; + return {response: this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file), responseRequired: true}; }, [CommandNames.Format]: (request: protocol.Request) => { var formatArgs = request.arguments; - return {response: this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file)}; + return {response: this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file), responseRequired: true}; }, [CommandNames.Formatonkey]: (request: protocol.Request) => { var formatOnKeyArgs = request.arguments; - return {response: this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file)}; + return {response: this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file), responseRequired: true}; }, [CommandNames.Completions]: (request: protocol.Request) => { var completionsArgs = request.arguments; - return {response: this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file)} + return {response: this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true} }, [CommandNames.CompletionDetails]: (request: protocol.Request) => { var completionDetailsArgs = request.arguments; return {response: this.getCompletionEntryDetails(completionDetailsArgs.line,completionDetailsArgs.offset, - completionDetailsArgs.entryNames,completionDetailsArgs.file)} + completionDetailsArgs.entryNames,completionDetailsArgs.file), responseRequired: true} }, [CommandNames.SignatureHelp]: (request: protocol.Request) => { var signatureHelpArgs = request.arguments; - return {response: this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file)} + return {response: this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true} }, [CommandNames.Geterr]: (request: protocol.Request) => { var geterrArgs = request.arguments; @@ -923,23 +923,23 @@ namespace ts.server { }, [CommandNames.Navto]: (request: protocol.Request) => { var navtoArgs = request.arguments; - return {response: this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount)}; + return {response: this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount), responseRequired: true}; }, [CommandNames.Brace]: (request: protocol.Request) => { var braceArguments = request.arguments; - return {response: this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file)}; + return {response: this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file), responseRequired: true}; }, [CommandNames.NavBar]: (request: protocol.Request) => { var navBarArgs = request.arguments; - return {response: this.getNavigationBarItems(navBarArgs.file)}; + return {response: this.getNavigationBarItems(navBarArgs.file), responseRequired: true}; }, [CommandNames.Occurrences]: (request: protocol.Request) => { var { line, offset, file: fileName } = request.arguments; - return {response: this.getOccurrences(line, offset, fileName)}; + return {response: this.getOccurrences(line, offset, fileName), responseRequired: true}; }, [CommandNames.ProjectInfo]: (request: protocol.Request) => { var { file, needFileNameList } = request.arguments; - return {response: this.getProjectInfo(file, needFileNameList)}; + return {response: this.getProjectInfo(file, needFileNameList), responseRequired: true}; }, }; addProtocolHandler(command: string, handler: (request: protocol.Request) => {response?: any, responseRequired: boolean}) { From 9a9e00487f27834579b6276e53ce5eda760986ad Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 16 Jul 2015 16:34:07 -0700 Subject: [PATCH 34/41] Added tests. --- .../es6/destructuring/emptyAssignmentPatterns01_ES5.ts | 6 ++++++ .../es6/destructuring/emptyAssignmentPatterns01_ES6.ts | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts create mode 100644 tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts new file mode 100644 index 00000000000..dd10e552615 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts @@ -0,0 +1,6 @@ +// @target: es5 + +var a: any; + +({} = a); +([] = a); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts new file mode 100644 index 00000000000..043f0cf1108 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts @@ -0,0 +1,6 @@ +// @target: es6 + +var a: any; + +({} = a); +([] = a); \ No newline at end of file From 255fc65410128cb2f0fc8c21daa44e271ff5e6f4 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 16 Jul 2015 16:34:47 -0700 Subject: [PATCH 35/41] Tabs to spaces. --- .../es6/destructuring/emptyArrayBindingPatternParameter01.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts index 0dea1fe795c..64b198b0916 100644 --- a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts +++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts @@ -1,5 +1,5 @@ function f([]) { - var x, y, z; + var x, y, z; } \ No newline at end of file From 895535bd2232b25b0389854c2eee7eb058e9b294 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 16 Jul 2015 16:50:09 -0700 Subject: [PATCH 36/41] Accepted baselines. --- .../emptyArrayBindingPatternParameter01.js | 2 +- .../emptyArrayBindingPatternParameter01.symbols | 8 ++++---- .../emptyArrayBindingPatternParameter01.types | 2 +- .../reference/emptyAssignmentPatterns01_ES5.js | 11 +++++++++++ .../emptyAssignmentPatterns01_ES5.symbols | 11 +++++++++++ .../emptyAssignmentPatterns01_ES5.types | 17 +++++++++++++++++ .../reference/emptyAssignmentPatterns01_ES6.js | 11 +++++++++++ .../emptyAssignmentPatterns01_ES6.symbols | 11 +++++++++++ .../emptyAssignmentPatterns01_ES6.types | 17 +++++++++++++++++ 9 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/emptyAssignmentPatterns01_ES5.js create mode 100644 tests/baselines/reference/emptyAssignmentPatterns01_ES5.symbols create mode 100644 tests/baselines/reference/emptyAssignmentPatterns01_ES5.types create mode 100644 tests/baselines/reference/emptyAssignmentPatterns01_ES6.js create mode 100644 tests/baselines/reference/emptyAssignmentPatterns01_ES6.symbols create mode 100644 tests/baselines/reference/emptyAssignmentPatterns01_ES6.types diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter01.js b/tests/baselines/reference/emptyArrayBindingPatternParameter01.js index 05b59b7d5f2..5723c74f117 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter01.js +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter01.js @@ -2,7 +2,7 @@ function f([]) { - var x, y, z; + var x, y, z; } //// [emptyArrayBindingPatternParameter01.js] diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols index 3207ca97dec..f5089ce5850 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols @@ -4,8 +4,8 @@ function f([]) { >f : Symbol(f, Decl(emptyArrayBindingPatternParameter01.ts, 0, 0)) - var x, y, z; ->x : Symbol(x, Decl(emptyArrayBindingPatternParameter01.ts, 3, 4)) ->y : Symbol(y, Decl(emptyArrayBindingPatternParameter01.ts, 3, 7)) ->z : Symbol(z, Decl(emptyArrayBindingPatternParameter01.ts, 3, 10)) + var x, y, z; +>x : Symbol(x, Decl(emptyArrayBindingPatternParameter01.ts, 3, 7)) +>y : Symbol(y, Decl(emptyArrayBindingPatternParameter01.ts, 3, 10)) +>z : Symbol(z, Decl(emptyArrayBindingPatternParameter01.ts, 3, 13)) } diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter01.types b/tests/baselines/reference/emptyArrayBindingPatternParameter01.types index e93394b7371..7ef40d52d59 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter01.types +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter01.types @@ -4,7 +4,7 @@ function f([]) { >f : ([]: any[]) => void - var x, y, z; + var x, y, z; >x : any >y : any >z : any diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js new file mode 100644 index 00000000000..97f050ac2c6 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js @@ -0,0 +1,11 @@ +//// [emptyAssignmentPatterns01_ES5.ts] + +var a: any; + +({} = a); +([] = a); + +//// [emptyAssignmentPatterns01_ES5.js] +var a; +(, a); +(, a); diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES5.symbols b/tests/baselines/reference/emptyAssignmentPatterns01_ES5.symbols new file mode 100644 index 00000000000..97752a1358d --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES5.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts === + +var a: any; +>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES5.ts, 1, 3)) + +({} = a); +>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES5.ts, 1, 3)) + +([] = a); +>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES5.ts, 1, 3)) + diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES5.types b/tests/baselines/reference/emptyAssignmentPatterns01_ES5.types new file mode 100644 index 00000000000..cbc0a25b074 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES5.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts === + +var a: any; +>a : any + +({} = a); +>({} = a) : any +>{} = a : any +>{} : {} +>a : any + +([] = a); +>([] = a) : any +>[] = a : any +>[] : undefined[] +>a : any + diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES6.js b/tests/baselines/reference/emptyAssignmentPatterns01_ES6.js new file mode 100644 index 00000000000..fe311ac9061 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES6.js @@ -0,0 +1,11 @@ +//// [emptyAssignmentPatterns01_ES6.ts] + +var a: any; + +({} = a); +([] = a); + +//// [emptyAssignmentPatterns01_ES6.js] +var a; +({} = a); +([] = a); diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES6.symbols b/tests/baselines/reference/emptyAssignmentPatterns01_ES6.symbols new file mode 100644 index 00000000000..345bdd52265 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES6.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts === + +var a: any; +>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES6.ts, 1, 3)) + +({} = a); +>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES6.ts, 1, 3)) + +([] = a); +>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES6.ts, 1, 3)) + diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES6.types b/tests/baselines/reference/emptyAssignmentPatterns01_ES6.types new file mode 100644 index 00000000000..c22c0e72854 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES6.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts === + +var a: any; +>a : any + +({} = a); +>({} = a) : any +>{} = a : any +>{} : {} +>a : any + +([] = a); +>([] = a) : any +>[] = a : any +>[] : undefined[] +>a : any + From 987dc1f5d0fc23440bd27ace0c5d87175e5eb637 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 16 Jul 2015 17:23:43 -0700 Subject: [PATCH 37/41] Added tests. --- .../es6/destructuring/emptyAssignmentPatterns02_ES5.ts | 7 +++++++ .../es6/destructuring/emptyAssignmentPatterns02_ES6.ts | 7 +++++++ .../es6/destructuring/emptyAssignmentPatterns03_ES5.ts | 6 ++++++ .../es6/destructuring/emptyAssignmentPatterns03_ES6.ts | 6 ++++++ .../es6/destructuring/emptyAssignmentPatterns04_ES5.ts | 7 +++++++ .../es6/destructuring/emptyAssignmentPatterns04_ES6.ts | 7 +++++++ 6 files changed, 40 insertions(+) create mode 100644 tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts create mode 100644 tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts create mode 100644 tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts create mode 100644 tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts create mode 100644 tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts create mode 100644 tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts new file mode 100644 index 00000000000..60fe89758d6 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts @@ -0,0 +1,7 @@ +// @target: es5 + +var a: any; +let x, y, z, a1, a2, a3; + +({} = { x, y, z } = a); +([] = [ a1, a2, a3] = a); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts new file mode 100644 index 00000000000..295401545d4 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts @@ -0,0 +1,7 @@ +// @target: es6 + +var a: any; +let x, y, z, a1, a2, a3; + +({} = { x, y, z } = a); +([] = [ a1, a2, a3] = a); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts new file mode 100644 index 00000000000..080c828ad62 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts @@ -0,0 +1,6 @@ +// @target: es5 + +var a: any; + +({} = {} = a); +([] = [] = a); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts new file mode 100644 index 00000000000..10d67254cd8 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts @@ -0,0 +1,6 @@ +// @target: es6 + +var a: any; + +({} = {} = a); +([] = [] = a); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts new file mode 100644 index 00000000000..0233ddcda70 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts @@ -0,0 +1,7 @@ +// @target: es5 + +var a: any; +let x, y, z, a1, a2, a3; + +({ x, y, z } = {} = a); +([ a1, a2, a3] = [] = a); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts new file mode 100644 index 00000000000..3380a56aaa7 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts @@ -0,0 +1,7 @@ +// @target: es6 + +var a: any; +let x, y, z, a1, a2, a3; + +({ x, y, z } = {} = a); +([ a1, a2, a3] = [] = a); \ No newline at end of file From 0ec38b759004d6040cd0695f4148840832c71e21 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 16 Jul 2015 17:25:00 -0700 Subject: [PATCH 38/41] Accepted baselines. --- .../emptyAssignmentPatterns02_ES5.js | 14 ++++++++ .../emptyAssignmentPatterns02_ES5.symbols | 25 +++++++++++++ .../emptyAssignmentPatterns02_ES5.types | 35 +++++++++++++++++++ .../emptyAssignmentPatterns02_ES6.js | 13 +++++++ .../emptyAssignmentPatterns02_ES6.symbols | 25 +++++++++++++ .../emptyAssignmentPatterns02_ES6.types | 35 +++++++++++++++++++ .../emptyAssignmentPatterns03_ES5.js | 12 +++++++ .../emptyAssignmentPatterns03_ES5.symbols | 11 ++++++ .../emptyAssignmentPatterns03_ES5.types | 21 +++++++++++ .../emptyAssignmentPatterns03_ES6.js | 11 ++++++ .../emptyAssignmentPatterns03_ES6.symbols | 11 ++++++ .../emptyAssignmentPatterns03_ES6.types | 21 +++++++++++ .../emptyAssignmentPatterns04_ES5.js | 14 ++++++++ .../emptyAssignmentPatterns04_ES5.symbols | 25 +++++++++++++ .../emptyAssignmentPatterns04_ES5.types | 35 +++++++++++++++++++ .../emptyAssignmentPatterns04_ES6.js | 13 +++++++ .../emptyAssignmentPatterns04_ES6.symbols | 25 +++++++++++++ .../emptyAssignmentPatterns04_ES6.types | 35 +++++++++++++++++++ 18 files changed, 381 insertions(+) create mode 100644 tests/baselines/reference/emptyAssignmentPatterns02_ES5.js create mode 100644 tests/baselines/reference/emptyAssignmentPatterns02_ES5.symbols create mode 100644 tests/baselines/reference/emptyAssignmentPatterns02_ES5.types create mode 100644 tests/baselines/reference/emptyAssignmentPatterns02_ES6.js create mode 100644 tests/baselines/reference/emptyAssignmentPatterns02_ES6.symbols create mode 100644 tests/baselines/reference/emptyAssignmentPatterns02_ES6.types create mode 100644 tests/baselines/reference/emptyAssignmentPatterns03_ES5.js create mode 100644 tests/baselines/reference/emptyAssignmentPatterns03_ES5.symbols create mode 100644 tests/baselines/reference/emptyAssignmentPatterns03_ES5.types create mode 100644 tests/baselines/reference/emptyAssignmentPatterns03_ES6.js create mode 100644 tests/baselines/reference/emptyAssignmentPatterns03_ES6.symbols create mode 100644 tests/baselines/reference/emptyAssignmentPatterns03_ES6.types create mode 100644 tests/baselines/reference/emptyAssignmentPatterns04_ES5.js create mode 100644 tests/baselines/reference/emptyAssignmentPatterns04_ES5.symbols create mode 100644 tests/baselines/reference/emptyAssignmentPatterns04_ES5.types create mode 100644 tests/baselines/reference/emptyAssignmentPatterns04_ES6.js create mode 100644 tests/baselines/reference/emptyAssignmentPatterns04_ES6.symbols create mode 100644 tests/baselines/reference/emptyAssignmentPatterns04_ES6.types diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js new file mode 100644 index 00000000000..253d68c8779 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js @@ -0,0 +1,14 @@ +//// [emptyAssignmentPatterns02_ES5.ts] + +var a: any; +let x, y, z, a1, a2, a3; + +({} = { x, y, z } = a); +([] = [ a1, a2, a3] = a); + +//// [emptyAssignmentPatterns02_ES5.js] +var a; +var x, y, z, a1, a2, a3; +(_a = (x = a.x, y = a.y, z = a.z, a), _a); +(_b = (a1 = a[0], a2 = a[1], a3 = a[2], a), _b); +var _a, _b; diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES5.symbols b/tests/baselines/reference/emptyAssignmentPatterns02_ES5.symbols new file mode 100644 index 00000000000..a575ea35f24 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES5.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts === + +var a: any; +>a : Symbol(a, Decl(emptyAssignmentPatterns02_ES5.ts, 1, 3)) + +let x, y, z, a1, a2, a3; +>x : Symbol(x, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 3)) +>y : Symbol(y, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 6)) +>z : Symbol(z, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 9)) +>a1 : Symbol(a1, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 12)) +>a2 : Symbol(a2, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 16)) +>a3 : Symbol(a3, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 20)) + +({} = { x, y, z } = a); +>x : Symbol(x, Decl(emptyAssignmentPatterns02_ES5.ts, 4, 7)) +>y : Symbol(y, Decl(emptyAssignmentPatterns02_ES5.ts, 4, 10)) +>z : Symbol(z, Decl(emptyAssignmentPatterns02_ES5.ts, 4, 13)) +>a : Symbol(a, Decl(emptyAssignmentPatterns02_ES5.ts, 1, 3)) + +([] = [ a1, a2, a3] = a); +>a1 : Symbol(a1, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 12)) +>a2 : Symbol(a2, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 16)) +>a3 : Symbol(a3, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 20)) +>a : Symbol(a, Decl(emptyAssignmentPatterns02_ES5.ts, 1, 3)) + diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES5.types b/tests/baselines/reference/emptyAssignmentPatterns02_ES5.types new file mode 100644 index 00000000000..76897f8516e --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES5.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts === + +var a: any; +>a : any + +let x, y, z, a1, a2, a3; +>x : any +>y : any +>z : any +>a1 : any +>a2 : any +>a3 : any + +({} = { x, y, z } = a); +>({} = { x, y, z } = a) : any +>{} = { x, y, z } = a : any +>{} : {} +>{ x, y, z } = a : any +>{ x, y, z } : { x: any; y: any; z: any; } +>x : any +>y : any +>z : any +>a : any + +([] = [ a1, a2, a3] = a); +>([] = [ a1, a2, a3] = a) : any +>[] = [ a1, a2, a3] = a : any +>[] : undefined[] +>[ a1, a2, a3] = a : any +>[ a1, a2, a3] : [any, any, any] +>a1 : any +>a2 : any +>a3 : any +>a : any + diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES6.js b/tests/baselines/reference/emptyAssignmentPatterns02_ES6.js new file mode 100644 index 00000000000..e9783c7e57d --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES6.js @@ -0,0 +1,13 @@ +//// [emptyAssignmentPatterns02_ES6.ts] + +var a: any; +let x, y, z, a1, a2, a3; + +({} = { x, y, z } = a); +([] = [ a1, a2, a3] = a); + +//// [emptyAssignmentPatterns02_ES6.js] +var a; +let x, y, z, a1, a2, a3; +({} = { x, y, z } = a); +([] = [a1, a2, a3] = a); diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES6.symbols b/tests/baselines/reference/emptyAssignmentPatterns02_ES6.symbols new file mode 100644 index 00000000000..e55339cb658 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES6.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts === + +var a: any; +>a : Symbol(a, Decl(emptyAssignmentPatterns02_ES6.ts, 1, 3)) + +let x, y, z, a1, a2, a3; +>x : Symbol(x, Decl(emptyAssignmentPatterns02_ES6.ts, 2, 3)) +>y : Symbol(y, Decl(emptyAssignmentPatterns02_ES6.ts, 2, 6)) +>z : Symbol(z, Decl(emptyAssignmentPatterns02_ES6.ts, 2, 9)) +>a1 : Symbol(a1, Decl(emptyAssignmentPatterns02_ES6.ts, 2, 12)) +>a2 : Symbol(a2, Decl(emptyAssignmentPatterns02_ES6.ts, 2, 16)) +>a3 : Symbol(a3, Decl(emptyAssignmentPatterns02_ES6.ts, 2, 20)) + +({} = { x, y, z } = a); +>x : Symbol(x, Decl(emptyAssignmentPatterns02_ES6.ts, 4, 7)) +>y : Symbol(y, Decl(emptyAssignmentPatterns02_ES6.ts, 4, 10)) +>z : Symbol(z, Decl(emptyAssignmentPatterns02_ES6.ts, 4, 13)) +>a : Symbol(a, Decl(emptyAssignmentPatterns02_ES6.ts, 1, 3)) + +([] = [ a1, a2, a3] = a); +>a1 : Symbol(a1, Decl(emptyAssignmentPatterns02_ES6.ts, 2, 12)) +>a2 : Symbol(a2, Decl(emptyAssignmentPatterns02_ES6.ts, 2, 16)) +>a3 : Symbol(a3, Decl(emptyAssignmentPatterns02_ES6.ts, 2, 20)) +>a : Symbol(a, Decl(emptyAssignmentPatterns02_ES6.ts, 1, 3)) + diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES6.types b/tests/baselines/reference/emptyAssignmentPatterns02_ES6.types new file mode 100644 index 00000000000..48c9146e154 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES6.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts === + +var a: any; +>a : any + +let x, y, z, a1, a2, a3; +>x : any +>y : any +>z : any +>a1 : any +>a2 : any +>a3 : any + +({} = { x, y, z } = a); +>({} = { x, y, z } = a) : any +>{} = { x, y, z } = a : any +>{} : {} +>{ x, y, z } = a : any +>{ x, y, z } : { x: any; y: any; z: any; } +>x : any +>y : any +>z : any +>a : any + +([] = [ a1, a2, a3] = a); +>([] = [ a1, a2, a3] = a) : any +>[] = [ a1, a2, a3] = a : any +>[] : undefined[] +>[ a1, a2, a3] = a : any +>[ a1, a2, a3] : [any, any, any] +>a1 : any +>a2 : any +>a3 : any +>a : any + diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js new file mode 100644 index 00000000000..7c6d39eb0a2 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js @@ -0,0 +1,12 @@ +//// [emptyAssignmentPatterns03_ES5.ts] + +var a: any; + +({} = {} = a); +([] = [] = a); + +//// [emptyAssignmentPatterns03_ES5.js] +var a; +(_a = (, a), _a); +(_b = (, a), _b); +var _a, _b; diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES5.symbols b/tests/baselines/reference/emptyAssignmentPatterns03_ES5.symbols new file mode 100644 index 00000000000..c57365bc7d0 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES5.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts === + +var a: any; +>a : Symbol(a, Decl(emptyAssignmentPatterns03_ES5.ts, 1, 3)) + +({} = {} = a); +>a : Symbol(a, Decl(emptyAssignmentPatterns03_ES5.ts, 1, 3)) + +([] = [] = a); +>a : Symbol(a, Decl(emptyAssignmentPatterns03_ES5.ts, 1, 3)) + diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES5.types b/tests/baselines/reference/emptyAssignmentPatterns03_ES5.types new file mode 100644 index 00000000000..4f32b0555ef --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES5.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts === + +var a: any; +>a : any + +({} = {} = a); +>({} = {} = a) : any +>{} = {} = a : any +>{} : {} +>{} = a : any +>{} : {} +>a : any + +([] = [] = a); +>([] = [] = a) : any +>[] = [] = a : any +>[] : undefined[] +>[] = a : any +>[] : undefined[] +>a : any + diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES6.js b/tests/baselines/reference/emptyAssignmentPatterns03_ES6.js new file mode 100644 index 00000000000..95bfdfefa52 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES6.js @@ -0,0 +1,11 @@ +//// [emptyAssignmentPatterns03_ES6.ts] + +var a: any; + +({} = {} = a); +([] = [] = a); + +//// [emptyAssignmentPatterns03_ES6.js] +var a; +({} = {} = a); +([] = [] = a); diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES6.symbols b/tests/baselines/reference/emptyAssignmentPatterns03_ES6.symbols new file mode 100644 index 00000000000..3e32848207a --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES6.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts === + +var a: any; +>a : Symbol(a, Decl(emptyAssignmentPatterns03_ES6.ts, 1, 3)) + +({} = {} = a); +>a : Symbol(a, Decl(emptyAssignmentPatterns03_ES6.ts, 1, 3)) + +([] = [] = a); +>a : Symbol(a, Decl(emptyAssignmentPatterns03_ES6.ts, 1, 3)) + diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES6.types b/tests/baselines/reference/emptyAssignmentPatterns03_ES6.types new file mode 100644 index 00000000000..1f1d005aac5 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES6.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts === + +var a: any; +>a : any + +({} = {} = a); +>({} = {} = a) : any +>{} = {} = a : any +>{} : {} +>{} = a : any +>{} : {} +>a : any + +([] = [] = a); +>([] = [] = a) : any +>[] = [] = a : any +>[] : undefined[] +>[] = a : any +>[] : undefined[] +>a : any + diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js new file mode 100644 index 00000000000..10b024352f4 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js @@ -0,0 +1,14 @@ +//// [emptyAssignmentPatterns04_ES5.ts] + +var a: any; +let x, y, z, a1, a2, a3; + +({ x, y, z } = {} = a); +([ a1, a2, a3] = [] = a); + +//// [emptyAssignmentPatterns04_ES5.js] +var a; +var x, y, z, a1, a2, a3; +(_a = (, a), x = _a.x, y = _a.y, z = _a.z, _a); +(_b = (, a), a1 = _b[0], a2 = _b[1], a3 = _b[2], _b); +var _a, _b; diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES5.symbols b/tests/baselines/reference/emptyAssignmentPatterns04_ES5.symbols new file mode 100644 index 00000000000..20ea8c037c3 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES5.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts === + +var a: any; +>a : Symbol(a, Decl(emptyAssignmentPatterns04_ES5.ts, 1, 3)) + +let x, y, z, a1, a2, a3; +>x : Symbol(x, Decl(emptyAssignmentPatterns04_ES5.ts, 2, 3)) +>y : Symbol(y, Decl(emptyAssignmentPatterns04_ES5.ts, 2, 6)) +>z : Symbol(z, Decl(emptyAssignmentPatterns04_ES5.ts, 2, 9)) +>a1 : Symbol(a1, Decl(emptyAssignmentPatterns04_ES5.ts, 2, 12)) +>a2 : Symbol(a2, Decl(emptyAssignmentPatterns04_ES5.ts, 2, 16)) +>a3 : Symbol(a3, Decl(emptyAssignmentPatterns04_ES5.ts, 2, 20)) + +({ x, y, z } = {} = a); +>x : Symbol(x, Decl(emptyAssignmentPatterns04_ES5.ts, 4, 2)) +>y : Symbol(y, Decl(emptyAssignmentPatterns04_ES5.ts, 4, 5)) +>z : Symbol(z, Decl(emptyAssignmentPatterns04_ES5.ts, 4, 8)) +>a : Symbol(a, Decl(emptyAssignmentPatterns04_ES5.ts, 1, 3)) + +([ a1, a2, a3] = [] = a); +>a1 : Symbol(a1, Decl(emptyAssignmentPatterns04_ES5.ts, 2, 12)) +>a2 : Symbol(a2, Decl(emptyAssignmentPatterns04_ES5.ts, 2, 16)) +>a3 : Symbol(a3, Decl(emptyAssignmentPatterns04_ES5.ts, 2, 20)) +>a : Symbol(a, Decl(emptyAssignmentPatterns04_ES5.ts, 1, 3)) + diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES5.types b/tests/baselines/reference/emptyAssignmentPatterns04_ES5.types new file mode 100644 index 00000000000..5ae2f0674fa --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES5.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts === + +var a: any; +>a : any + +let x, y, z, a1, a2, a3; +>x : any +>y : any +>z : any +>a1 : any +>a2 : any +>a3 : any + +({ x, y, z } = {} = a); +>({ x, y, z } = {} = a) : any +>{ x, y, z } = {} = a : any +>{ x, y, z } : { x: any; y: any; z: any; } +>x : any +>y : any +>z : any +>{} = a : any +>{} : {} +>a : any + +([ a1, a2, a3] = [] = a); +>([ a1, a2, a3] = [] = a) : any +>[ a1, a2, a3] = [] = a : any +>[ a1, a2, a3] : [any, any, any] +>a1 : any +>a2 : any +>a3 : any +>[] = a : any +>[] : undefined[] +>a : any + diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES6.js b/tests/baselines/reference/emptyAssignmentPatterns04_ES6.js new file mode 100644 index 00000000000..eabc2678c05 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES6.js @@ -0,0 +1,13 @@ +//// [emptyAssignmentPatterns04_ES6.ts] + +var a: any; +let x, y, z, a1, a2, a3; + +({ x, y, z } = {} = a); +([ a1, a2, a3] = [] = a); + +//// [emptyAssignmentPatterns04_ES6.js] +var a; +let x, y, z, a1, a2, a3; +({ x, y, z } = {} = a); +([a1, a2, a3] = [] = a); diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES6.symbols b/tests/baselines/reference/emptyAssignmentPatterns04_ES6.symbols new file mode 100644 index 00000000000..ee793cd3187 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES6.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts === + +var a: any; +>a : Symbol(a, Decl(emptyAssignmentPatterns04_ES6.ts, 1, 3)) + +let x, y, z, a1, a2, a3; +>x : Symbol(x, Decl(emptyAssignmentPatterns04_ES6.ts, 2, 3)) +>y : Symbol(y, Decl(emptyAssignmentPatterns04_ES6.ts, 2, 6)) +>z : Symbol(z, Decl(emptyAssignmentPatterns04_ES6.ts, 2, 9)) +>a1 : Symbol(a1, Decl(emptyAssignmentPatterns04_ES6.ts, 2, 12)) +>a2 : Symbol(a2, Decl(emptyAssignmentPatterns04_ES6.ts, 2, 16)) +>a3 : Symbol(a3, Decl(emptyAssignmentPatterns04_ES6.ts, 2, 20)) + +({ x, y, z } = {} = a); +>x : Symbol(x, Decl(emptyAssignmentPatterns04_ES6.ts, 4, 2)) +>y : Symbol(y, Decl(emptyAssignmentPatterns04_ES6.ts, 4, 5)) +>z : Symbol(z, Decl(emptyAssignmentPatterns04_ES6.ts, 4, 8)) +>a : Symbol(a, Decl(emptyAssignmentPatterns04_ES6.ts, 1, 3)) + +([ a1, a2, a3] = [] = a); +>a1 : Symbol(a1, Decl(emptyAssignmentPatterns04_ES6.ts, 2, 12)) +>a2 : Symbol(a2, Decl(emptyAssignmentPatterns04_ES6.ts, 2, 16)) +>a3 : Symbol(a3, Decl(emptyAssignmentPatterns04_ES6.ts, 2, 20)) +>a : Symbol(a, Decl(emptyAssignmentPatterns04_ES6.ts, 1, 3)) + diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES6.types b/tests/baselines/reference/emptyAssignmentPatterns04_ES6.types new file mode 100644 index 00000000000..6bd85593748 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES6.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts === + +var a: any; +>a : any + +let x, y, z, a1, a2, a3; +>x : any +>y : any +>z : any +>a1 : any +>a2 : any +>a3 : any + +({ x, y, z } = {} = a); +>({ x, y, z } = {} = a) : any +>{ x, y, z } = {} = a : any +>{ x, y, z } : { x: any; y: any; z: any; } +>x : any +>y : any +>z : any +>{} = a : any +>{} : {} +>a : any + +([ a1, a2, a3] = [] = a); +>([ a1, a2, a3] = [] = a) : any +>[ a1, a2, a3] = [] = a : any +>[ a1, a2, a3] : [any, any, any] +>a1 : any +>a2 : any +>a3 : any +>[] = a : any +>[] : undefined[] +>a : any + From 0bdc79fbb8dc6eced088b795ca4fb16c93ac2c15 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 16 Jul 2015 17:40:07 -0700 Subject: [PATCH 39/41] Only emit the RHS in an empty assignment pattern. --- src/compiler/emitter.ts | 6 +++++- src/compiler/utilities.ts | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 9c8438565e7..2c235f9fdca 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3249,7 +3249,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitAssignmentExpression(root: BinaryExpression) { let target = root.left; let value = root.right; - if (isAssignmentExpressionStatement) { + + if (isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index df3f1c9f174..9d7877ca6e3 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1981,6 +1981,17 @@ namespace ts { (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node); } + export function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean { + let kind = expression.kind; + if (kind === SyntaxKind.ObjectLiteralExpression) { + return (expression).properties.length === 0; + } + if (kind === SyntaxKind.ArrayLiteralExpression) { + return (expression).elements.length === 0; + } + return false; + } + export function getLocalSymbolForExportDefault(symbol: Symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined; } From 521d83a934f09af859d1942366ff849311287438 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 16 Jul 2015 17:40:53 -0700 Subject: [PATCH 40/41] Accepted baselines. --- tests/baselines/reference/emptyAssignmentPatterns01_ES5.js | 4 ++-- tests/baselines/reference/emptyAssignmentPatterns02_ES5.js | 5 ++--- tests/baselines/reference/emptyAssignmentPatterns03_ES5.js | 5 ++--- tests/baselines/reference/emptyAssignmentPatterns04_ES5.js | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js index 97f050ac2c6..b89db88e5e5 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js +++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js @@ -7,5 +7,5 @@ var a: any; //// [emptyAssignmentPatterns01_ES5.js] var a; -(, a); -(, a); +(a); +(a); diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js index 253d68c8779..7b9f1f402f9 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js @@ -9,6 +9,5 @@ let x, y, z, a1, a2, a3; //// [emptyAssignmentPatterns02_ES5.js] var a; var x, y, z, a1, a2, a3; -(_a = (x = a.x, y = a.y, z = a.z, a), _a); -(_b = (a1 = a[0], a2 = a[1], a3 = a[2], a), _b); -var _a, _b; +((x = a.x, y = a.y, z = a.z, a)); +((a1 = a[0], a2 = a[1], a3 = a[2], a)); diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js index 7c6d39eb0a2..d9ff8ba9ede 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js +++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js @@ -7,6 +7,5 @@ var a: any; //// [emptyAssignmentPatterns03_ES5.js] var a; -(_a = (, a), _a); -(_b = (, a), _b); -var _a, _b; +(a); +(a); diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js index 10b024352f4..7e342d08e39 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js @@ -9,6 +9,6 @@ let x, y, z, a1, a2, a3; //// [emptyAssignmentPatterns04_ES5.js] var a; var x, y, z, a1, a2, a3; -(_a = (, a), x = _a.x, y = _a.y, z = _a.z, _a); -(_b = (, a), a1 = _b[0], a2 = _b[1], a3 = _b[2], _b); +(_a = a, x = _a.x, y = _a.y, z = _a.z, _a); +(_b = a, a1 = _b[0], a2 = _b[1], a3 = _b[2], _b); var _a, _b; From 65a9713d800f1e9e5651a492e8465eef91838fa4 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 16 Jul 2015 18:26:46 -0700 Subject: [PATCH 41/41] Fix reading rwc file --- src/harness/rwcRunner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index bbe80abc887..54aeff18efd 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -123,7 +123,7 @@ module RWC { content = ts.sys.readFile(unitName); } catch (e) { - // Leave content undefined. + content = ts.sys.readFile(fileName); } return { unitName, content }; }