Support module.exports.name = expr format

This commit is contained in:
zhengbli committed 2016-04-29 00:41:38 -07:00
1 parent 91201211f4
commit 42c94885d6
2 files changed
+22 -2

No files matched your search

+9 -2
View File
@@ -1240,8 +1240,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;
}
}
}
@@ -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');