mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-10 06:41:59 -06:00
Merge pull request #9194 from Microsoft/port8369
Port 8369: Support module.exports.name = expr format for JavaScript m…
This commit is contained in:
commit
4e739fbeca
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
13
tests/cases/fourslash/javascriptModules25.ts
Normal file
13
tests/cases/fourslash/javascriptModules25.ts
Normal 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');
|
||||
Loading…
x
Reference in New Issue
Block a user