@@ -603,12 +603,15 @@ namespace ts {
603
603
604
604
export type DeclarationName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | BindingPattern ;
605
605
606
- export interface Declaration extends Node {
606
+ export interface RealDeclaration extends Node {
607
607
_declarationBrand : any ;
608
608
name ?: DeclarationName ;
609
609
}
610
610
611
- export interface DeclarationStatement extends Declaration , Statement {
611
+ // Binary expressions can be declarations if they are 'exports.foo = bar' expressions in JS files
612
+ export type Declaration = RealDeclaration | BinaryExpression ;
613
+
614
+ export interface DeclarationStatement extends RealDeclaration , Statement {
612
615
name ?: Identifier | StringLiteral | NumericLiteral ;
613
616
}
614
617
@@ -622,7 +625,7 @@ namespace ts {
622
625
expression : LeftHandSideExpression ;
623
626
}
624
627
625
- export interface TypeParameterDeclaration extends Declaration {
628
+ export interface TypeParameterDeclaration extends RealDeclaration {
626
629
kind : SyntaxKind . TypeParameter ;
627
630
parent ?: DeclarationWithTypeParameters ;
628
631
name : Identifier ;
@@ -633,7 +636,7 @@ namespace ts {
633
636
expression ?: Expression ;
634
637
}
635
638
636
- export interface SignatureDeclaration extends Declaration {
639
+ export interface SignatureDeclaration extends RealDeclaration {
637
640
name ?: PropertyName ;
638
641
typeParameters ?: NodeArray < TypeParameterDeclaration > ;
639
642
parameters : NodeArray < ParameterDeclaration > ;
@@ -650,7 +653,7 @@ namespace ts {
650
653
651
654
export type BindingName = Identifier | BindingPattern ;
652
655
653
- export interface VariableDeclaration extends Declaration {
656
+ export interface VariableDeclaration extends RealDeclaration {
654
657
kind : SyntaxKind . VariableDeclaration ;
655
658
parent ?: VariableDeclarationList | CatchClause ;
656
659
name : BindingName ; // Declared variable name
@@ -664,7 +667,7 @@ namespace ts {
664
667
declarations : NodeArray < VariableDeclaration > ;
665
668
}
666
669
667
- export interface ParameterDeclaration extends Declaration {
670
+ export interface ParameterDeclaration extends RealDeclaration {
668
671
kind : SyntaxKind . Parameter ;
669
672
parent ?: SignatureDeclaration ;
670
673
dotDotDotToken ?: DotDotDotToken ; // Present on rest parameter
@@ -674,7 +677,7 @@ namespace ts {
674
677
initializer ?: Expression ; // Optional initializer
675
678
}
676
679
677
- export interface BindingElement extends Declaration {
680
+ export interface BindingElement extends RealDeclaration {
678
681
kind : SyntaxKind . BindingElement ;
679
682
parent ?: BindingPattern ;
680
683
propertyName ?: PropertyName ; // Binding property name (in object binding pattern)
@@ -699,7 +702,7 @@ namespace ts {
699
702
initializer ?: Expression ; // Optional initializer
700
703
}
701
704
702
- export interface ObjectLiteralElement extends Declaration {
705
+ export interface ObjectLiteralElement extends RealDeclaration {
703
706
_objectLiteralBrandBrand : any ;
704
707
name ?: PropertyName ;
705
708
}
@@ -743,7 +746,7 @@ namespace ts {
743
746
// SyntaxKind.ShorthandPropertyAssignment
744
747
// SyntaxKind.EnumMember
745
748
// SyntaxKind.JSDocPropertyTag
746
- export interface VariableLikeDeclaration extends Declaration {
749
+ export interface VariableLikeDeclaration extends RealDeclaration {
747
750
propertyName ?: PropertyName ;
748
751
dotDotDotToken ?: DotDotDotToken ;
749
752
name : DeclarationName ;
@@ -752,7 +755,7 @@ namespace ts {
752
755
initializer ?: Expression ;
753
756
}
754
757
755
- export interface PropertyLikeDeclaration extends Declaration {
758
+ export interface PropertyLikeDeclaration extends RealDeclaration {
756
759
name : PropertyName ;
757
760
}
758
761
@@ -901,7 +904,7 @@ namespace ts {
901
904
}
902
905
903
906
// A TypeLiteral is the declaration node for an anonymous symbol.
904
- export interface TypeLiteralNode extends TypeNode , Declaration {
907
+ export interface TypeLiteralNode extends TypeNode , RealDeclaration {
905
908
kind : SyntaxKind . TypeLiteral ;
906
909
members : NodeArray < TypeElement > ;
907
910
}
@@ -945,7 +948,7 @@ namespace ts {
945
948
indexType : TypeNode ;
946
949
}
947
950
948
- export interface MappedTypeNode extends TypeNode , Declaration {
951
+ export interface MappedTypeNode extends TypeNode , RealDeclaration {
949
952
kind : SyntaxKind . MappedType ;
950
953
parent ?: TypeAliasDeclaration ;
951
954
readonlyToken ?: ReadonlyToken ;
@@ -1216,8 +1219,7 @@ namespace ts {
1216
1219
1217
1220
export type BinaryOperatorToken = Token < BinaryOperator > ;
1218
1221
1219
- // Binary expressions can be declarations if they are 'exports.foo = bar' expressions in JS files
1220
- export interface BinaryExpression extends Expression , Declaration {
1222
+ export interface BinaryExpression extends Expression {
1221
1223
kind : SyntaxKind . BinaryExpression ;
1222
1224
left : Expression ;
1223
1225
operatorToken : BinaryOperatorToken ;
@@ -1403,7 +1405,7 @@ namespace ts {
1403
1405
* JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type
1404
1406
* ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.)
1405
1407
*/
1406
- export interface ObjectLiteralExpressionBase < T extends ObjectLiteralElement > extends PrimaryExpression , Declaration {
1408
+ export interface ObjectLiteralExpressionBase < T extends ObjectLiteralElement > extends PrimaryExpression , RealDeclaration {
1407
1409
properties : NodeArray < T > ;
1408
1410
}
1409
1411
@@ -1417,7 +1419,7 @@ namespace ts {
1417
1419
export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression | ParenthesizedExpression ;
1418
1420
export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression ;
1419
1421
1420
- export interface PropertyAccessExpression extends MemberExpression , Declaration {
1422
+ export interface PropertyAccessExpression extends MemberExpression , RealDeclaration {
1421
1423
kind : SyntaxKind . PropertyAccessExpression ;
1422
1424
expression : LeftHandSideExpression ;
1423
1425
name : Identifier ;
@@ -1449,7 +1451,7 @@ namespace ts {
1449
1451
| SuperElementAccessExpression
1450
1452
;
1451
1453
1452
- export interface CallExpression extends LeftHandSideExpression , Declaration {
1454
+ export interface CallExpression extends LeftHandSideExpression , RealDeclaration {
1453
1455
kind : SyntaxKind . CallExpression ;
1454
1456
expression : LeftHandSideExpression ;
1455
1457
typeArguments ?: NodeArray < TypeNode > ;
@@ -1468,7 +1470,7 @@ namespace ts {
1468
1470
typeArguments ?: NodeArray < TypeNode > ;
1469
1471
}
1470
1472
1471
- export interface NewExpression extends PrimaryExpression , Declaration {
1473
+ export interface NewExpression extends PrimaryExpression , RealDeclaration {
1472
1474
kind : SyntaxKind . NewExpression ;
1473
1475
expression : LeftHandSideExpression ;
1474
1476
typeArguments ?: NodeArray < TypeNode > ;
@@ -1762,7 +1764,7 @@ namespace ts {
1762
1764
1763
1765
export type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration ;
1764
1766
1765
- export interface ClassLikeDeclaration extends Declaration {
1767
+ export interface ClassLikeDeclaration extends RealDeclaration {
1766
1768
name ?: Identifier ;
1767
1769
typeParameters ?: NodeArray < TypeParameterDeclaration > ;
1768
1770
heritageClauses ?: NodeArray < HeritageClause > ;
@@ -1778,12 +1780,12 @@ namespace ts {
1778
1780
kind : SyntaxKind . ClassExpression ;
1779
1781
}
1780
1782
1781
- export interface ClassElement extends Declaration {
1783
+ export interface ClassElement extends RealDeclaration {
1782
1784
_classElementBrand : any ;
1783
1785
name ?: PropertyName ;
1784
1786
}
1785
1787
1786
- export interface TypeElement extends Declaration {
1788
+ export interface TypeElement extends RealDeclaration {
1787
1789
_typeElementBrand : any ;
1788
1790
name ?: PropertyName ;
1789
1791
questionToken ?: QuestionToken ;
@@ -1811,7 +1813,7 @@ namespace ts {
1811
1813
type : TypeNode ;
1812
1814
}
1813
1815
1814
- export interface EnumMember extends Declaration {
1816
+ export interface EnumMember extends RealDeclaration {
1815
1817
kind : SyntaxKind . EnumMember ;
1816
1818
parent ?: EnumDeclaration ;
1817
1819
// This does include ComputedPropertyName, but the parser will give an error
@@ -1900,14 +1902,14 @@ namespace ts {
1900
1902
// import d, * as ns from "mod" => name = d, namedBinding: NamespaceImport = { name: ns }
1901
1903
// import { a, b as x } from "mod" => name = undefined, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]}
1902
1904
// import d, { a, b as x } from "mod" => name = d, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]}
1903
- export interface ImportClause extends Declaration {
1905
+ export interface ImportClause extends RealDeclaration {
1904
1906
kind : SyntaxKind . ImportClause ;
1905
1907
parent ?: ImportDeclaration ;
1906
1908
name ?: Identifier ; // Default binding
1907
1909
namedBindings ?: NamedImportBindings ;
1908
1910
}
1909
1911
1910
- export interface NamespaceImport extends Declaration {
1912
+ export interface NamespaceImport extends RealDeclaration {
1911
1913
kind : SyntaxKind . NamespaceImport ;
1912
1914
parent ?: ImportClause ;
1913
1915
name : Identifier ;
@@ -1940,14 +1942,14 @@ namespace ts {
1940
1942
1941
1943
export type NamedImportsOrExports = NamedImports | NamedExports ;
1942
1944
1943
- export interface ImportSpecifier extends Declaration {
1945
+ export interface ImportSpecifier extends RealDeclaration {
1944
1946
kind : SyntaxKind . ImportSpecifier ;
1945
1947
parent ?: NamedImports ;
1946
1948
propertyName ?: Identifier ; // Name preceding "as" keyword (or undefined when "as" is absent)
1947
1949
name : Identifier ; // Declared name
1948
1950
}
1949
1951
1950
- export interface ExportSpecifier extends Declaration {
1952
+ export interface ExportSpecifier extends RealDeclaration {
1951
1953
kind : SyntaxKind . ExportSpecifier ;
1952
1954
parent ?: NamedExports ;
1953
1955
propertyName ?: Identifier ; // Name preceding "as" keyword (or undefined when "as" is absent)
@@ -2113,7 +2115,7 @@ namespace ts {
2113
2115
typeExpression : JSDocTypeExpression ;
2114
2116
}
2115
2117
2116
- export interface JSDocTypedefTag extends JSDocTag , Declaration {
2118
+ export interface JSDocTypedefTag extends JSDocTag , RealDeclaration {
2117
2119
kind : SyntaxKind . JSDocTypedefTag ;
2118
2120
fullName ?: JSDocNamespaceDeclaration | Identifier ;
2119
2121
name ?: Identifier ;
@@ -2247,7 +2249,7 @@ namespace ts {
2247
2249
2248
2250
2249
2251
// Source files are declarations when they are external modules.
2250
- export interface SourceFile extends Declaration {
2252
+ export interface SourceFile extends RealDeclaration {
2251
2253
kind : SyntaxKind . SourceFile ;
2252
2254
statements : NodeArray < Statement > ;
2253
2255
endOfFileToken : Token < SyntaxKind . EndOfFileToken > ;
0 commit comments