Merge pull request #9194 from Microsoft/port8369

Port 8369: Support module.exports.name = expr format for JavaScript m…
This commit is contained in:
Paul van Brenk 2016-06-15 13:49:57 -07:00 committed by GitHub
commit 4e739fbeca
2 changed files with 22 additions and 2 deletions

View File

@ -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 = <PropertyAccessExpression>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 = <Identifier>innerPropertyAccess.expression;
if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") {
return SpecialPropertyAssignmentKind.ExportsProperty;
}
if (innerPropertyAccess.name.text === "prototype") {
return SpecialPropertyAssignmentKind.PrototypeProperty;
}
}
}

View File

@ -0,0 +1,13 @@
/// <reference path='fourslash.ts'/>
// @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');