@@ -168,6 +168,9 @@ namespace ts {
168
168
visitNode ( cbNode , ( < FunctionLikeDeclaration > node ) . type ) ||
169
169
visitNode ( cbNode , ( < ArrowFunction > node ) . equalsGreaterThanToken ) ||
170
170
visitNode ( cbNode , ( < FunctionLikeDeclaration > node ) . body ) ;
171
+ case SyntaxKind . ClassStaticBlockDeclaration :
172
+ return visitNode ( cbNode , ( < ClassStaticBlockDeclaration > node ) . staticToken ) ||
173
+ visitNode ( cbNode , ( < ClassStaticBlockDeclaration > node ) . body ) ;
171
174
case SyntaxKind . TypeReference :
172
175
return visitNode ( cbNode , ( < TypeReferenceNode > node ) . typeName ) ||
173
176
visitNodes ( cbNode , cbNodes , ( < TypeReferenceNode > node ) . typeArguments ) ;
@@ -6561,6 +6564,28 @@ namespace ts {
6561
6564
return false ;
6562
6565
}
6563
6566
6567
+ function parseClassStaticBlockDeclaration ( ) : ClassStaticBlockDeclaration {
6568
+ const pos = getNodePos ( ) ;
6569
+ const staticKeyworkd = parseExpectedToken ( SyntaxKind . StaticKeyword ) ;
6570
+ const body = parseClassStaticBlockBodyBlock ( ) ;
6571
+ return finishNode ( factory . createClassStaticBlockDeclaration ( staticKeyworkd , body ) , pos ) ;
6572
+ }
6573
+
6574
+ function parseClassStaticBlockBodyBlock ( ) {
6575
+ const savedYieldContext = inYieldContext ( ) ;
6576
+ setYieldContext ( false ) ;
6577
+
6578
+ const savedAwaitContext = inAwaitContext ( ) ;
6579
+ setAwaitContext ( false ) ;
6580
+
6581
+ const block = parseBlock ( /*ignoreMissingOpenBrace*/ false ) ;
6582
+
6583
+ setAwaitContext ( savedAwaitContext ) ;
6584
+ setYieldContext ( savedYieldContext ) ;
6585
+
6586
+ return block ;
6587
+ }
6588
+
6564
6589
function parseDecoratorExpression ( ) {
6565
6590
if ( inAwaitContext ( ) && token ( ) === SyntaxKind . AwaitKeyword ) {
6566
6591
// `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails
@@ -6645,6 +6670,9 @@ namespace ts {
6645
6670
nextToken ( ) ;
6646
6671
return finishNode ( factory . createSemicolonClassElement ( ) , pos ) ;
6647
6672
}
6673
+ if ( token ( ) === SyntaxKind . StaticKeyword && lookAhead ( nextTokenIsOpenBrace ) ) {
6674
+ return parseClassStaticBlockDeclaration ( ) ;
6675
+ }
6648
6676
6649
6677
const hasJSDoc = hasPrecedingJSDocComment ( ) ;
6650
6678
const decorators = parseDecorators ( ) ;
@@ -6910,6 +6938,10 @@ namespace ts {
6910
6938
return nextToken ( ) === SyntaxKind . OpenParenToken ;
6911
6939
}
6912
6940
6941
+ function nextTokenIsOpenBrace ( ) {
6942
+ return nextToken ( ) === SyntaxKind . OpenBraceToken ;
6943
+ }
6944
+
6913
6945
function nextTokenIsSlash ( ) {
6914
6946
return nextToken ( ) === SyntaxKind . SlashToken ;
6915
6947
}
0 commit comments