(node *ast.Node)
| 24481 | } |
| 24482 | |
| 24483 | func (c *Checker) getTypeFromImportTypeNode(node *ast.Node) *Type { |
| 24484 | links := c.typeNodeLinks.Get(node) |
| 24485 | if links.resolvedType == nil { |
| 24486 | n := node.AsImportTypeNode() |
| 24487 | if !ast.IsLiteralImportTypeNode(node) { |
| 24488 | c.error(n.Argument, diagnostics.String_literal_expected) |
| 24489 | c.symbolNodeLinks.Get(node).resolvedSymbol = c.unknownSymbol |
| 24490 | links.resolvedType = c.errorType |
| 24491 | return links.resolvedType |
| 24492 | } |
| 24493 | targetMeaning := core.IfElse(n.IsTypeOf, ast.SymbolFlagsValue, ast.SymbolFlagsType) |
| 24494 | // TODO: Future work: support unions/generics/whatever via a deferred import-type |
| 24495 | innerModuleSymbol := c.resolveExternalModuleName(node, n.Argument.AsLiteralTypeNode().Literal, false /*ignoreErrors*/) |
| 24496 | if innerModuleSymbol == nil { |
| 24497 | c.symbolNodeLinks.Get(node).resolvedSymbol = c.unknownSymbol |
| 24498 | links.resolvedType = c.errorType |
| 24499 | return links.resolvedType |
| 24500 | } |
| 24501 | moduleSymbol := c.resolveExternalModuleSymbol(innerModuleSymbol, false /*dontResolveAlias*/) |
| 24502 | if !ast.NodeIsMissing(n.Qualifier) { |
| 24503 | nameChain := c.getIdentifierChain(n.Qualifier) |
| 24504 | currentNamespace := moduleSymbol |
| 24505 | for i, current := range nameChain { |
| 24506 | meaning := ast.SymbolFlagsNamespace |
| 24507 | if i == len(nameChain)-1 { |
| 24508 | meaning = targetMeaning |
| 24509 | } |
| 24510 | // typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName` |
| 24511 | // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from |
| 24512 | // the `exports` lookup process that only looks up namespace members which is used for most type references |
| 24513 | mergedResolvedSymbol := c.getMergedSymbol(c.resolveSymbol(currentNamespace)) |
| 24514 | var symbolFromVariable *ast.Symbol |
| 24515 | var symbolFromModule *ast.Symbol |
| 24516 | if n.IsTypeOf { |
| 24517 | symbolFromVariable = c.getPropertyOfTypeEx(c.getTypeOfSymbol(mergedResolvedSymbol), current.Text(), false /*skipObjectFunctionPropertyAugment*/, true /*includeTypeOnlyMembers*/) |
| 24518 | } else { |
| 24519 | symbolFromModule = c.getSymbol(c.getExportsOfSymbol(mergedResolvedSymbol), current.Text(), meaning) |
| 24520 | if symbolFromModule == nil { |
| 24521 | // a CommonJS module might have typedefs exported alongside an export= |
| 24522 | // !!! |
| 24523 | immediateModuleSymbol := c.resolveExternalModuleSymbol(innerModuleSymbol, true /*dontResolveAlias*/) |
| 24524 | if immediateModuleSymbol != nil && core.Some(immediateModuleSymbol.Declarations, func(d *ast.Node) bool { |
| 24525 | return ast.GetAssignmentDeclarationKind(d) == ast.JSDeclarationKindModuleExports |
| 24526 | }) { |
| 24527 | symbolFromModule = c.getSymbol(c.getExportsOfSymbol(immediateModuleSymbol.Parent), current.Text(), meaning) |
| 24528 | } |
| 24529 | } |
| 24530 | } |
| 24531 | next := core.OrElse(symbolFromModule, symbolFromVariable) |
| 24532 | if next == nil { |
| 24533 | c.error(current, diagnostics.Namespace_0_has_no_exported_member_1, c.getFullyQualifiedName(currentNamespace, nil), scanner.DeclarationNameToString(current)) |
| 24534 | links.resolvedType = c.errorType |
| 24535 | return links.resolvedType |
| 24536 | } |
| 24537 | c.symbolNodeLinks.Get(current).resolvedSymbol = next |
| 24538 | c.symbolNodeLinks.Get(current.Parent).resolvedSymbol = next |
| 24539 | currentNamespace = next |
| 24540 | } |
no test coverage detected