(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList)
| 2542 | } |
| 2543 | |
| 2544 | func (p *Parser) parseExportDeclaration(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList) *ast.Node { |
| 2545 | saveContextFlags := p.contextFlags |
| 2546 | saveHasAwaitIdentifier := p.statementHasAwaitIdentifier |
| 2547 | p.setContextFlags(ast.NodeFlagsAwaitContext, true) |
| 2548 | var exportClause *ast.Node |
| 2549 | var moduleSpecifier *ast.Expression |
| 2550 | var attributes *ast.Node |
| 2551 | isTypeOnly := p.parseOptional(ast.KindTypeKeyword) |
| 2552 | namespaceExportPos := p.nodePos() |
| 2553 | if p.parseOptional(ast.KindAsteriskToken) { |
| 2554 | if p.parseOptional(ast.KindAsKeyword) { |
| 2555 | exportClause = p.parseNamespaceExport(namespaceExportPos) |
| 2556 | } |
| 2557 | p.parseExpected(ast.KindFromKeyword) |
| 2558 | moduleSpecifier = p.parseModuleSpecifier() |
| 2559 | } else { |
| 2560 | exportClause = p.parseNamedExports() |
| 2561 | // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, |
| 2562 | // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) |
| 2563 | // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. |
| 2564 | if p.token == ast.KindFromKeyword || (p.token == ast.KindStringLiteral && !p.hasPrecedingLineBreak()) { |
| 2565 | p.parseExpected(ast.KindFromKeyword) |
| 2566 | moduleSpecifier = p.parseModuleSpecifier() |
| 2567 | } |
| 2568 | } |
| 2569 | if moduleSpecifier != nil && (p.token == ast.KindWithKeyword || p.token == ast.KindAssertKeyword) && !p.hasPrecedingLineBreak() { |
| 2570 | if p.token == ast.KindAssertKeyword { |
| 2571 | p.parseErrorAtCurrentToken(diagnostics.Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_assert) |
| 2572 | } |
| 2573 | attributes = p.parseImportAttributes(p.token, false /*skipKeyword*/) |
| 2574 | } |
| 2575 | p.parseSemicolon() |
| 2576 | p.contextFlags = saveContextFlags |
| 2577 | p.statementHasAwaitIdentifier = saveHasAwaitIdentifier |
| 2578 | result := p.finishNode(p.factory.NewExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, attributes), pos) |
| 2579 | p.withJSDoc(result, jsdoc) |
| 2580 | p.checkJSSyntax(result) |
| 2581 | return result |
| 2582 | } |
| 2583 | |
| 2584 | func (p *Parser) parseNamespaceExport(pos int) *ast.Node { |
| 2585 | exportName, _ := p.parseModuleExportName(false /*disallowKeywords*/) |
no test coverage detected