mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-27 04:46:25 -05:00
Disallow export declarations in internal modules
This commit is contained in:
@@ -10236,6 +10236,11 @@ module ts {
|
||||
// export { x, y }
|
||||
// export { x, y } from "foo"
|
||||
forEach(node.exportClause.elements, checkExportSpecifier);
|
||||
|
||||
let inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && (<ModuleDeclaration>node.parent.parent).name.kind === SyntaxKind.StringLiteral;
|
||||
if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule) {
|
||||
error(node, Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// export * from "foo"
|
||||
|
||||
@@ -3838,35 +3838,7 @@ module ts {
|
||||
}
|
||||
|
||||
function emitExportDeclaration(node: ExportDeclaration) {
|
||||
if (node.parent.kind !== SyntaxKind.SourceFile) {
|
||||
// internal module
|
||||
if (node.exportClause) {
|
||||
// export { x, y, ... }
|
||||
for (let specifier of node.exportClause.elements) {
|
||||
if (resolver.isValueAliasDeclaration(specifier)) {
|
||||
writeLine();
|
||||
emitStart(specifier);
|
||||
emitContainingModuleName(specifier);
|
||||
write(".");
|
||||
emitNodeWithoutSourceMap(specifier.name);
|
||||
write(" = ");
|
||||
|
||||
var name = specifier.propertyName || specifier.name;
|
||||
var generatedName = getGeneratedNameForIdentifier(name);
|
||||
if (generatedName) {
|
||||
write(generatedName);
|
||||
}
|
||||
else {
|
||||
emitExpressionIdentifier(name);
|
||||
}
|
||||
|
||||
write(";");
|
||||
emitEnd(specifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (languageVersion < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) {
|
||||
emitStart(node);
|
||||
let generatedName = resolver.getGeneratedNameForNode(node);
|
||||
|
||||
Reference in New Issue
Block a user