mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Bind JSDoc on SemicolonClassElement (#54044)
This commit is contained in:
@@ -7835,12 +7835,12 @@ namespace Parser {
|
||||
|
||||
function parseClassElement(): ClassElement {
|
||||
const pos = getNodePos();
|
||||
const hasJSDoc = hasPrecedingJSDocComment();
|
||||
if (token() === SyntaxKind.SemicolonToken) {
|
||||
nextToken();
|
||||
return finishNode(factory.createSemicolonClassElement(), pos);
|
||||
return withJSDoc(finishNode(factory.createSemicolonClassElement(), pos), hasJSDoc);
|
||||
}
|
||||
|
||||
const hasJSDoc = hasPrecedingJSDocComment();
|
||||
const modifiers = parseModifiers(/*allowDecorators*/ true, /*permitConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true);
|
||||
if (token() === SyntaxKind.StaticKeyword && lookAhead(nextTokenIsOpenBrace)) {
|
||||
return parseClassStaticBlockDeclaration(pos, hasJSDoc, modifiers);
|
||||
|
||||
@@ -1219,6 +1219,7 @@ export type HasJSDoc =
|
||||
| PropertyDeclaration
|
||||
| PropertySignature
|
||||
| ReturnStatement
|
||||
| SemicolonClassElement
|
||||
| ShorthandPropertyAssignment
|
||||
| SpreadAssignment
|
||||
| SwitchStatement
|
||||
@@ -2101,7 +2102,7 @@ export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, Cla
|
||||
}
|
||||
|
||||
/** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */
|
||||
export interface SemicolonClassElement extends ClassElement {
|
||||
export interface SemicolonClassElement extends ClassElement, JSDocContainer {
|
||||
readonly kind: SyntaxKind.SemicolonClassElement;
|
||||
readonly parent: ClassLikeDeclaration;
|
||||
}
|
||||
|
||||
@@ -4180,6 +4180,7 @@ export function canHaveJSDoc(node: Node): node is HasJSDoc {
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.ReturnStatement:
|
||||
case SyntaxKind.SemicolonClassElement:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
|
||||
Reference in New Issue
Block a user