(node *Node, ancestors []*Node, visited map[NodeId]ModuleInstanceState)
| 2385 | } |
| 2386 | |
| 2387 | func getModuleInstanceStateForAliasTarget(node *Node, ancestors []*Node, visited map[NodeId]ModuleInstanceState) ModuleInstanceState { |
| 2388 | name := node.PropertyNameOrName() |
| 2389 | if name.Kind != KindIdentifier { |
| 2390 | // Skip for invalid syntax like this: export { "x" } |
| 2391 | return ModuleInstanceStateInstantiated |
| 2392 | } |
| 2393 | for ancestors, p := popAncestor(ancestors, node); p != nil; ancestors, p = popAncestor(ancestors, p) { |
| 2394 | if IsBlock(p) || IsModuleBlock(p) || IsSourceFile(p) { |
| 2395 | found := ModuleInstanceStateUnknown |
| 2396 | statementsAncestors := pushAncestor(ancestors, p) |
| 2397 | for _, statement := range p.Statements() { |
| 2398 | if NodeHasName(statement, name) { |
| 2399 | state := getModuleInstanceStateCached(statement, statementsAncestors, visited) |
| 2400 | if found == ModuleInstanceStateUnknown || state > found { |
| 2401 | found = state |
| 2402 | } |
| 2403 | if found == ModuleInstanceStateInstantiated { |
| 2404 | return found |
| 2405 | } |
| 2406 | if statement.Kind == KindImportEqualsDeclaration { |
| 2407 | // Treat re-exports of import aliases as instantiated since they're ambiguous. This is consistent |
| 2408 | // with `export import x = mod.x` being treated as instantiated: |
| 2409 | // import x = mod.x; |
| 2410 | // export { x }; |
| 2411 | found = ModuleInstanceStateInstantiated |
| 2412 | } |
| 2413 | } |
| 2414 | } |
| 2415 | if found != ModuleInstanceStateUnknown { |
| 2416 | return found |
| 2417 | } |
| 2418 | } |
| 2419 | } |
| 2420 | // Couldn't locate, assume could refer to a value |
| 2421 | return ModuleInstanceStateInstantiated |
| 2422 | } |
| 2423 | |
| 2424 | func IsInstantiatedModule(node *Node, preserveConstEnums bool) bool { |
| 2425 | moduleState := GetModuleInstanceState(node) |
no test coverage detected