Skip to content

Commit 644ceab

Browse files
author
Andy
authored
Document ObjectLiteralElementLike (microsoft#26024)
1 parent 57d4251 commit 644ceab

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ namespace ts {
858858
name?: PropertyName;
859859
}
860860

861+
/** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */
861862
export type ObjectLiteralElementLike
862863
= PropertyAssignment
863864
| ShorthandPropertyAssignment

src/compiler/utilities.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6632,18 +6632,7 @@ namespace ts {
66326632
}
66336633

66346634
export function isObjectLiteralElement(node: Node): node is ObjectLiteralElement {
6635-
switch (node.kind) {
6636-
case SyntaxKind.JsxAttribute:
6637-
case SyntaxKind.JsxSpreadAttribute:
6638-
case SyntaxKind.PropertyAssignment:
6639-
case SyntaxKind.ShorthandPropertyAssignment:
6640-
case SyntaxKind.MethodDeclaration:
6641-
case SyntaxKind.GetAccessor:
6642-
case SyntaxKind.SetAccessor:
6643-
return true;
6644-
default:
6645-
return false;
6646-
}
6635+
return node.kind === SyntaxKind.JsxAttribute || node.kind === SyntaxKind.JsxSpreadAttribute || isObjectLiteralElementLike(node);
66476636
}
66486637

66496638
/* @internal */

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ declare namespace ts {
616616
_objectLiteralBrandBrand: any;
617617
name?: PropertyName;
618618
}
619+
/** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */
619620
type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration;
620621
interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer {
621622
parent: ObjectLiteralExpression;

tests/baselines/reference/api/typescript.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ declare namespace ts {
616616
_objectLiteralBrandBrand: any;
617617
name?: PropertyName;
618618
}
619+
/** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */
619620
type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration;
620621
interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer {
621622
parent: ObjectLiteralExpression;

0 commit comments

Comments
 (0)