From f4f9d899fd09823d358628cd17df0db788064b8b Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Wed, 15 Jun 2016 11:54:39 -0700 Subject: [PATCH 1/2] Port 8369: Support module.exports.name = expr format for JavaScript module --- src/compiler/utilities.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9d1aa877cf0..929fedb0c58 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1135,8 +1135,15 @@ namespace ts { else if (lhs.expression.kind === SyntaxKind.PropertyAccessExpression) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part const innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === SyntaxKind.Identifier && innerPropertyAccess.name.text === "prototype") { - return SpecialPropertyAssignmentKind.PrototypeProperty; + if (innerPropertyAccess.expression.kind === SyntaxKind.Identifier) { + // module.exports.name = expr + const innerPropertyAccessIdentifier = innerPropertyAccess.expression; + if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { + return SpecialPropertyAssignmentKind.ExportsProperty; + } + if (innerPropertyAccess.name.text === "prototype") { + return SpecialPropertyAssignmentKind.PrototypeProperty; + } } } From 00a642b84c7ea19a054d8b4202ab36569abf3bb8 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Wed, 15 Jun 2016 12:07:12 -0700 Subject: [PATCH 2/2] Add testcase --- tests/cases/fourslash/javascriptModules25.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/cases/fourslash/javascriptModules25.ts diff --git a/tests/cases/fourslash/javascriptModules25.ts b/tests/cases/fourslash/javascriptModules25.ts new file mode 100644 index 00000000000..e20a957bdc5 --- /dev/null +++ b/tests/cases/fourslash/javascriptModules25.ts @@ -0,0 +1,13 @@ +/// +// @allowJs: true + +// @Filename: mod.js +//// function foo() { return {a: true}; } +//// module.exports.a = foo; + +// @Filename: app.js +//// import * as mod from "./mod" +//// mod./**/ + +goTo.marker(); +verify.completionListContains('a'); \ No newline at end of file