Correct the external module check to determine if declaration is part of export assignment

This commit is contained in:
Sheetal Nandi 2014-07-11 15:31:06 -07:00
parent bb7f7fb8dd
commit d1cdf03d53
3 changed files with 12 additions and 2 deletions

View File

@ -1891,7 +1891,10 @@ module ts {
}
// If this node is in external module, check if this is export assigned
if (getContainerOfModuleElementDeclaration(node).flags & NodeFlags.ExternalModule) {
var moduleDeclaration = getContainerOfModuleElementDeclaration(node);
if ((moduleDeclaration.flags & NodeFlags.ExternalModule) || // Source file with external module flag
// Ambient external module declaration
(moduleDeclaration.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>moduleDeclaration).name.kind === SyntaxKind.StringLiteral)) {
return resolver.isReferencedInExportAssignment(node);
}
@ -2083,6 +2086,7 @@ module ts {
}
function emitVariableDeclaration(node: VariableDeclaration) {
// If we are emitting property it isnt moduleElement and doesnt need canEmitModuleElement check
if (node.kind !== SyntaxKind.VariableDeclaration || canEmitModuleElementDeclaration(node)) {
emitSourceTextOfNode(node.name);
// If optional property emit ?

View File

@ -275,7 +275,8 @@ module ts {
export function getContainerOfModuleElementDeclaration(node: Declaration) {
// If the declaration is var declaration, then the parent is variable statement but we actually want the module
return node.kind === SyntaxKind.VariableDeclaration ? node.parent.parent : node.parent;
var container = node.kind === SyntaxKind.VariableDeclaration ? node.parent.parent : node.parent;
return container.kind == SyntaxKind.ModuleBlock ? container.parent : container;
}
enum ParsingContext {

View File

@ -35,6 +35,11 @@ module.exports = MainModule;
//// [missingImportAfterModuleImport_0.d.ts]
declare module "SubModule" {
class SubModule {
static StaticVar;
InstanceVar;
constructor ();
}
export = SubModule;
}
//// [missingImportAfterModuleImport_1.d.ts]