@@ -771,12 +771,10 @@ func (n *Node) Children() *NodeList {
771
771
772
772
func (n * Node ) ModuleSpecifier () * Expression {
773
773
switch n .Kind {
774
- case KindImportDeclaration :
774
+ case KindImportDeclaration , KindJSImportDeclaration :
775
775
return n .AsImportDeclaration ().ModuleSpecifier
776
776
case KindExportDeclaration :
777
777
return n .AsExportDeclaration ().ModuleSpecifier
778
- case KindJSDocImportTag :
779
- return n .AsJSDocImportTag ().ModuleSpecifier
780
778
}
781
779
panic ("Unhandled case in Node.ModuleSpecifier: " + n .Kind .String ())
782
780
}
@@ -3689,7 +3687,7 @@ type TypeAliasDeclaration struct {
3689
3687
Type * TypeNode // TypeNode
3690
3688
}
3691
3689
3692
- func (f * NodeFactory ) newTypeOrJSTypeAliasDeclaration (kind Kind , modifiers * ModifierList , name * IdentifierNode , typeParameters * NodeList , typeNode * TypeNode ) * Node {
3690
+ func (f * NodeFactory ) newTypeAliasOrJSTypeAliasDeclaration (kind Kind , modifiers * ModifierList , name * IdentifierNode , typeParameters * NodeList , typeNode * TypeNode ) * Node {
3693
3691
data := & TypeAliasDeclaration {}
3694
3692
data .modifiers = modifiers
3695
3693
data .name = name
@@ -3699,12 +3697,12 @@ func (f *NodeFactory) newTypeOrJSTypeAliasDeclaration(kind Kind, modifiers *Modi
3699
3697
}
3700
3698
3701
3699
func (f * NodeFactory ) NewTypeAliasDeclaration (modifiers * ModifierList , name * IdentifierNode , typeParameters * NodeList , typeNode * TypeNode ) * Node {
3702
- return f .newTypeOrJSTypeAliasDeclaration (KindTypeAliasDeclaration , modifiers , name , typeParameters , typeNode )
3700
+ return f .newTypeAliasOrJSTypeAliasDeclaration (KindTypeAliasDeclaration , modifiers , name , typeParameters , typeNode )
3703
3701
}
3704
3702
3705
3703
func (f * NodeFactory ) UpdateTypeAliasDeclaration (node * TypeAliasDeclaration , modifiers * ModifierList , name * IdentifierNode , typeParameters * TypeParameterList , typeNode * TypeNode ) * Node {
3706
3704
if modifiers != node .modifiers || name != node .name || typeParameters != node .TypeParameters || typeNode != node .Type {
3707
- return updateNode (f .NewTypeAliasDeclaration ( modifiers , name , typeParameters , typeNode ), node .AsNode (), f .hooks )
3705
+ return updateNode (f .newTypeAliasOrJSTypeAliasDeclaration ( node . Kind , modifiers , name , typeParameters , typeNode ), node .AsNode (), f .hooks )
3708
3706
}
3709
3707
return node .AsNode ()
3710
3708
}
@@ -3714,14 +3712,11 @@ func (node *TypeAliasDeclaration) ForEachChild(v Visitor) bool {
3714
3712
}
3715
3713
3716
3714
func (node * TypeAliasDeclaration ) VisitEachChild (v * NodeVisitor ) * Node {
3717
- if node .Kind == KindJSTypeAliasDeclaration {
3718
- return v .Factory .UpdateJSTypeAliasDeclaration (node , v .visitModifiers (node .modifiers ), v .visitNode (node .name ), v .visitNodes (node .TypeParameters ), v .visitNode (node .Type ))
3719
- }
3720
3715
return v .Factory .UpdateTypeAliasDeclaration (node , v .visitModifiers (node .modifiers ), v .visitNode (node .name ), v .visitNodes (node .TypeParameters ), v .visitNode (node .Type ))
3721
3716
}
3722
3717
3723
3718
func (node * TypeAliasDeclaration ) Clone (f NodeFactoryCoercible ) * Node {
3724
- return cloneNode (f .AsNodeFactory ().NewTypeAliasDeclaration ( node .Modifiers (), node .Name (), node .TypeParameters , node .Type ), node .AsNode (), f .AsNodeFactory ().hooks )
3719
+ return cloneNode (f .AsNodeFactory ().newTypeAliasOrJSTypeAliasDeclaration ( node . Kind , node .Modifiers (), node .Name (), node .TypeParameters , node .Type ), node .AsNode (), f .AsNodeFactory ().hooks )
3725
3720
}
3726
3721
3727
3722
func (node * TypeAliasDeclaration ) Name () * DeclarationName { return node .name }
@@ -3735,14 +3730,7 @@ func IsTypeOrJSTypeAliasDeclaration(node *Node) bool {
3735
3730
}
3736
3731
3737
3732
func (f * NodeFactory ) NewJSTypeAliasDeclaration (modifiers * ModifierList , name * IdentifierNode , typeParameters * NodeList , typeNode * TypeNode ) * Node {
3738
- return f .newTypeOrJSTypeAliasDeclaration (KindJSTypeAliasDeclaration , modifiers , name , typeParameters , typeNode )
3739
- }
3740
-
3741
- func (f * NodeFactory ) UpdateJSTypeAliasDeclaration (node * TypeAliasDeclaration , modifiers * ModifierList , name * IdentifierNode , typeParameters * TypeParameterList , typeNode * TypeNode ) * Node {
3742
- if modifiers != node .modifiers || name != node .name || typeParameters != node .TypeParameters || typeNode != node .Type {
3743
- return updateNode (f .NewJSTypeAliasDeclaration (modifiers , name , typeParameters , typeNode ), node .AsNode (), f .hooks )
3744
- }
3745
- return node .AsNode ()
3733
+ return f .newTypeAliasOrJSTypeAliasDeclaration (KindJSTypeAliasDeclaration , modifiers , name , typeParameters , typeNode )
3746
3734
}
3747
3735
3748
3736
func IsJSTypeAliasDeclaration (node * Node ) bool {
@@ -4056,18 +4044,26 @@ type ImportDeclaration struct {
4056
4044
Attributes * ImportAttributesNode // ImportAttributesNode. Optional
4057
4045
}
4058
4046
4059
- func (f * NodeFactory ) NewImportDeclaration ( modifiers * ModifierList , importClause * ImportClauseNode , moduleSpecifier * Expression , attributes * ImportAttributesNode ) * Node {
4047
+ func (f * NodeFactory ) newImportOrJSImportDeclaration ( kind Kind , modifiers * ModifierList , importClause * ImportClauseNode , moduleSpecifier * Expression , attributes * ImportAttributesNode ) * Node {
4060
4048
data := & ImportDeclaration {}
4061
4049
data .modifiers = modifiers
4062
4050
data .ImportClause = importClause
4063
4051
data .ModuleSpecifier = moduleSpecifier
4064
4052
data .Attributes = attributes
4065
- return f .newNode (KindImportDeclaration , data )
4053
+ return f .newNode (kind , data )
4054
+ }
4055
+
4056
+ func (f * NodeFactory ) NewImportDeclaration (modifiers * ModifierList , importClause * ImportClauseNode , moduleSpecifier * Expression , attributes * ImportAttributesNode ) * Node {
4057
+ return f .newImportOrJSImportDeclaration (KindImportDeclaration , modifiers , importClause , moduleSpecifier , attributes )
4058
+ }
4059
+
4060
+ func (f * NodeFactory ) NewJSImportDeclaration (modifiers * ModifierList , importClause * ImportClauseNode , moduleSpecifier * Expression , attributes * ImportAttributesNode ) * Node {
4061
+ return f .newImportOrJSImportDeclaration (KindJSImportDeclaration , modifiers , importClause , moduleSpecifier , attributes )
4066
4062
}
4067
4063
4068
4064
func (f * NodeFactory ) UpdateImportDeclaration (node * ImportDeclaration , modifiers * ModifierList , importClause * ImportClauseNode , moduleSpecifier * Expression , attributes * ImportAttributesNode ) * Node {
4069
4065
if modifiers != node .modifiers || importClause != node .ImportClause || moduleSpecifier != node .ModuleSpecifier || attributes != node .Attributes {
4070
- return updateNode (f .NewImportDeclaration ( modifiers , importClause , moduleSpecifier , attributes ), node .AsNode (), f .hooks )
4066
+ return updateNode (f .newImportOrJSImportDeclaration ( node . Kind , modifiers , importClause , moduleSpecifier , attributes ), node .AsNode (), f .hooks )
4071
4067
}
4072
4068
return node .AsNode ()
4073
4069
}
@@ -4081,7 +4077,7 @@ func (node *ImportDeclaration) VisitEachChild(v *NodeVisitor) *Node {
4081
4077
}
4082
4078
4083
4079
func (node * ImportDeclaration ) Clone (f NodeFactoryCoercible ) * Node {
4084
- return cloneNode (f .AsNodeFactory ().NewImportDeclaration ( node .Modifiers (), node .ImportClause , node .ModuleSpecifier , node .Attributes ), node .AsNode (), f .AsNodeFactory ().hooks )
4080
+ return cloneNode (f .AsNodeFactory ().newImportOrJSImportDeclaration ( node . Kind , node .Modifiers (), node .ImportClause , node .ModuleSpecifier , node .Attributes ), node .AsNode (), f .AsNodeFactory ().hooks )
4085
4081
}
4086
4082
4087
4083
func (node * ImportDeclaration ) computeSubtreeFacts () SubtreeFacts {
0 commit comments