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

Function GetExternalModuleName

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

Source from the content-addressed store, hash-verified

1882}
1883
1884func GetExternalModuleName(node *Node) *Expression {
1885 switch node.Kind {
1886 case KindImportDeclaration, KindJSImportDeclaration, KindExportDeclaration:
1887 return node.ModuleSpecifier()
1888 case KindImportEqualsDeclaration:
1889 if node.AsImportEqualsDeclaration().ModuleReference.Kind == KindExternalModuleReference {
1890 return node.AsImportEqualsDeclaration().ModuleReference.Expression()
1891 }
1892 return nil
1893 case KindImportType:
1894 return getImportTypeNodeLiteral(node)
1895 case KindCallExpression:
1896 return core.FirstOrNil(node.Arguments())
1897 case KindModuleDeclaration:
1898 if IsStringLiteral(node.AsModuleDeclaration().Name()) {
1899 return node.AsModuleDeclaration().Name()
1900 }
1901 return nil
1902 }
1903 panic("Unhandled case in getExternalModuleName")
1904}
1905
1906func GetImportAttributes(node *Node) *Node {
1907 switch node.Kind {

Calls 10

FirstOrNilFunction · 0.92
getImportTypeNodeLiteralFunction · 0.85
IsStringLiteralFunction · 0.85
panicFunction · 0.85
ModuleSpecifierMethod · 0.80
ExpressionMethod · 0.80
ArgumentsMethod · 0.80
AsModuleDeclarationMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected