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

Function IsAliasSymbolDeclaration

internal/ast/utilities.go:2612–2630  ·  view source on GitHub ↗

An alias symbol is created by one of the following declarations: import = ... const = ... (JS only) const { , ... } = ... (JS only) import from ... import * as from ... import { x as } from ... export { x as } from ... export * a

(node *Node)

Source from the content-addressed store, hash-verified

2610// module.exports.<symbol> = <EntityNameExpression> (JS only)
2611// exports.<symbol> = <EntityNameExpression> (JS only)
2612func IsAliasSymbolDeclaration(node *Node) bool {
2613 switch node.Kind {
2614 case KindImportEqualsDeclaration, KindNamespaceExportDeclaration, KindNamespaceImport, KindNamespaceExport,
2615 KindImportSpecifier, KindExportSpecifier:
2616 return true
2617 case KindImportClause:
2618 return node.AsImportClause().Name() != nil
2619 case KindExportAssignment:
2620 return ExpressionIsAlias(node.Expression())
2621 case KindVariableDeclaration, KindBindingElement:
2622 return IsVariableDeclarationInitializedToRequire(node)
2623 case KindBinaryExpression:
2624 switch GetAssignmentDeclarationKind(node) {
2625 case JSDeclarationKindModuleExports, JSDeclarationKindExportsProperty:
2626 return ExpressionIsAlias(node.AsBinaryExpression().Right)
2627 }
2628 }
2629 return false
2630}
2631
2632func IsParseTreeNode(node *Node) bool {
2633 return node.Flags&NodeFlagsSynthesized == 0

Calls 7

ExpressionIsAliasFunction · 0.85
AsImportClauseMethod · 0.80
ExpressionMethod · 0.80
AsBinaryExpressionMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected