(node)
| 85339 | } |
| 85340 | } |
| 85341 | function checkExportDeclaration(node) { |
| 85342 | if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) { |
| 85343 | // If we hit an export in an illegal context, just bail out to avoid cascading errors. |
| 85344 | return; |
| 85345 | } |
| 85346 | if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) { |
| 85347 | grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); |
| 85348 | } |
| 85349 | if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ScriptTarget.ES3 */) { |
| 85350 | checkExternalEmitHelpers(node, 4194304 /* ExternalEmitHelpers.CreateBinding */); |
| 85351 | } |
| 85352 | checkGrammarExportDeclaration(node); |
| 85353 | if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { |
| 85354 | if (node.exportClause && !ts.isNamespaceExport(node.exportClause)) { |
| 85355 | // export { x, y } |
| 85356 | // export { x, y } from "foo" |
| 85357 | ts.forEach(node.exportClause.elements, checkExportSpecifier); |
| 85358 | var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); |
| 85359 | var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && |
| 85360 | !node.moduleSpecifier && node.flags & 16777216 /* NodeFlags.Ambient */; |
| 85361 | if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { |
| 85362 | error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); |
| 85363 | } |
| 85364 | } |
| 85365 | else { |
| 85366 | // export * from "foo" |
| 85367 | // export * as ns from "foo"; |
| 85368 | var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); |
| 85369 | if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) { |
| 85370 | error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); |
| 85371 | } |
| 85372 | else if (node.exportClause) { |
| 85373 | checkAliasSymbol(node.exportClause); |
| 85374 | } |
| 85375 | if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { |
| 85376 | if (node.exportClause) { |
| 85377 | // export * as ns from "foo"; |
| 85378 | // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. |
| 85379 | // We only use the helper here when in esModuleInterop |
| 85380 | if (ts.getESModuleInterop(compilerOptions)) { |
| 85381 | checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); |
| 85382 | } |
| 85383 | } |
| 85384 | else { |
| 85385 | // export * from "foo" |
| 85386 | checkExternalEmitHelpers(node, 32768 /* ExternalEmitHelpers.ExportStar */); |
| 85387 | } |
| 85388 | } |
| 85389 | } |
| 85390 | } |
| 85391 | checkAssertClause(node); |
| 85392 | } |
| 85393 | function checkGrammarExportDeclaration(node) { |
| 85394 | var _a; |
| 85395 | if (node.isTypeOnly) { |
no test coverage detected