(node *ast.Node, specifier *ast.Node, dontResolveAlias bool)
| 14591 | } |
| 14592 | |
| 14593 | func (c *Checker) getExternalModuleMember(node *ast.Node, specifier *ast.Node, dontResolveAlias bool) *ast.Symbol { |
| 14594 | // node is ImportDeclaration | ExportDeclaration | VariableDeclaration |
| 14595 | // specifier is ImportSpecifier | ExportSpecifier | BindingElement | PropertyAccessExpression |
| 14596 | moduleSpecifier := getExternalModuleRequireArgument(node) |
| 14597 | if moduleSpecifier == nil { |
| 14598 | moduleSpecifier = ast.GetExternalModuleName(node) |
| 14599 | } |
| 14600 | moduleSymbol := c.resolveExternalModuleName(node, moduleSpecifier, false /*ignoreErrors*/) |
| 14601 | var name *ast.Node |
| 14602 | if !ast.IsPropertyAccessExpression(specifier) { |
| 14603 | name = specifier.PropertyNameOrName() |
| 14604 | } else { |
| 14605 | name = specifier.Name() |
| 14606 | } |
| 14607 | if !ast.IsIdentifier(name) && !ast.IsStringLiteral(name) { |
| 14608 | return nil |
| 14609 | } |
| 14610 | nameText := name.Text() |
| 14611 | targetSymbol := c.resolveESModuleSymbol(moduleSymbol, specifier, moduleSpecifier) |
| 14612 | if targetSymbol != nil { |
| 14613 | // Note: The empty string is a valid module export name: |
| 14614 | // |
| 14615 | // import { "" as foo } from "./foo"; |
| 14616 | // export { foo as "" }; |
| 14617 | // |
| 14618 | if nameText != "" || name.Kind == ast.KindStringLiteral { |
| 14619 | if isShorthandAmbientModuleSymbol(moduleSymbol) { |
| 14620 | return moduleSymbol |
| 14621 | } |
| 14622 | var symbolFromVariable *ast.Symbol |
| 14623 | // First check if module was specified with "export=". If so, get the member from the resolved type |
| 14624 | if moduleSymbol != nil && moduleSymbol.Exports[ast.InternalSymbolNameExportEquals] != nil { |
| 14625 | symbolFromVariable = c.getPropertyOfTypeEx(c.getTypeOfSymbol(targetSymbol), nameText, true /*skipObjectFunctionPropertyAugment*/, false /*includeTypeOnlyMembers*/) |
| 14626 | } else { |
| 14627 | symbolFromVariable = c.getPropertyOfVariable(targetSymbol, nameText) |
| 14628 | } |
| 14629 | // if symbolFromVariable is export - get its final target |
| 14630 | symbolFromVariable = c.resolveSymbolEx(symbolFromVariable, dontResolveAlias) |
| 14631 | exportContainer := targetSymbol |
| 14632 | if moduleSymbol != nil && moduleSymbol.Exports[ast.InternalSymbolNameExportEquals] != nil { |
| 14633 | // For `export =` modules, supplemental type/namespace exports live on the original module symbol. |
| 14634 | exportContainer = moduleSymbol |
| 14635 | } |
| 14636 | symbolFromModule := c.getExportOfModule(exportContainer, nameText, specifier, dontResolveAlias) |
| 14637 | if symbolFromModule == nil && nameText == ast.InternalSymbolNameDefault { |
| 14638 | file := core.Find(moduleSymbol.Declarations, ast.IsSourceFile) |
| 14639 | if c.isOnlyImportableAsDefault(moduleSpecifier, moduleSymbol) || c.canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier) { |
| 14640 | symbolFromModule = c.resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) |
| 14641 | if symbolFromModule == nil { |
| 14642 | symbolFromModule = c.resolveSymbolEx(moduleSymbol, dontResolveAlias) |
| 14643 | } |
| 14644 | } |
| 14645 | } |
| 14646 | symbol := symbolFromVariable |
| 14647 | if symbolFromModule != nil { |
| 14648 | symbol = symbolFromModule |
| 14649 | if symbolFromVariable != nil { |
| 14650 | symbol = c.combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) |
no test coverage detected