mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 20:25:23 -06:00
Do not emit ES6 import/export inside namespaces
ES6 imports and exports are illegal inside namespaces. In order to emit syntactically legal code, skip emit for these incorrect statements.
This commit is contained in:
parent
1e49a57a8d
commit
2cb7401a56
@ -157,7 +157,15 @@ namespace ts {
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function namespaceElementVisitorWorker(node: Node): VisitResult<Node> {
|
||||
if (node.transformFlags & TransformFlags.TypeScript || hasModifier(node, ModifierFlags.Export)) {
|
||||
if (node.kind === SyntaxKind.ExportDeclaration ||
|
||||
node.kind === SyntaxKind.ImportDeclaration ||
|
||||
node.kind === SyntaxKind.ImportClause ||
|
||||
(node.kind === SyntaxKind.ImportEqualsDeclaration &&
|
||||
(<ImportEqualsDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference)) {
|
||||
// do not emit ES6 imports and exports since they are illegal inside a namespace
|
||||
return createNotEmittedStatement(node);
|
||||
}
|
||||
else if (node.transformFlags & TransformFlags.TypeScript || hasModifier(node, ModifierFlags.Export)) {
|
||||
// This node is explicitly marked as TypeScript, or is exported at the namespace
|
||||
// level, so we should transform the node.
|
||||
return visitTypeScript(node);
|
||||
@ -2903,4 +2911,4 @@ namespace ts {
|
||||
&& resolver.getNodeCheckFlags(getOriginalNode(currentSuperContainer)) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user