@@ -643,21 +643,23 @@ namespace ts {
643
643
initializer ?: Expression ; // Optional initializer
644
644
}
645
645
646
- export interface ObjectLiteralElement extends Declaration {
646
+ export interface ObjectLiteralElementLike extends Declaration {
647
647
_objectLiteralBrandBrand : any ;
648
648
name ?: PropertyName ;
649
649
}
650
650
651
+ export type ObjectLiteralElement = PropertyAssignment | ShorthandPropertyAssignment | SpreadObjectLiteralAssignment | MethodDeclaration | AccessorDeclaration ;
652
+
651
653
// @kind (SyntaxKind.PropertyAssignment)
652
- export interface PropertyAssignment extends ObjectLiteralElement {
654
+ export interface PropertyAssignment extends ObjectLiteralElementLike {
653
655
_propertyAssignmentBrand : any ;
654
656
name : PropertyName ;
655
657
questionToken ?: Node ;
656
658
initializer : Expression ;
657
659
}
658
660
659
661
// @kind (SyntaxKind.ShorthandPropertyAssignment)
660
- export interface ShorthandPropertyAssignment extends ObjectLiteralElement {
662
+ export interface ShorthandPropertyAssignment extends ObjectLiteralElementLike {
661
663
name : Identifier ;
662
664
questionToken ?: Node ;
663
665
// used when ObjectLiteralExpression is used in ObjectAssignmentPattern
@@ -740,7 +742,7 @@ namespace ts {
740
742
// at later stages of the compiler pipeline. In that case, you can either check the parent kind
741
743
// of the method, or use helpers like isObjectLiteralMethodDeclaration
742
744
// @kind (SyntaxKind.MethodDeclaration)
743
- export interface MethodDeclaration extends FunctionLikeDeclaration , ClassElement , ObjectLiteralElement {
745
+ export interface MethodDeclaration extends FunctionLikeDeclaration , ClassElement , ObjectLiteralElementLike {
744
746
name : PropertyName ;
745
747
body ?: FunctionBody ;
746
748
}
@@ -758,7 +760,7 @@ namespace ts {
758
760
759
761
// See the comment on MethodDeclaration for the intuition behind AccessorDeclaration being a
760
762
// ClassElement and an ObjectLiteralElement.
761
- export interface AccessorDeclaration extends FunctionLikeDeclaration , ClassElement , ObjectLiteralElement {
763
+ export interface AccessorDeclaration extends FunctionLikeDeclaration , ClassElement , ObjectLiteralElementLike {
762
764
_accessorDeclarationBrand : any ;
763
765
name : PropertyName ;
764
766
body : FunctionBody ;
@@ -1048,10 +1050,16 @@ namespace ts {
1048
1050
expression : Expression ;
1049
1051
}
1050
1052
1053
+ // The reason we create this interface so that JSXAttributes and ObjectLiteralExpression interface can extend out of it.
1054
+ // JSXAttributes differs from normal ObjectLiteralExpression in that JSXAttributes can only take JSXAttribute or JSXSpreadAttribute
1055
+ // but not ShortHandPropertyAssignment, methodDeclaration or other ObjectLiteralElementLike acceptable by ObjectLiteralExpression.
1056
+ export interface ObjectLiteralExpressionBase < T extends ObjectLiteralElementLike > extends PrimaryExpression , Declaration {
1057
+ properties : NodeArray < T > ;
1058
+ }
1059
+
1051
1060
// An ObjectLiteralExpression is the declaration node for an anonymous symbol.
1052
1061
// @kind (SyntaxKind.ObjectLiteralExpression)
1053
- export interface ObjectLiteralExpression extends PrimaryExpression , Declaration {
1054
- properties : NodeArray < ObjectLiteralElement > ;
1062
+ export interface ObjectLiteralExpression extends ObjectLiteralExpressionBase < ObjectLiteralElement > {
1055
1063
/* @internal */
1056
1064
multiLine ?: boolean ;
1057
1065
}
@@ -1195,7 +1203,7 @@ namespace ts {
1195
1203
export interface DebuggerStatement extends Statement { }
1196
1204
1197
1205
// @kind (SyntaxKind.MissingDeclaration)
1198
- export interface MissingDeclaration extends DeclarationStatement , ClassElement , ObjectLiteralElement , TypeElement {
1206
+ export interface MissingDeclaration extends DeclarationStatement , ClassElement , ObjectLiteralElementLike , TypeElement {
1199
1207
name ?: Identifier ;
1200
1208
}
1201
1209
0 commit comments