MCPcopy Create free account
hub / github.com/microsoft/typescript-go / checkExportSpecifier

Method checkExportSpecifier

internal/checker/checker.go:5534–5556  ·  view source on GitHub ↗
(node *ast.ExportSpecifierNode)

Source from the content-addressed store, hash-verified

5532}
5533
5534func (c *Checker) checkExportSpecifier(node *ast.ExportSpecifierNode) {
5535 c.checkAliasSymbol(node)
5536 hasModuleSpecifier := node.Parent.Parent.ModuleSpecifier() != nil
5537 c.checkModuleExportName(node.PropertyName(), hasModuleSpecifier)
5538 c.checkModuleExportName(node.Name(), true /*allowStringLiteral*/)
5539
5540 if !hasModuleSpecifier {
5541 exportedName := node.PropertyNameOrName()
5542 if exportedName.Kind == ast.KindStringLiteral {
5543 return // Skip for invalid syntax like this: export { "x" }
5544 }
5545 // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases)
5546 symbol := c.resolveName(exportedName, exportedName.Text(), ast.SymbolFlagsValue|ast.SymbolFlagsType|ast.SymbolFlagsNamespace|ast.SymbolFlagsAlias, nil /*nameNotFoundMessage*/, true /*isUse*/, false)
5547 if symbol != nil && (symbol == c.undefinedSymbol || symbol == c.globalThisSymbol || symbol.Declarations != nil && ast.IsGlobalSourceFile(ast.GetDeclarationContainer(symbol.Declarations[0]))) {
5548 c.error(exportedName, diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, exportedName.Text())
5549 } else {
5550 c.markLinkedReferences(node, ReferenceHintExportSpecifier, nil /*propSymbol*/, nil /*parentType*/)
5551 }
5552 } else if c.program.GetEmitModuleFormatOfFile(ast.GetSourceFileOfNode(node)) == core.ModuleKindCommonJS &&
5553 ast.ModuleExportNameIsDefault(node.PropertyNameOrName()) {
5554 c.checkExternalEmitHelpers(node, ExternalEmitHelpersImportDefault)
5555 }
5556}
5557
5558func (c *Checker) checkExportAssignment(node *ast.Node) {
5559 isExportEquals := node.AsExportAssignment().IsExportEquals

Callers 1

Calls 15

checkAliasSymbolMethod · 0.95
checkModuleExportNameMethod · 0.95
resolveNameMethod · 0.95
errorMethod · 0.95
markLinkedReferencesMethod · 0.95
IsGlobalSourceFileFunction · 0.92
GetDeclarationContainerFunction · 0.92
GetSourceFileOfNodeFunction · 0.92
ModuleSpecifierMethod · 0.80
PropertyNameMethod · 0.80

Tested by

no test coverage detected