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

Function IsModuleAugmentationExternal

internal/ast/utilities.go:1675–1687  ·  view source on GitHub ↗
(node *Node)

Source from the content-addressed store, hash-verified

1673}
1674
1675func IsModuleAugmentationExternal(node *Node) bool {
1676 // external module augmentation is a ambient module declaration that is either:
1677 // - defined in the top level scope and source file is an external module
1678 // - defined inside ambient module declaration located in the top level scope and source file not an external module
1679 switch node.Parent.Kind {
1680 case KindSourceFile:
1681 return IsExternalModule(node.Parent.AsSourceFile())
1682 case KindModuleBlock:
1683 grandParent := node.Parent.Parent
1684 return IsAmbientModule(grandParent) && IsSourceFile(grandParent.Parent) && !IsExternalModule(grandParent.Parent.AsSourceFile())
1685 }
1686 return false
1687}
1688
1689func IsModuleWithStringLiteralName(node *Node) bool {
1690 return IsModuleDeclaration(node) && node.Name().Kind == KindStringLiteral

Callers 3

bindModuleDeclarationMethod · 0.92

Calls 4

IsExternalModuleFunction · 0.85
IsAmbientModuleFunction · 0.85
IsSourceFileFunction · 0.85
AsSourceFileMethod · 0.80

Tested by

no test coverage detected