Proposal class static block support (#43370)

* Class static block (#9)

* Add types factory and parser

* Add some case

* Make class static block as a container

* Update cases

* Add visitor

* Add emitter and more compile target

* Check boundary of break and continue

* Add basic transformer

* Fix emit behavior

* Add more tests

* Add friend tests

* Update baseline

* Fix cr issues

* Accept baseline

* Add decorator and modifier check

* Add functional boundary check

* Fix conflict

* Fix computed prop name within context

* Add more tests

* Update baseline

* Avoid invalid test baseline

* Support use before initialize check

* wip

* Fix class static block context

* Fix checks

* Fix missing case

* Improve assert message

* Accept baseline

* Avoid new context

* Update diagnostic message

* Fix name collision

* Fix targets

* Avoid unnecessary files

* Add more case

* Add more test cases

* Fix strict mode function declaration

* Avoid private fields initializer if no private identifier references

* Avoid private fields and add more test case

* Add more case

* Add tests and support for related services functionality

* Fix this reference in static block

* Split parser diagnostic and binder diagnostic

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
This commit is contained in:
Wenlu WangandRon Buckton authored and GitHub committed 2021-06-25 09:24:05 -07:00
1 parent 1694c77060
commit 906cbd2715
217 files changed
+8636 -469

No files matched your search

+5 -3
View File
@@ -1832,6 +1832,7 @@ namespace ts {
case SyntaxKind.ConstructSignature:
case SyntaxKind.IndexSignature:
case SyntaxKind.ConstructorType:
case SyntaxKind.ClassStaticBlockDeclaration:
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike;
case SyntaxKind.FunctionExpression:
@@ -1867,7 +1868,7 @@ namespace ts {
// By not creating a new block-scoped-container here, we ensure that both 'var x'
// and 'let x' go into the Function-container's locals, and we do get a collision
// conflict.
return isFunctionLike(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer;
return isFunctionLike(node.parent) || isClassStaticBlockDeclaration(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer;
}
return ContainerFlags.None;
@@ -1929,6 +1930,7 @@ namespace ts {
case SyntaxKind.JSDocFunctionType:
case SyntaxKind.JSDocTypedefTag:
case SyntaxKind.JSDocCallbackTag:
case SyntaxKind.ClassStaticBlockDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.MappedType:
// All the children of these container types are never visible through another
@@ -2328,7 +2330,7 @@ namespace ts {
// Report error if function is not top level function declaration
if (blockScopeContainer.kind !== SyntaxKind.SourceFile &&
blockScopeContainer.kind !== SyntaxKind.ModuleDeclaration &&
!isFunctionLike(blockScopeContainer)) {
!isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) {
// We check first if the name is inside class declaration or class expression; if so give explicit message
// otherwise report generic error message.
const errorSpan = getErrorSpanForNode(file, node);
@@ -2712,7 +2714,7 @@ namespace ts {
updateStrictModeStatementList((node as SourceFile).statements);
return bindSourceFileIfExternalModule();
case SyntaxKind.Block:
if (!isFunctionLike(node.parent)) {
if (!isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) {
return;
}
// falls through
+53 -22
View File
@@ -24186,7 +24186,7 @@ namespace ts {
// To avoid that we will give an error to users if they use arguments objects in arrow function so that they
// can explicitly bound arguments objects
if (symbol === argumentsSymbol) {
if (isInPropertyInitializer(node)) {
if (isInPropertyInitializerOrClassStaticBlock(node)) {
error(node, Diagnostics.arguments_cannot_be_referenced_in_property_initializers);
return errorType;
}
@@ -24544,6 +24544,9 @@ namespace ts {
// do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks
}
break;
case SyntaxKind.ClassStaticBlockDeclaration:
error(node, Diagnostics.this_cannot_be_referenced_in_current_location);
break;
case SyntaxKind.ComputedPropertyName:
error(node, Diagnostics.this_cannot_be_referenced_in_a_computed_property_name);
break;
@@ -24602,7 +24605,8 @@ namespace ts {
if (isClassLike(container.parent)) {
const symbol = getSymbolOfNode(container.parent);
const type = hasSyntacticModifier(container, ModifierFlags.Static) ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol) as InterfaceType).thisType!;
const isStatic = hasSyntacticModifier(container, ModifierFlags.Static) || isClassStaticBlockDeclaration(container);
const type = isStatic ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol) as InterfaceType).thisType!;
return getFlowTypeOfReference(node, type);
}
@@ -27565,7 +27569,7 @@ namespace ts {
let diagnosticMessage;
const declarationName = idText(right);
if (isInPropertyInitializer(node)
if (isInPropertyInitializerOrClassStaticBlock(node)
&& !isOptionalPropertyDeclaration(valueDeclaration)
&& !(isAccessExpression(node) && isAccessExpression(node.expression))
&& !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
@@ -27586,7 +27590,7 @@ namespace ts {
}
}
function isInPropertyInitializer(node: Node): boolean {
function isInPropertyInitializerOrClassStaticBlock(node: Node): boolean {
return !!findAncestor(node, node => {
switch (node.kind) {
case SyntaxKind.PropertyDeclaration:
@@ -27606,6 +27610,8 @@ namespace ts {
case SyntaxKind.ExpressionWithTypeArguments:
case SyntaxKind.HeritageClause:
return false;
case SyntaxKind.ExpressionStatement:
return isBlock(node.parent) && isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit";
default:
return isExpressionNode(node) ? false : "quit";
}
@@ -31303,7 +31309,11 @@ namespace ts {
function checkAwaitExpression(node: AwaitExpression): Type {
// Grammar checking
if (produceDiagnostics) {
if (!(node.flags & NodeFlags.AwaitContext)) {
const container = getContainingFunctionOrClassStaticBlock(node);
if (container && isClassStaticBlockDeclaration(container)) {
error(node, Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
}
else if (!(node.flags & NodeFlags.AwaitContext)) {
if (isInTopLevelContext(node)) {
const sourceFile = getSourceFileOfNode(node);
if (!hasParseDiagnostics(sourceFile)) {
@@ -31328,9 +31338,8 @@ namespace ts {
if (!hasParseDiagnostics(sourceFile)) {
const span = getSpanOfTokenAtPosition(sourceFile, node.pos);
const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules);
const func = getContainingFunction(node);
if (func && func.kind !== SyntaxKind.Constructor && (getFunctionFlags(func) & FunctionFlags.Async) === 0) {
const relatedInfo = createDiagnosticForNode(func, Diagnostics.Did_you_mean_to_mark_this_function_as_async);
if (container && container.kind !== SyntaxKind.Constructor && (getFunctionFlags(container) & FunctionFlags.Async) === 0) {
const relatedInfo = createDiagnosticForNode(container, Diagnostics.Did_you_mean_to_mark_this_function_as_async);
addRelatedInfo(diagnostic, relatedInfo);
}
diagnostics.add(diagnostic);
@@ -33489,6 +33498,12 @@ namespace ts {
}
}
function checkClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration) {
checkGrammarDecoratorsAndModifiers(node);
forEachChild(node, checkSourceElement);
}
function checkConstructorDeclaration(node: ConstructorDeclaration) {
// Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function.
checkSignatureDeclaration(node);
@@ -35096,10 +35111,11 @@ namespace ts {
break;
case SyntaxKind.IndexSignature:
case SyntaxKind.SemicolonClassElement:
case SyntaxKind.ClassStaticBlockDeclaration:
// Can't be private
break;
default:
Debug.fail();
Debug.fail("Unexpected class member");
}
}
}
@@ -35531,6 +35547,7 @@ namespace ts {
if (!node.name) {
return;
}
// For a computed property, just check the initializer and exit
// Do not use hasDynamicName here, because that returns false for well known symbols.
// We want to perform checkComputedPropertyName for all computed properties, including
@@ -35907,11 +35924,17 @@ namespace ts {
function checkForOfStatement(node: ForOfStatement): void {
checkGrammarForInOrForOfStatement(node);
const container = getContainingFunctionOrClassStaticBlock(node);
if (node.awaitModifier) {
const functionFlags = getFunctionFlags(getContainingFunction(node));
if ((functionFlags & (FunctionFlags.Invalid | FunctionFlags.Async)) === FunctionFlags.Async && languageVersion < ScriptTarget.ESNext) {
// for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper
checkExternalEmitHelpers(node, ExternalEmitHelpers.ForAwaitOfIncludes);
if (container && isClassStaticBlockDeclaration(container)) {
grammarErrorOnNode(node.awaitModifier, Diagnostics.For_await_loops_cannot_be_used_inside_a_class_static_block);
}
else {
const functionFlags = getFunctionFlags(container);
if ((functionFlags & (FunctionFlags.Invalid | FunctionFlags.Async)) === FunctionFlags.Async && languageVersion < ScriptTarget.ESNext) {
// for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper
checkExternalEmitHelpers(node, ExternalEmitHelpers.ForAwaitOfIncludes);
}
}
}
else if (compilerOptions.downlevelIteration && languageVersion < ScriptTarget.ES2015) {
@@ -36791,28 +36814,33 @@ namespace ts {
return;
}
const func = getContainingFunction(node);
if (!func) {
const container = getContainingFunctionOrClassStaticBlock(node);
if(container && isClassStaticBlockDeclaration(container)) {
grammarErrorOnFirstToken(node, Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block);
return;
}
if (!container) {
grammarErrorOnFirstToken(node, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body);
return;
}
const signature = getSignatureFromDeclaration(func);
const signature = getSignatureFromDeclaration(container);
const returnType = getReturnTypeOfSignature(signature);
const functionFlags = getFunctionFlags(func);
const functionFlags = getFunctionFlags(container);
if (strictNullChecks || node.expression || returnType.flags & TypeFlags.Never) {
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
if (func.kind === SyntaxKind.SetAccessor) {
if (container.kind === SyntaxKind.SetAccessor) {
if (node.expression) {
error(node, Diagnostics.Setters_cannot_return_a_value);
}
}
else if (func.kind === SyntaxKind.Constructor) {
else if (container.kind === SyntaxKind.Constructor) {
if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
error(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
}
}
else if (getReturnTypeFromAnnotation(func)) {
else if (getReturnTypeFromAnnotation(container)) {
const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
const unwrappedExprType = functionFlags & FunctionFlags.Async
? checkAwaitedType(exprType, node, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)
@@ -36825,7 +36853,7 @@ namespace ts {
}
}
}
else if (func.kind !== SyntaxKind.Constructor && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) {
else if (container.kind !== SyntaxKind.Constructor && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) {
// The function has a return type, but the return statement doesn't have an expression.
error(node, Diagnostics.Not_all_code_paths_return_a_value);
}
@@ -38655,6 +38683,8 @@ namespace ts {
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
return checkMethodDeclaration(node as MethodDeclaration | MethodSignature);
case SyntaxKind.ClassStaticBlockDeclaration:
return checkClassStaticBlockDeclaration(node as ClassStaticBlockDeclaration);
case SyntaxKind.Constructor:
return checkConstructorDeclaration(node as ConstructorDeclaration);
case SyntaxKind.GetAccessor:
@@ -41132,6 +41162,7 @@ namespace ts {
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.VariableStatement:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.ClassStaticBlockDeclaration:
return true;
case SyntaxKind.EnumDeclaration:
return nodeHasAnyModifiersExcept(node, SyntaxKind.ConstKeyword);
@@ -41869,7 +41900,7 @@ namespace ts {
function checkGrammarBreakOrContinueStatement(node: BreakOrContinueStatement): boolean {
let current: Node = node;
while (current) {
if (isFunctionLike(current)) {
if (isFunctionLikeOrClassStaticBlockDeclaration(current)) {
return grammarErrorOnNode(node, Diagnostics.Jump_target_cannot_cross_function_boundary);
}
+16
View File
@@ -7154,5 +7154,21 @@
"Class decorators can't be used with static private identifier. Consider removing the experimental decorator.": {
"category": "Error",
"code": 18036
},
"Await expression cannot be used inside a class static block.": {
"category": "Error",
"code": 18037
},
"'For await' loops cannot be used inside a class static block.": {
"category": "Error",
"code": 18038
},
"Invalid use of '{0}'. It cannot be used inside a class static block.": {
"category": "Error",
"code": 18039
},
"A 'return' statement cannot be used inside a class static block.": {
"category": "Error",
"code": 18041
}
}
+9
View File
@@ -1351,6 +1351,8 @@ namespace ts {
return emitMethodSignature(node as MethodSignature);
case SyntaxKind.MethodDeclaration:
return emitMethodDeclaration(node as MethodDeclaration);
case SyntaxKind.ClassStaticBlockDeclaration:
return emitClassStaticBlockDeclaration(node as ClassStaticBlockDeclaration);
case SyntaxKind.Constructor:
return emitConstructor(node as ConstructorDeclaration);
case SyntaxKind.GetAccessor:
@@ -2063,6 +2065,13 @@ namespace ts {
emitSignatureAndBody(node, emitSignatureHead);
}
function emitClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration) {
emitDecorators(node, node.decorators);
emitModifiers(node, node.modifiers);
writeKeyword("static");
emitBlockFunctionBody(node.body);
}
function emitConstructor(node: ConstructorDeclaration) {
emitModifiers(node, node.modifiers);
writeKeyword("constructor");
+34
View File
@@ -94,6 +94,8 @@ namespace ts {
updateConstructSignature,
createIndexSignature,
updateIndexSignature,
createClassStaticBlockDeclaration,
updateClassStaticBlockDeclaration,
createTemplateLiteralTypeSpan,
updateTemplateLiteralTypeSpan,
createKeywordTypeNode,
@@ -1415,6 +1417,38 @@ namespace ts {
: node;
}
// @api
function createClassStaticBlockDeclaration(
decorators: readonly Decorator[] | undefined,
modifiers: readonly Modifier[] | undefined,
body: Block
): ClassStaticBlockDeclaration {
const node = createBaseGenericNamedDeclaration<ClassStaticBlockDeclaration>(
SyntaxKind.ClassStaticBlockDeclaration,
decorators,
modifiers,
/*name*/ undefined,
/*typeParameters*/ undefined
);
node.body = body;
node.transformFlags = propagateChildFlags(body) | TransformFlags.ContainsClassFields;
return node;
}
// @api
function updateClassStaticBlockDeclaration(
node: ClassStaticBlockDeclaration,
decorators: readonly Decorator[] | undefined,
modifiers: readonly Modifier[] | undefined,
body: Block
): ClassStaticBlockDeclaration {
return node.decorators !== decorators
|| node.modifier !== modifiers
|| node.body !== body
? update(createClassStaticBlockDeclaration(decorators, modifiers, body), node)
: node;
}
// @api
function createConstructorDeclaration(
decorators: readonly Decorator[] | undefined,
+4
View File
@@ -182,6 +182,10 @@ namespace ts {
return node.kind === SyntaxKind.MethodDeclaration;
}
export function isClassStaticBlockDeclaration(node: Node): node is ClassStaticBlockDeclaration {
return node.kind === SyntaxKind.ClassStaticBlockDeclaration;
}
export function isConstructorDeclaration(node: Node): node is ConstructorDeclaration {
return node.kind === SyntaxKind.Constructor;
}
+46 -14
View File
@@ -168,6 +168,10 @@ namespace ts {
visitNode(cbNode, (node as FunctionLikeDeclaration).type) ||
visitNode(cbNode, (node as ArrowFunction).equalsGreaterThanToken) ||
visitNode(cbNode, (node as FunctionLikeDeclaration).body);
case SyntaxKind.ClassStaticBlockDeclaration:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, (node as ClassStaticBlockDeclaration).body);
case SyntaxKind.TypeReference:
return visitNode(cbNode, (node as TypeReferenceNode).typeName) ||
visitNodes(cbNode, cbNodes, (node as TypeReferenceNode).typeArguments);
@@ -5573,10 +5577,8 @@ namespace ts {
//
// FunctionExpression:
// function BindingIdentifier[opt](FormalParameters){ FunctionBody }
const saveDecoratorContext = inDecoratorContext();
if (saveDecoratorContext) {
setDecoratorContext(/*val*/ false);
}
const savedDecoratorContext = inDecoratorContext();
setDecoratorContext(/*val*/ false);
const pos = getNodePos();
const hasJSDoc = hasPrecedingJSDocComment();
@@ -5585,8 +5587,7 @@ namespace ts {
const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
const isGenerator = asteriskToken ? SignatureFlags.Yield : SignatureFlags.None;
const isAsync = some(modifiers, isAsyncModifier) ? SignatureFlags.Await : SignatureFlags.None;
const name =
isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) :
const name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) :
isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) :
isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) :
parseOptionalBindingIdentifier();
@@ -5596,9 +5597,7 @@ namespace ts {
const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false);
const body = parseFunctionBlock(isGenerator | isAsync);
if (saveDecoratorContext) {
setDecoratorContext(/*val*/ true);
}
setDecoratorContext(savedDecoratorContext);
const node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
return withJSDoc(finishNode(node, pos), hasJSDoc);
@@ -6422,7 +6421,7 @@ namespace ts {
// So we need to look ahead to determine if 'of' should be treated as a keyword in
// this context.
// The checker will then give an error that there is an empty declaration list.
let declarations;
let declarations: readonly VariableDeclaration[];
if (token() === SyntaxKind.OfKeyword && lookAhead(canFollowContextualOfKeyword)) {
declarations = createMissingList<VariableDeclaration>();
}
@@ -6454,6 +6453,7 @@ namespace ts {
function parseFunctionDeclaration(pos: number, hasJSDoc: boolean, decorators: NodeArray<Decorator> | undefined, modifiers: NodeArray<Modifier> | undefined): FunctionDeclaration {
const savedAwaitContext = inAwaitContext();
const modifierFlags = modifiersToFlags(modifiers);
parseExpected(SyntaxKind.FunctionKeyword);
const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
@@ -6649,6 +6649,27 @@ namespace ts {
return false;
}
function parseClassStaticBlockDeclaration(pos: number, hasJSDoc: boolean, decorators: NodeArray<Decorator> | undefined, modifiers: ModifiersArray | undefined): ClassStaticBlockDeclaration {
parseExpectedToken(SyntaxKind.StaticKeyword);
const body = parseClassStaticBlockBody();
return withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(decorators, modifiers, body), pos), hasJSDoc);
}
function parseClassStaticBlockBody() {
const savedYieldContext = inYieldContext();
const savedAwaitContext = inAwaitContext();
setYieldContext(false);
setAwaitContext(true);
const body = parseBlock(/*ignoreMissingOpenBrace*/ false);
setYieldContext(savedYieldContext);
setAwaitContext(savedAwaitContext);
return body;
}
function parseDecoratorExpression() {
if (inAwaitContext() && token() === SyntaxKind.AwaitKeyword) {
// `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails
@@ -6680,7 +6701,7 @@ namespace ts {
return list && createNodeArray(list, pos);
}
function tryParseModifier(permitInvalidConstAsModifier?: boolean): Modifier | undefined {
function tryParseModifier(permitInvalidConstAsModifier?: boolean, stopOnStartOfClassStaticBlock?: boolean): Modifier | undefined {
const pos = getNodePos();
const kind = token();
@@ -6691,6 +6712,9 @@ namespace ts {
return undefined;
}
}
else if (stopOnStartOfClassStaticBlock && token() === SyntaxKind.StaticKeyword && lookAhead(nextTokenIsOpenBrace)) {
return undefined;
}
else {
if (!parseAnyContextualModifier()) {
return undefined;
@@ -6707,10 +6731,10 @@ namespace ts {
*
* In such situations, 'permitInvalidConstAsModifier' should be set to true.
*/
function parseModifiers(permitInvalidConstAsModifier?: boolean): NodeArray<Modifier> | undefined {
function parseModifiers(permitInvalidConstAsModifier?: boolean, stopOnStartOfClassStaticBlock?: boolean): NodeArray<Modifier> | undefined {
const pos = getNodePos();
let list, modifier;
while (modifier = tryParseModifier(permitInvalidConstAsModifier)) {
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock)) {
list = append(list, modifier);
}
return list && createNodeArray(list, pos);
@@ -6736,7 +6760,10 @@ namespace ts {
const hasJSDoc = hasPrecedingJSDocComment();
const decorators = parseDecorators();
const modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true);
const modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true);
if (token() === SyntaxKind.StaticKeyword && lookAhead(nextTokenIsOpenBrace)) {
return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers);
}
if (parseContextualModifier(SyntaxKind.GetKeyword)) {
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, SyntaxKind.GetAccessor);
@@ -6797,6 +6824,7 @@ namespace ts {
function parseClassDeclarationOrExpression(pos: number, hasJSDoc: boolean, decorators: NodeArray<Decorator> | undefined, modifiers: NodeArray<Modifier> | undefined, kind: ClassLikeDeclaration["kind"]): ClassLikeDeclaration {
const savedAwaitContext = inAwaitContext();
parseExpected(SyntaxKind.ClassKeyword);
// We don't parse the name here in await context, instead we will report a grammar error in the checker.
const name = parseNameOfClassDeclarationOrExpression();
const typeParameters = parseTypeParameters();
@@ -6998,6 +7026,10 @@ namespace ts {
return nextToken() === SyntaxKind.OpenParenToken;
}
function nextTokenIsOpenBrace() {
return nextToken() === SyntaxKind.OpenBraceToken;
}
function nextTokenIsSlash() {
return nextToken() === SyntaxKind.SlashToken;
}
+61 -34
View File
@@ -102,6 +102,7 @@ namespace ts {
factory,
hoistVariableDeclaration,
endLexicalEnvironment,
startLexicalEnvironment,
resumeLexicalEnvironment,
addBlockScopedVariable
} = context;
@@ -110,7 +111,7 @@ namespace ts {
const languageVersion = getEmitScriptTarget(compilerOptions);
const useDefineForClassFields = getUseDefineForClassFields(compilerOptions);
const shouldTransformPrivateElements = languageVersion < ScriptTarget.ESNext;
const shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < ScriptTarget.ESNext;
const previousOnSubstituteNode = context.onSubstituteNode;
context.onSubstituteNode = onSubstituteNode;
@@ -176,10 +177,20 @@ namespace ts {
return visitForStatement(node as ForStatement);
case SyntaxKind.TaggedTemplateExpression:
return visitTaggedTemplateExpression(node as TaggedTemplateExpression);
case SyntaxKind.ClassStaticBlockDeclaration:
return visitClassStaticBlockDeclaration(node as ClassStaticBlockDeclaration);
}
return visitEachChild(node, visitor, context);
}
function visitClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration) {
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
return visitEachChild(node, classElementVisitor, context);
}
// ClassStaticBlockDeclaration for classes are transformed in `visitClassDeclaration` or `visitClassExpression`.
return undefined;
}
function visitorDestructuringTarget(node: Node): VisitResult<Node> {
switch (node.kind) {
case SyntaxKind.ObjectLiteralExpression:
@@ -195,7 +206,7 @@ namespace ts {
* Replace it with an empty identifier to indicate a problem with the code.
*/
function visitPrivateIdentifier(node: PrivateIdentifier) {
if (!shouldTransformPrivateElements) {
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
return node;
}
return setOriginalNode(factory.createIdentifier(""), node);
@@ -262,7 +273,7 @@ namespace ts {
function visitMethodOrAccessorDeclaration(node: MethodDeclaration | AccessorDeclaration) {
Debug.assert(!some(node.decorators));
if (!shouldTransformPrivateElements || !isPrivateIdentifier(node.name)) {
if (!shouldTransformPrivateElementsOrClassStaticBlocks || !isPrivateIdentifier(node.name)) {
return visitEachChild(node, classElementVisitor, context);
}
@@ -318,7 +329,7 @@ namespace ts {
Debug.assert(!some(node.decorators));
if (isPrivateIdentifier(node.name)) {
if (!shouldTransformPrivateElements) {
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
// Initializer is elided as the field is initialized in transformConstructor.
return factory.updatePropertyDeclaration(
node,
@@ -383,7 +394,7 @@ namespace ts {
}
function visitPropertyAccessExpression(node: PropertyAccessExpression) {
if (shouldTransformPrivateElements && isPrivateIdentifier(node.name)) {
if (shouldTransformPrivateElementsOrClassStaticBlocks && isPrivateIdentifier(node.name)) {
const privateIdentifierInfo = accessPrivateIdentifier(node.name);
if (privateIdentifierInfo) {
return setTextRange(
@@ -399,7 +410,7 @@ namespace ts {
}
function visitPrefixUnaryExpression(node: PrefixUnaryExpression) {
if (shouldTransformPrivateElements && isPrivateIdentifierPropertyAccessExpression(node.operand)) {
if (shouldTransformPrivateElementsOrClassStaticBlocks && isPrivateIdentifierPropertyAccessExpression(node.operand)) {
const operator = node.operator === SyntaxKind.PlusPlusToken ?
SyntaxKind.PlusToken : node.operator === SyntaxKind.MinusMinusToken ?
SyntaxKind.MinusToken : undefined;
@@ -425,7 +436,7 @@ namespace ts {
}
function visitPostfixUnaryExpression(node: PostfixUnaryExpression, valueIsDiscarded: boolean) {
if (shouldTransformPrivateElements && isPrivateIdentifierPropertyAccessExpression(node.operand)) {
if (shouldTransformPrivateElementsOrClassStaticBlocks && isPrivateIdentifierPropertyAccessExpression(node.operand)) {
const operator = node.operator === SyntaxKind.PlusPlusToken ?
SyntaxKind.PlusToken : node.operator === SyntaxKind.MinusMinusToken ?
SyntaxKind.MinusToken : undefined;
@@ -491,7 +502,7 @@ namespace ts {
}
function visitCallExpression(node: CallExpression) {
if (shouldTransformPrivateElements && isPrivateIdentifierPropertyAccessExpression(node.expression)) {
if (shouldTransformPrivateElementsOrClassStaticBlocks && isPrivateIdentifierPropertyAccessExpression(node.expression)) {
// Transform call expressions of private names to properly bind the `this` parameter.
const { thisArg, target } = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion);
if (isCallChain(node)) {
@@ -514,7 +525,7 @@ namespace ts {
}
function visitTaggedTemplateExpression(node: TaggedTemplateExpression) {
if (shouldTransformPrivateElements && isPrivateIdentifierPropertyAccessExpression(node.tag)) {
if (shouldTransformPrivateElementsOrClassStaticBlocks && isPrivateIdentifierPropertyAccessExpression(node.tag)) {
// Bind the `this` correctly for tagged template literals when the tag is a private identifier property access.
const { thisArg, target } = factory.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion);
return factory.updateTaggedTemplateExpression(
@@ -531,8 +542,24 @@ namespace ts {
return visitEachChild(node, visitor, context);
}
function transformClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration) {
if (shouldTransformPrivateElementsOrClassStaticBlocks) {
startLexicalEnvironment();
let statements = visitNodes(node.body.statements, visitor, isStatement);
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
return setTextRange(
setOriginalNode(
factory.createImmediatelyInvokedArrowFunction(statements),
node
),
node
);
}
}
function visitBinaryExpression(node: BinaryExpression) {
if (shouldTransformPrivateElements) {
if (shouldTransformPrivateElementsOrClassStaticBlocks) {
if (isDestructuringAssignment(node)) {
const savedPendingExpressions = pendingExpressions;
pendingExpressions = undefined;
@@ -616,7 +643,7 @@ namespace ts {
function visitClassLike(node: ClassLikeDeclaration) {
const savedPendingExpressions = pendingExpressions;
pendingExpressions = undefined;
if (shouldTransformPrivateElements) {
if (shouldTransformPrivateElementsOrClassStaticBlocks) {
startPrivateIdentifierEnvironment();
const name = getNameOfDeclaration(node);
@@ -637,7 +664,7 @@ namespace ts {
visitClassDeclaration(node) :
visitClassExpression(node);
if (shouldTransformPrivateElements) {
if (shouldTransformPrivateElementsOrClassStaticBlocks) {
endPrivateIdentifierEnvironment();
}
pendingExpressions = savedPendingExpressions;
@@ -645,7 +672,7 @@ namespace ts {
}
function doesClassElementNeedTransform(node: ClassElement) {
return isPropertyDeclaration(node) || (shouldTransformPrivateElements && node.name && isPrivateIdentifier(node.name));
return isPropertyDeclaration(node) || isClassStaticBlockDeclaration(node) || (shouldTransformPrivateElementsOrClassStaticBlocks && node.name && isPrivateIdentifier(node.name));
}
function getPrivateInstanceMethodsAndAccessors(node: ClassLikeDeclaration) {
@@ -657,9 +684,9 @@ namespace ts {
return visitEachChild(node, visitor, context);
}
const staticProperties = getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true);
const staticProperties = getStaticPropertiesAndClassStaticBlock(node);
let pendingPrivateStateAssignment: BinaryExpression | undefined;
if (shouldTransformPrivateElements && some(node.members, m => hasStaticModifier(m) && !!m.name && isPrivateIdentifier(m.name))) {
if (shouldTransformPrivateElementsOrClassStaticBlocks && some(node.members, m => hasStaticModifier(m) && !!m.name && isPrivateIdentifier(m.name))) {
const temp = factory.createTempVariable(hoistVariableDeclaration, /* reservedInNestedScopes */ true);
getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp);
pendingPrivateStateAssignment = factory.createAssignment(
@@ -699,7 +726,7 @@ namespace ts {
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
if (some(staticProperties)) {
addPropertyStatements(statements, staticProperties, factory.getInternalName(node));
addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
}
return statements;
@@ -719,7 +746,7 @@ namespace ts {
// these statements after the class expression variable statement.
const isDecoratedClassDeclaration = isClassDeclaration(getOriginalNode(node));
const staticProperties = getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true);
const staticPropertiesOrClassStaticBlocks = getStaticPropertiesAndClassStaticBlock(node);
const extendsClauseElement = getEffectiveBaseTypeNode(node);
const isDerivedClass = !!(extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== SyntaxKind.NullKeyword);
@@ -732,7 +759,7 @@ namespace ts {
const requiresBlockScopedVar = classCheckFlags & NodeCheckFlags.BlockScopedBindingInLoop;
return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference);
}
if (shouldTransformPrivateElements && some(node.members, m => hasStaticModifier(m) && !!m.name && isPrivateIdentifier(m.name))) {
if (shouldTransformPrivateElementsOrClassStaticBlocks && some(node.members, m => hasStaticModifier(m) && !!m.name && isPrivateIdentifier(m.name))) {
temp = createClassTempVar();
getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp);
}
@@ -746,7 +773,7 @@ namespace ts {
visitNodes(node.heritageClauses, visitor, isHeritageClause),
transformClassMembers(node, isDerivedClass)
);
const hasTransformableStatics = some(staticProperties, p => !!p.initializer || (shouldTransformPrivateElements && isPrivateIdentifier(p.name)));
const hasTransformableStatics = some(staticPropertiesOrClassStaticBlocks, p => isClassStaticBlockDeclaration(p) || !!p.initializer || (shouldTransformPrivateElementsOrClassStaticBlocks && isPrivateIdentifier(p.name)));
if (hasTransformableStatics || some(pendingExpressions)) {
if (isDecoratedClassDeclaration) {
Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
@@ -756,8 +783,8 @@ namespace ts {
pendingStatements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
}
if (pendingStatements && some(staticProperties)) {
addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node));
if (pendingStatements && some(staticPropertiesOrClassStaticBlocks)) {
addPropertyOrClassStaticBlockStatements(pendingStatements, staticPropertiesOrClassStaticBlocks, factory.getInternalName(node));
}
if (temp) {
return factory.inlineExpressions([factory.createAssignment(temp, classExpression), temp]);
@@ -781,7 +808,7 @@ namespace ts {
expressions.push(startOnNewLine(factory.createAssignment(temp, classExpression)));
// Add any pending expressions leftover from elided or relocated computed property names
addRange(expressions, map(pendingExpressions, startOnNewLine));
addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp));
addRange(expressions, generateInitializedPropertyExpressionsOrClassStaticBlock(staticPropertiesOrClassStaticBlocks, temp));
expressions.push(startOnNewLine(temp));
@@ -793,7 +820,7 @@ namespace ts {
}
function transformClassMembers(node: ClassDeclaration | ClassExpression, isDerivedClass: boolean) {
if (shouldTransformPrivateElements) {
if (shouldTransformPrivateElementsOrClassStaticBlocks) {
// Declare private names.
for (const member of node.members) {
if (isPrivateIdentifierClassElementDeclaration(member)) {
@@ -840,7 +867,7 @@ namespace ts {
// then we don't need to transform any class properties.
return languageVersion < ScriptTarget.ESNext;
}
return isInitializedProperty(member) || shouldTransformPrivateElements && isPrivateIdentifierClassElementDeclaration(member);
return isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && isPrivateIdentifierClassElementDeclaration(member);
}
function transformConstructor(node: ClassDeclaration | ClassExpression, isDerivedClass: boolean) {
@@ -933,7 +960,7 @@ namespace ts {
const receiver = factory.createThis();
// private methods can be called in property initializers, they should execute first.
addMethodStatements(statements, privateMethodsAndAccessors, receiver);
addPropertyStatements(statements, properties, receiver);
addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
// Add existing statements, skipping the initial super call.
if (constructor) {
@@ -960,9 +987,9 @@ namespace ts {
* @param properties An array of property declarations to transform.
* @param receiver The receiver on which each property should be assigned.
*/
function addPropertyStatements(statements: Statement[], properties: readonly PropertyDeclaration[], receiver: LeftHandSideExpression) {
function addPropertyOrClassStaticBlockStatements(statements: Statement[], properties: readonly (PropertyDeclaration | ClassStaticBlockDeclaration)[], receiver: LeftHandSideExpression) {
for (const property of properties) {
const expression = transformProperty(property, receiver);
const expression = isClassStaticBlockDeclaration(property) ? transformClassStaticBlockDeclaration(property) : transformProperty(property, receiver);
if (!expression) {
continue;
}
@@ -977,13 +1004,13 @@ namespace ts {
/**
* Generates assignment expressions for property initializers.
*
* @param properties An array of property declarations to transform.
* @param propertiesOrClassStaticBlocks An array of property declarations to transform.
* @param receiver The receiver on which each property should be assigned.
*/
function generateInitializedPropertyExpressions(properties: readonly PropertyDeclaration[], receiver: LeftHandSideExpression) {
function generateInitializedPropertyExpressionsOrClassStaticBlock(propertiesOrClassStaticBlocks: readonly (PropertyDeclaration | ClassStaticBlockDeclaration)[], receiver: LeftHandSideExpression) {
const expressions: Expression[] = [];
for (const property of properties) {
const expression = transformProperty(property, receiver);
for (const property of propertiesOrClassStaticBlocks) {
const expression = isClassStaticBlockDeclaration(property) ? transformClassStaticBlockDeclaration(property) : transformProperty(property, receiver);
if (!expression) {
continue;
}
@@ -1010,7 +1037,7 @@ namespace ts {
? factory.updateComputedPropertyName(property.name, factory.getGeneratedNameForNode(property.name))
: property.name;
if (shouldTransformPrivateElements && isPrivateIdentifier(propertyName)) {
if (shouldTransformPrivateElementsOrClassStaticBlocks && isPrivateIdentifier(propertyName)) {
const privateIdentifierInfo = accessPrivateIdentifier(propertyName);
if (privateIdentifierInfo) {
if (privateIdentifierInfo.kind === PrivateIdentifierKind.Field) {
@@ -1082,7 +1109,7 @@ namespace ts {
* @param receiver The receiver on which each method should be assigned.
*/
function addMethodStatements(statements: Statement[], methods: readonly (MethodDeclaration | AccessorDeclaration)[], receiver: LeftHandSideExpression) {
if (!shouldTransformPrivateElements || !some(methods)) {
if (!shouldTransformPrivateElementsOrClassStaticBlocks || !some(methods)) {
return;
}
@@ -1337,7 +1364,7 @@ namespace ts {
getPendingExpressions().push(...assignmentExpressions);
}
function createHoistedVariableForClass(name: string, node: PrivateIdentifier): Identifier {
function createHoistedVariableForClass(name: string, node: PrivateIdentifier | ClassStaticBlockDeclaration): Identifier {
const { className } = getPrivateIdentifierEnvironment();
const prefix = className ? `_${className}` : "";
const identifier = factory.createUniqueName(`${prefix}_${name}`, GeneratedIdentifierFlags.Optimistic);
@@ -569,6 +569,8 @@ namespace ts {
case SyntaxKind.ExportDeclaration:
case SyntaxKind.ExportAssignment:
return false;
case SyntaxKind.ClassStaticBlockDeclaration:
return true;
}
return false;
}
+1
View File
@@ -1610,6 +1610,7 @@ namespace ts {
break;
case SyntaxKind.Constructor:
case SyntaxKind.ClassStaticBlockDeclaration:
// Constructors are handled in visitClassExpression/visitClassDeclaration
break;
+1
View File
@@ -324,6 +324,7 @@ namespace ts {
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.ClassStaticBlockDeclaration:
// Fallback to the default visit behavior.
return visitorWorker(node);
+14
View File
@@ -342,6 +342,16 @@ namespace ts {
return filter(node.members, m => isInitializedOrStaticProperty(m, requireInitializer, isStatic)) as PropertyDeclaration[];
}
function isStaticPropertyDeclarationOrClassStaticBlockDeclaration(element: ClassElement): element is PropertyDeclaration | ClassStaticBlockDeclaration {
return isStaticPropertyDeclaration(element) || isClassStaticBlockDeclaration(element);
}
export function getStaticPropertiesAndClassStaticBlock(node: ClassExpression | ClassDeclaration): readonly (PropertyDeclaration | ClassStaticBlockDeclaration)[];
export function getStaticPropertiesAndClassStaticBlock(node: ClassExpression | ClassDeclaration): readonly (PropertyDeclaration | ClassStaticBlockDeclaration)[];
export function getStaticPropertiesAndClassStaticBlock(node: ClassExpression | ClassDeclaration): readonly (PropertyDeclaration | ClassStaticBlockDeclaration)[] {
return filter(node.members, isStaticPropertyDeclarationOrClassStaticBlockDeclaration);
}
/**
* Is a class element either a static or an instance property declaration with an initializer?
*
@@ -354,6 +364,10 @@ namespace ts {
&& hasStaticModifier(member) === isStatic;
}
function isStaticPropertyDeclaration(member: ClassElement) {
return isPropertyDeclaration(member) && hasStaticModifier(member);
}
/**
* Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer.
*
+12
View File
@@ -206,6 +206,7 @@ namespace ts {
PropertyDeclaration,
MethodSignature,
MethodDeclaration,
ClassStaticBlockDeclaration,
Constructor,
GetAccessor,
SetAccessor,
@@ -873,6 +874,7 @@ namespace ts {
export type HasJSDoc =
| ParameterDeclaration
| CallSignatureDeclaration
| ClassStaticBlockDeclaration
| ConstructSignatureDeclaration
| MethodSignature
| PropertySignature
@@ -1535,6 +1537,14 @@ namespace ts {
readonly type: TypeNode;
}
export interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer {
readonly kind: SyntaxKind.ClassStaticBlockDeclaration;
readonly parent: ClassDeclaration | ClassExpression;
readonly body: Block;
/* @internal */ readonly decorators?: NodeArray<Decorator>; // Present for use with reporting a grammar error
/* @internal */ readonly modifier?: ModifiersArray; // Present for use with reporting a grammar error
}
export interface TypeNode extends Node {
_typeNodeBrand: any;
}
@@ -7054,6 +7064,8 @@ namespace ts {
updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
createTemplateLiteralTypeSpan(type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan;
updateTemplateLiteralTypeSpan(node: TemplateLiteralTypeSpan, type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan;
createClassStaticBlockDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration;
updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration;
//
// Types
+17 -2
View File
@@ -281,6 +281,7 @@ namespace ts {
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.ClassStaticBlockDeclaration:
return true;
}
return false;
@@ -759,7 +760,7 @@ namespace ts {
export function isBlockScopedContainerTopLevel(node: Node): boolean {
return node.kind === SyntaxKind.SourceFile ||
node.kind === SyntaxKind.ModuleDeclaration ||
isFunctionLike(node);
isFunctionLikeOrClassStaticBlockDeclaration(node);
}
export function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean {
@@ -849,7 +850,7 @@ namespace ts {
case SyntaxKind.Block:
// function block is not considered block-scope container
// see comment in binder.ts: bind(...), case for SyntaxKind.Block
return !isFunctionLike(parentNode);
return !isFunctionLikeOrClassStaticBlockDeclaration(parentNode);
}
return false;
@@ -1573,6 +1574,19 @@ namespace ts {
return findAncestor(node.parent, isClassLike);
}
export function getContainingClassStaticBlock(node: Node): Node | undefined {
return findAncestor(node.parent, n => {
if (isClassLike(n) || isFunctionLike(n)) {
return "quit";
}
return isClassStaticBlockDeclaration(n);
});
}
export function getContainingFunctionOrClassStaticBlock(node: Node): SignatureDeclaration | ClassStaticBlockDeclaration | undefined {
return findAncestor(node.parent, isFunctionLikeOrClassStaticBlockDeclaration);
}
export function getThisContainer(node: Node, includeArrowFunctions: boolean): Node {
Debug.assert(node.kind !== SyntaxKind.SourceFile);
while (true) {
@@ -1618,6 +1632,7 @@ namespace ts {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ClassStaticBlockDeclaration:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
case SyntaxKind.MethodDeclaration:
+7
View File
@@ -1227,6 +1227,11 @@ namespace ts {
return !!node && isFunctionLikeKind(node.kind);
}
/* @internal */
export function isFunctionLikeOrClassStaticBlockDeclaration(node: Node | undefined): node is SignatureDeclaration | ClassStaticBlockDeclaration {
return !!node && (isFunctionLikeKind(node.kind) || isClassStaticBlockDeclaration(node));
}
/* @internal */
export function isFunctionLikeDeclaration(node: Node): node is FunctionLikeDeclaration {
return node && isFunctionLikeDeclarationKind(node.kind);
@@ -1283,6 +1288,7 @@ namespace ts {
|| kind === SyntaxKind.GetAccessor
|| kind === SyntaxKind.SetAccessor
|| kind === SyntaxKind.IndexSignature
|| kind === SyntaxKind.ClassStaticBlockDeclaration
|| kind === SyntaxKind.SemicolonClassElement;
}
@@ -1688,6 +1694,7 @@ namespace ts {
|| kind === SyntaxKind.BindingElement
|| kind === SyntaxKind.ClassDeclaration
|| kind === SyntaxKind.ClassExpression
|| kind === SyntaxKind.ClassStaticBlockDeclaration
|| kind === SyntaxKind.Constructor
|| kind === SyntaxKind.EnumDeclaration
|| kind === SyntaxKind.EnumMember
+9
View File
@@ -475,6 +475,15 @@ namespace ts {
visitParameterList(node.parameters, visitor, context, nodesVisitor),
visitFunctionBody(node.body!, visitor, context, nodeVisitor));
case SyntaxKind.ClassStaticBlockDeclaration:
Debug.type<ClassStaticBlockDeclaration>(node);
context.startLexicalEnvironment();
context.suspendLexicalEnvironment();
return factory.updateClassStaticBlockDeclaration(node,
nodesVisitor(node.decorators, visitor, isDecorator),
nodesVisitor(node.modifiers, visitor, isModifier),
visitFunctionBody(node.body, visitor, context, nodeVisitor));
case SyntaxKind.CallSignature:
Debug.type<CallSignatureDeclaration>(node);
return factory.updateCallSignature(node,
+38 -3
View File
@@ -30,6 +30,7 @@ namespace ts.CallHierarchy {
| ModuleDeclaration & { name: Identifier }
| FunctionDeclaration
| ClassDeclaration
| ClassStaticBlockDeclaration
| MethodDeclaration
| GetAccessorDeclaration
| SetAccessorDeclaration
@@ -49,6 +50,7 @@ namespace ts.CallHierarchy {
|| isFunctionExpression(node)
|| isClassDeclaration(node)
|| isClassExpression(node)
|| isClassStaticBlockDeclaration(node)
|| isMethodDeclaration(node)
|| isMethodSignature(node)
|| isGetAccessorDeclaration(node)
@@ -65,6 +67,7 @@ namespace ts.CallHierarchy {
|| isModuleDeclaration(node) && isIdentifier(node.name)
|| isFunctionDeclaration(node)
|| isClassDeclaration(node)
|| isClassStaticBlockDeclaration(node)
|| isMethodDeclaration(node)
|| isMethodSignature(node)
|| isGetAccessorDeclaration(node)
@@ -104,6 +107,16 @@ namespace ts.CallHierarchy {
}
}
if (isClassStaticBlockDeclaration(node)) {
const sourceFile = node.getSourceFile();
const pos = skipTrivia(sourceFile.text, moveRangePastModifiers(node).pos);
const end = pos + 6; /* "static".length */
const typeChecker = program.getTypeChecker();
const symbol = typeChecker.getSymbolAtLocation(node.parent);
const prefix = symbol ? `${typeChecker.symbolToString(symbol, node.parent)} ` : "";
return { text: `${prefix}static {}`, pos, end };
}
const declName = isConstNamedExpression(node) ? node.parent.name :
Debug.checkDefined(getNameOfDeclaration(node), "Expected call hierarchy item to have a name");
@@ -197,6 +210,9 @@ namespace ts.CallHierarchy {
/** Find the implementation or the first declaration for a call hierarchy declaration. */
function findImplementationOrAllInitialDeclarations(typeChecker: TypeChecker, node: CallHierarchyDeclaration): CallHierarchyDeclaration | CallHierarchyDeclaration[] {
if (isClassStaticBlockDeclaration(node)) {
return node;
}
if (isFunctionLikeDeclaration(node)) {
return findImplementation(typeChecker, node) ??
findAllInitialDeclarations(typeChecker, node) ??
@@ -207,13 +223,14 @@ namespace ts.CallHierarchy {
/** Resolves the call hierarchy declaration for a node. */
export function resolveCallHierarchyDeclaration(program: Program, location: Node): CallHierarchyDeclaration | CallHierarchyDeclaration[] | undefined {
// A call hierarchy item must refer to either a SourceFile, Module Declaration, or something intrinsically callable that has a name:
// A call hierarchy item must refer to either a SourceFile, Module Declaration, Class Static Block, or something intrinsically callable that has a name:
// - Class Declarations
// - Class Expressions (with a name)
// - Function Declarations
// - Function Expressions (with a name or assigned to a const variable)
// - Arrow Functions (assigned to a const variable)
// - Constructors
// - Class `static {}` initializer blocks
// - Methods
// - Accessors
//
@@ -249,6 +266,10 @@ namespace ts.CallHierarchy {
}
return undefined;
}
if (location.kind === SyntaxKind.StaticKeyword && isClassStaticBlockDeclaration(location.parent)) {
location = location.parent;
continue;
}
// #39453
if (isVariableDeclaration(location) && location.initializer && isConstNamedExpression(location.initializer)) {
return location.initializer;
@@ -322,7 +343,7 @@ namespace ts.CallHierarchy {
/** Gets the call sites that call into the provided call hierarchy declaration. */
export function getIncomingCalls(program: Program, declaration: CallHierarchyDeclaration, cancellationToken: CancellationToken): CallHierarchyIncomingCall[] {
// Source files and modules have no incoming calls.
if (isSourceFile(declaration) || isModuleDeclaration(declaration)) {
if (isSourceFile(declaration) || isModuleDeclaration(declaration) || isClassStaticBlockDeclaration(declaration)) {
return [];
}
const location = getCallHierarchyDeclarationReferenceNode(declaration);
@@ -331,11 +352,12 @@ namespace ts.CallHierarchy {
}
function createCallSiteCollector(program: Program, callSites: CallSite[]): (node: Node | undefined) => void {
function recordCallSite(node: CallExpression | NewExpression | TaggedTemplateExpression | PropertyAccessExpression | ElementAccessExpression | Decorator | JsxOpeningLikeElement) {
function recordCallSite(node: CallExpression | NewExpression | TaggedTemplateExpression | PropertyAccessExpression | ElementAccessExpression | Decorator | JsxOpeningLikeElement | ClassStaticBlockDeclaration) {
const target =
isTaggedTemplateExpression(node) ? node.tag :
isJsxOpeningLikeElement(node) ? node.tagName :
isAccessExpression(node) ? node :
isClassStaticBlockDeclaration(node) ? node :
node.expression;
const declaration = resolveCallHierarchyDeclaration(program, target);
if (declaration) {
@@ -379,6 +401,9 @@ namespace ts.CallHierarchy {
case SyntaxKind.TypeAliasDeclaration:
// do not descend into nodes that cannot contain callable nodes
return;
case SyntaxKind.ClassStaticBlockDeclaration:
recordCallSite(node as ClassStaticBlockDeclaration);
return;
case SyntaxKind.TypeAssertionExpression:
case SyntaxKind.AsExpression:
// do not descend into the type side of an assertion
@@ -454,6 +479,10 @@ namespace ts.CallHierarchy {
}
}
function collectCallSitesOfClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, collect: (node: Node | undefined) => void) {
collect(node.body);
}
function collectCallSitesOfClassLikeDeclaration(node: ClassLikeDeclaration, collect: (node: Node | undefined) => void) {
forEach(node.decorators, collect);
const heritage = getClassExtendsHeritageElement(node);
@@ -469,6 +498,9 @@ namespace ts.CallHierarchy {
forEach(member.parameters, collect);
collect(member.body);
}
else if (isClassStaticBlockDeclaration(member)) {
collect(member);
}
}
}
@@ -494,6 +526,9 @@ namespace ts.CallHierarchy {
case SyntaxKind.ClassExpression:
collectCallSitesOfClassLikeDeclaration(node, collect);
break;
case SyntaxKind.ClassStaticBlockDeclaration:
collectCallSitesOfClassStaticBlockDeclaration(node, collect);
break;
default:
Debug.assertNever(node);
}
+4
View File
@@ -884,6 +884,10 @@ namespace ts.FindAllReferences {
node.kind === SyntaxKind.ReadonlyKeyword ? isReadonlyTypeOperator : undefined);
}
if (isStaticModifier(node) && isClassStaticBlockDeclaration(node.parent)) {
return [{ definition: { type: DefinitionKind.Keyword, node }, references: [nodeEntry(node)] }];
}
// Labels
if (isJumpStatementTarget(node)) {
const labelDefinition = getTargetLabel(node.parent, node.text);
+19 -4
View File
@@ -22,6 +22,19 @@ namespace ts.GoToDefinition {
return label ? [createDefinitionInfoFromName(typeChecker, label, ScriptElementKind.label, node.text, /*containerName*/ undefined!)] : undefined; // TODO: GH#18217
}
if (isStaticModifier(node) && isClassStaticBlockDeclaration(node.parent)) {
const classDecl = node.parent.parent;
const symbol = getSymbol(classDecl, typeChecker);
const staticBlocks = filter(classDecl.members, isClassStaticBlockDeclaration);
const containerName = symbol ? typeChecker.symbolToString(symbol, classDecl) : "";
const sourceFile = node.getSourceFile();
return map(staticBlocks, staticBlock => {
let { pos } = moveRangePastModifiers(staticBlock);
pos = skipTrivia(sourceFile.text, pos);
return createDefinitionInfoFromName(typeChecker, staticBlock, ScriptElementKind.constructorImplementationElement, "static {}", containerName, { start: pos, length: "static".length });
});
}
const symbol = getSymbol(node, typeChecker);
// Could not find a symbol e.g. node is string or number keyword,
@@ -305,10 +318,12 @@ namespace ts.GoToDefinition {
}
/** Creates a DefinitionInfo directly from the name of a declaration. */
function createDefinitionInfoFromName(checker: TypeChecker, declaration: Declaration, symbolKind: ScriptElementKind, symbolName: string, containerName: string): DefinitionInfo {
const name = getNameOfDeclaration(declaration) || declaration;
const sourceFile = name.getSourceFile();
const textSpan = createTextSpanFromNode(name, sourceFile);
function createDefinitionInfoFromName(checker: TypeChecker, declaration: Declaration, symbolKind: ScriptElementKind, symbolName: string, containerName: string, textSpan?: TextSpan): DefinitionInfo {
const sourceFile = declaration.getSourceFile();
if (!textSpan) {
const name = getNameOfDeclaration(declaration) || declaration;
textSpan = createTextSpanFromNode(name, sourceFile);
}
return {
fileName: sourceFile.fileName,
textSpan,
+4 -1
View File
@@ -1404,7 +1404,10 @@ namespace ts {
*/
memberVariableElement = "property",
/** class X { constructor() { } } */
/**
* class X { constructor() { } }
* class X { static { } }
*/
constructorImplementationElement = "constructor",
/** interface Y { ():number; } */
+4 -2
View File
@@ -416,7 +416,9 @@ namespace ts {
case SyntaxKind.IndexSignature: return ScriptElementKind.indexSignatureElement;
case SyntaxKind.ConstructSignature: return ScriptElementKind.constructSignatureElement;
case SyntaxKind.CallSignature: return ScriptElementKind.callSignatureElement;
case SyntaxKind.Constructor: return ScriptElementKind.constructorImplementationElement;
case SyntaxKind.Constructor:
case SyntaxKind.ClassStaticBlockDeclaration:
return ScriptElementKind.constructorImplementationElement;
case SyntaxKind.TypeParameter: return ScriptElementKind.typeParameterElement;
case SyntaxKind.EnumMember: return ScriptElementKind.enumMemberElement;
case SyntaxKind.Parameter: return hasSyntacticModifier(node, ModifierFlags.ParameterPropertyModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
@@ -1620,7 +1622,7 @@ namespace ts {
if (flags & ModifierFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier);
if (flags & ModifierFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier);
if (flags & ModifierFlags.Public) result.push(ScriptElementKindModifier.publicMemberModifier);
if (flags & ModifierFlags.Static) result.push(ScriptElementKindModifier.staticModifier);
if (flags & ModifierFlags.Static || isClassStaticBlockDeclaration(node)) result.push(ScriptElementKindModifier.staticModifier);
if (flags & ModifierFlags.Abstract) result.push(ScriptElementKindModifier.abstractModifier);
if (flags & ModifierFlags.Export) result.push(ScriptElementKindModifier.exportedModifier);
if (flags & ModifierFlags.Deprecated) result.push(ScriptElementKindModifier.deprecatedModifier);
+204 -192
View File
@@ -273,188 +273,189 @@ declare namespace ts {
PropertyDeclaration = 165,
MethodSignature = 166,
MethodDeclaration = 167,
Constructor = 168,
GetAccessor = 169,
SetAccessor = 170,
CallSignature = 171,
ConstructSignature = 172,
IndexSignature = 173,
TypePredicate = 174,
TypeReference = 175,
FunctionType = 176,
ConstructorType = 177,
TypeQuery = 178,
TypeLiteral = 179,
ArrayType = 180,
TupleType = 181,
OptionalType = 182,
RestType = 183,
UnionType = 184,
IntersectionType = 185,
ConditionalType = 186,
InferType = 187,
ParenthesizedType = 188,
ThisType = 189,
TypeOperator = 190,
IndexedAccessType = 191,
MappedType = 192,
LiteralType = 193,
NamedTupleMember = 194,
TemplateLiteralType = 195,
TemplateLiteralTypeSpan = 196,
ImportType = 197,
ObjectBindingPattern = 198,
ArrayBindingPattern = 199,
BindingElement = 200,
ArrayLiteralExpression = 201,
ObjectLiteralExpression = 202,
PropertyAccessExpression = 203,
ElementAccessExpression = 204,
CallExpression = 205,
NewExpression = 206,
TaggedTemplateExpression = 207,
TypeAssertionExpression = 208,
ParenthesizedExpression = 209,
FunctionExpression = 210,
ArrowFunction = 211,
DeleteExpression = 212,
TypeOfExpression = 213,
VoidExpression = 214,
AwaitExpression = 215,
PrefixUnaryExpression = 216,
PostfixUnaryExpression = 217,
BinaryExpression = 218,
ConditionalExpression = 219,
TemplateExpression = 220,
YieldExpression = 221,
SpreadElement = 222,
ClassExpression = 223,
OmittedExpression = 224,
ExpressionWithTypeArguments = 225,
AsExpression = 226,
NonNullExpression = 227,
MetaProperty = 228,
SyntheticExpression = 229,
TemplateSpan = 230,
SemicolonClassElement = 231,
Block = 232,
EmptyStatement = 233,
VariableStatement = 234,
ExpressionStatement = 235,
IfStatement = 236,
DoStatement = 237,
WhileStatement = 238,
ForStatement = 239,
ForInStatement = 240,
ForOfStatement = 241,
ContinueStatement = 242,
BreakStatement = 243,
ReturnStatement = 244,
WithStatement = 245,
SwitchStatement = 246,
LabeledStatement = 247,
ThrowStatement = 248,
TryStatement = 249,
DebuggerStatement = 250,
VariableDeclaration = 251,
VariableDeclarationList = 252,
FunctionDeclaration = 253,
ClassDeclaration = 254,
InterfaceDeclaration = 255,
TypeAliasDeclaration = 256,
EnumDeclaration = 257,
ModuleDeclaration = 258,
ModuleBlock = 259,
CaseBlock = 260,
NamespaceExportDeclaration = 261,
ImportEqualsDeclaration = 262,
ImportDeclaration = 263,
ImportClause = 264,
NamespaceImport = 265,
NamedImports = 266,
ImportSpecifier = 267,
ExportAssignment = 268,
ExportDeclaration = 269,
NamedExports = 270,
NamespaceExport = 271,
ExportSpecifier = 272,
MissingDeclaration = 273,
ExternalModuleReference = 274,
JsxElement = 275,
JsxSelfClosingElement = 276,
JsxOpeningElement = 277,
JsxClosingElement = 278,
JsxFragment = 279,
JsxOpeningFragment = 280,
JsxClosingFragment = 281,
JsxAttribute = 282,
JsxAttributes = 283,
JsxSpreadAttribute = 284,
JsxExpression = 285,
CaseClause = 286,
DefaultClause = 287,
HeritageClause = 288,
CatchClause = 289,
PropertyAssignment = 290,
ShorthandPropertyAssignment = 291,
SpreadAssignment = 292,
EnumMember = 293,
UnparsedPrologue = 294,
UnparsedPrepend = 295,
UnparsedText = 296,
UnparsedInternalText = 297,
UnparsedSyntheticReference = 298,
SourceFile = 299,
Bundle = 300,
UnparsedSource = 301,
InputFiles = 302,
JSDocTypeExpression = 303,
JSDocNameReference = 304,
JSDocMemberName = 305,
JSDocAllType = 306,
JSDocUnknownType = 307,
JSDocNullableType = 308,
JSDocNonNullableType = 309,
JSDocOptionalType = 310,
JSDocFunctionType = 311,
JSDocVariadicType = 312,
JSDocNamepathType = 313,
JSDocComment = 314,
JSDocText = 315,
JSDocTypeLiteral = 316,
JSDocSignature = 317,
JSDocLink = 318,
JSDocLinkCode = 319,
JSDocLinkPlain = 320,
JSDocTag = 321,
JSDocAugmentsTag = 322,
JSDocImplementsTag = 323,
JSDocAuthorTag = 324,
JSDocDeprecatedTag = 325,
JSDocClassTag = 326,
JSDocPublicTag = 327,
JSDocPrivateTag = 328,
JSDocProtectedTag = 329,
JSDocReadonlyTag = 330,
JSDocOverrideTag = 331,
JSDocCallbackTag = 332,
JSDocEnumTag = 333,
JSDocParameterTag = 334,
JSDocReturnTag = 335,
JSDocThisTag = 336,
JSDocTypeTag = 337,
JSDocTemplateTag = 338,
JSDocTypedefTag = 339,
JSDocSeeTag = 340,
JSDocPropertyTag = 341,
SyntaxList = 342,
NotEmittedStatement = 343,
PartiallyEmittedExpression = 344,
CommaListExpression = 345,
MergeDeclarationMarker = 346,
EndOfDeclarationMarker = 347,
SyntheticReferenceExpression = 348,
Count = 349,
ClassStaticBlockDeclaration = 168,
Constructor = 169,
GetAccessor = 170,
SetAccessor = 171,
CallSignature = 172,
ConstructSignature = 173,
IndexSignature = 174,
TypePredicate = 175,
TypeReference = 176,
FunctionType = 177,
ConstructorType = 178,
TypeQuery = 179,
TypeLiteral = 180,
ArrayType = 181,
TupleType = 182,
OptionalType = 183,
RestType = 184,
UnionType = 185,
IntersectionType = 186,
ConditionalType = 187,
InferType = 188,
ParenthesizedType = 189,
ThisType = 190,
TypeOperator = 191,
IndexedAccessType = 192,
MappedType = 193,
LiteralType = 194,
NamedTupleMember = 195,
TemplateLiteralType = 196,
TemplateLiteralTypeSpan = 197,
ImportType = 198,
ObjectBindingPattern = 199,
ArrayBindingPattern = 200,
BindingElement = 201,
ArrayLiteralExpression = 202,
ObjectLiteralExpression = 203,
PropertyAccessExpression = 204,
ElementAccessExpression = 205,
CallExpression = 206,
NewExpression = 207,
TaggedTemplateExpression = 208,
TypeAssertionExpression = 209,
ParenthesizedExpression = 210,
FunctionExpression = 211,
ArrowFunction = 212,
DeleteExpression = 213,
TypeOfExpression = 214,
VoidExpression = 215,
AwaitExpression = 216,
PrefixUnaryExpression = 217,
PostfixUnaryExpression = 218,
BinaryExpression = 219,
ConditionalExpression = 220,
TemplateExpression = 221,
YieldExpression = 222,
SpreadElement = 223,
ClassExpression = 224,
OmittedExpression = 225,
ExpressionWithTypeArguments = 226,
AsExpression = 227,
NonNullExpression = 228,
MetaProperty = 229,
SyntheticExpression = 230,
TemplateSpan = 231,
SemicolonClassElement = 232,
Block = 233,
EmptyStatement = 234,
VariableStatement = 235,
ExpressionStatement = 236,
IfStatement = 237,
DoStatement = 238,
WhileStatement = 239,
ForStatement = 240,
ForInStatement = 241,
ForOfStatement = 242,
ContinueStatement = 243,
BreakStatement = 244,
ReturnStatement = 245,
WithStatement = 246,
SwitchStatement = 247,
LabeledStatement = 248,
ThrowStatement = 249,
TryStatement = 250,
DebuggerStatement = 251,
VariableDeclaration = 252,
VariableDeclarationList = 253,
FunctionDeclaration = 254,
ClassDeclaration = 255,
InterfaceDeclaration = 256,
TypeAliasDeclaration = 257,
EnumDeclaration = 258,
ModuleDeclaration = 259,
ModuleBlock = 260,
CaseBlock = 261,
NamespaceExportDeclaration = 262,
ImportEqualsDeclaration = 263,
ImportDeclaration = 264,
ImportClause = 265,
NamespaceImport = 266,
NamedImports = 267,
ImportSpecifier = 268,
ExportAssignment = 269,
ExportDeclaration = 270,
NamedExports = 271,
NamespaceExport = 272,
ExportSpecifier = 273,
MissingDeclaration = 274,
ExternalModuleReference = 275,
JsxElement = 276,
JsxSelfClosingElement = 277,
JsxOpeningElement = 278,
JsxClosingElement = 279,
JsxFragment = 280,
JsxOpeningFragment = 281,
JsxClosingFragment = 282,
JsxAttribute = 283,
JsxAttributes = 284,
JsxSpreadAttribute = 285,
JsxExpression = 286,
CaseClause = 287,
DefaultClause = 288,
HeritageClause = 289,
CatchClause = 290,
PropertyAssignment = 291,
ShorthandPropertyAssignment = 292,
SpreadAssignment = 293,
EnumMember = 294,
UnparsedPrologue = 295,
UnparsedPrepend = 296,
UnparsedText = 297,
UnparsedInternalText = 298,
UnparsedSyntheticReference = 299,
SourceFile = 300,
Bundle = 301,
UnparsedSource = 302,
InputFiles = 303,
JSDocTypeExpression = 304,
JSDocNameReference = 305,
JSDocMemberName = 306,
JSDocAllType = 307,
JSDocUnknownType = 308,
JSDocNullableType = 309,
JSDocNonNullableType = 310,
JSDocOptionalType = 311,
JSDocFunctionType = 312,
JSDocVariadicType = 313,
JSDocNamepathType = 314,
JSDocComment = 315,
JSDocText = 316,
JSDocTypeLiteral = 317,
JSDocSignature = 318,
JSDocLink = 319,
JSDocLinkCode = 320,
JSDocLinkPlain = 321,
JSDocTag = 322,
JSDocAugmentsTag = 323,
JSDocImplementsTag = 324,
JSDocAuthorTag = 325,
JSDocDeprecatedTag = 326,
JSDocClassTag = 327,
JSDocPublicTag = 328,
JSDocPrivateTag = 329,
JSDocProtectedTag = 330,
JSDocReadonlyTag = 331,
JSDocOverrideTag = 332,
JSDocCallbackTag = 333,
JSDocEnumTag = 334,
JSDocParameterTag = 335,
JSDocReturnTag = 336,
JSDocThisTag = 337,
JSDocTypeTag = 338,
JSDocTemplateTag = 339,
JSDocTypedefTag = 340,
JSDocSeeTag = 341,
JSDocPropertyTag = 342,
SyntaxList = 343,
NotEmittedStatement = 344,
PartiallyEmittedExpression = 345,
CommaListExpression = 346,
MergeDeclarationMarker = 347,
EndOfDeclarationMarker = 348,
SyntheticReferenceExpression = 349,
Count = 350,
FirstAssignment = 63,
LastAssignment = 78,
FirstCompoundAssignment = 64,
@@ -465,8 +466,8 @@ declare namespace ts {
LastKeyword = 158,
FirstFutureReservedWord = 117,
LastFutureReservedWord = 125,
FirstTypeNode = 174,
LastTypeNode = 197,
FirstTypeNode = 175,
LastTypeNode = 198,
FirstPunctuation = 18,
LastPunctuation = 78,
FirstToken = 0,
@@ -479,13 +480,13 @@ declare namespace ts {
LastTemplateToken = 17,
FirstBinaryOperator = 29,
LastBinaryOperator = 78,
FirstStatement = 234,
LastStatement = 250,
FirstStatement = 235,
LastStatement = 251,
FirstNode = 159,
FirstJSDocNode = 303,
LastJSDocNode = 341,
FirstJSDocTagNode = 321,
LastJSDocTagNode = 341,
FirstJSDocNode = 304,
LastJSDocNode = 342,
FirstJSDocTagNode = 322,
LastJSDocTagNode = 342,
}
export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
@@ -568,7 +569,7 @@ declare namespace ts {
}
export interface JSDocContainer {
}
export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken;
export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ClassStaticBlockDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken;
export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType;
export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement;
export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute;
@@ -850,6 +851,11 @@ declare namespace ts {
readonly parent: ObjectTypeDeclaration;
readonly type: TypeNode;
}
export interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer {
readonly kind: SyntaxKind.ClassStaticBlockDeclaration;
readonly parent: ClassDeclaration | ClassExpression;
readonly body: Block;
}
export interface TypeNode extends Node {
_typeNodeBrand: any;
}
@@ -3292,6 +3298,8 @@ declare namespace ts {
updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
createTemplateLiteralTypeSpan(type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan;
updateTemplateLiteralTypeSpan(node: TemplateLiteralTypeSpan, type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan;
createClassStaticBlockDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration;
updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration;
createKeywordTypeNode<TKind extends KeywordTypeSyntaxKind>(kind: TKind): KeywordTypeNode<TKind>;
createTypePredicateNode(assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode;
updateTypePredicateNode(node: TypePredicateNode, assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode;
@@ -4455,6 +4463,7 @@ declare namespace ts {
function isPropertyDeclaration(node: Node): node is PropertyDeclaration;
function isMethodSignature(node: Node): node is MethodSignature;
function isMethodDeclaration(node: Node): node is MethodDeclaration;
function isClassStaticBlockDeclaration(node: Node): node is ClassStaticBlockDeclaration;
function isConstructorDeclaration(node: Node): node is ConstructorDeclaration;
function isGetAccessorDeclaration(node: Node): node is GetAccessorDeclaration;
function isSetAccessorDeclaration(node: Node): node is SetAccessorDeclaration;
@@ -6427,7 +6436,10 @@ declare namespace ts {
* interface Y { foo:number; }
*/
memberVariableElement = "property",
/** class X { constructor() { } } */
/**
* class X { constructor() { } }
* class X { static { } }
*/
constructorImplementationElement = "constructor",
/** interface Y { ():number; } */
callSignatureElement = "call",
+204 -192
View File
@@ -273,188 +273,189 @@ declare namespace ts {
PropertyDeclaration = 165,
MethodSignature = 166,
MethodDeclaration = 167,
Constructor = 168,
GetAccessor = 169,
SetAccessor = 170,
CallSignature = 171,
ConstructSignature = 172,
IndexSignature = 173,
TypePredicate = 174,
TypeReference = 175,
FunctionType = 176,
ConstructorType = 177,
TypeQuery = 178,
TypeLiteral = 179,
ArrayType = 180,
TupleType = 181,
OptionalType = 182,
RestType = 183,
UnionType = 184,
IntersectionType = 185,
ConditionalType = 186,
InferType = 187,
ParenthesizedType = 188,
ThisType = 189,
TypeOperator = 190,
IndexedAccessType = 191,
MappedType = 192,
LiteralType = 193,
NamedTupleMember = 194,
TemplateLiteralType = 195,
TemplateLiteralTypeSpan = 196,
ImportType = 197,
ObjectBindingPattern = 198,
ArrayBindingPattern = 199,
BindingElement = 200,
ArrayLiteralExpression = 201,
ObjectLiteralExpression = 202,
PropertyAccessExpression = 203,
ElementAccessExpression = 204,
CallExpression = 205,
NewExpression = 206,
TaggedTemplateExpression = 207,
TypeAssertionExpression = 208,
ParenthesizedExpression = 209,
FunctionExpression = 210,
ArrowFunction = 211,
DeleteExpression = 212,
TypeOfExpression = 213,
VoidExpression = 214,
AwaitExpression = 215,
PrefixUnaryExpression = 216,
PostfixUnaryExpression = 217,
BinaryExpression = 218,
ConditionalExpression = 219,
TemplateExpression = 220,
YieldExpression = 221,
SpreadElement = 222,
ClassExpression = 223,
OmittedExpression = 224,
ExpressionWithTypeArguments = 225,
AsExpression = 226,
NonNullExpression = 227,
MetaProperty = 228,
SyntheticExpression = 229,
TemplateSpan = 230,
SemicolonClassElement = 231,
Block = 232,
EmptyStatement = 233,
VariableStatement = 234,
ExpressionStatement = 235,
IfStatement = 236,
DoStatement = 237,
WhileStatement = 238,
ForStatement = 239,
ForInStatement = 240,
ForOfStatement = 241,
ContinueStatement = 242,
BreakStatement = 243,
ReturnStatement = 244,
WithStatement = 245,
SwitchStatement = 246,
LabeledStatement = 247,
ThrowStatement = 248,
TryStatement = 249,
DebuggerStatement = 250,
VariableDeclaration = 251,
VariableDeclarationList = 252,
FunctionDeclaration = 253,
ClassDeclaration = 254,
InterfaceDeclaration = 255,
TypeAliasDeclaration = 256,
EnumDeclaration = 257,
ModuleDeclaration = 258,
ModuleBlock = 259,
CaseBlock = 260,
NamespaceExportDeclaration = 261,
ImportEqualsDeclaration = 262,
ImportDeclaration = 263,
ImportClause = 264,
NamespaceImport = 265,
NamedImports = 266,
ImportSpecifier = 267,
ExportAssignment = 268,
ExportDeclaration = 269,
NamedExports = 270,
NamespaceExport = 271,
ExportSpecifier = 272,
MissingDeclaration = 273,
ExternalModuleReference = 274,
JsxElement = 275,
JsxSelfClosingElement = 276,
JsxOpeningElement = 277,
JsxClosingElement = 278,
JsxFragment = 279,
JsxOpeningFragment = 280,
JsxClosingFragment = 281,
JsxAttribute = 282,
JsxAttributes = 283,
JsxSpreadAttribute = 284,
JsxExpression = 285,
CaseClause = 286,
DefaultClause = 287,
HeritageClause = 288,
CatchClause = 289,
PropertyAssignment = 290,
ShorthandPropertyAssignment = 291,
SpreadAssignment = 292,
EnumMember = 293,
UnparsedPrologue = 294,
UnparsedPrepend = 295,
UnparsedText = 296,
UnparsedInternalText = 297,
UnparsedSyntheticReference = 298,
SourceFile = 299,
Bundle = 300,
UnparsedSource = 301,
InputFiles = 302,
JSDocTypeExpression = 303,
JSDocNameReference = 304,
JSDocMemberName = 305,
JSDocAllType = 306,
JSDocUnknownType = 307,
JSDocNullableType = 308,
JSDocNonNullableType = 309,
JSDocOptionalType = 310,
JSDocFunctionType = 311,
JSDocVariadicType = 312,
JSDocNamepathType = 313,
JSDocComment = 314,
JSDocText = 315,
JSDocTypeLiteral = 316,
JSDocSignature = 317,
JSDocLink = 318,
JSDocLinkCode = 319,
JSDocLinkPlain = 320,
JSDocTag = 321,
JSDocAugmentsTag = 322,
JSDocImplementsTag = 323,
JSDocAuthorTag = 324,
JSDocDeprecatedTag = 325,
JSDocClassTag = 326,
JSDocPublicTag = 327,
JSDocPrivateTag = 328,
JSDocProtectedTag = 329,
JSDocReadonlyTag = 330,
JSDocOverrideTag = 331,
JSDocCallbackTag = 332,
JSDocEnumTag = 333,
JSDocParameterTag = 334,
JSDocReturnTag = 335,
JSDocThisTag = 336,
JSDocTypeTag = 337,
JSDocTemplateTag = 338,
JSDocTypedefTag = 339,
JSDocSeeTag = 340,
JSDocPropertyTag = 341,
SyntaxList = 342,
NotEmittedStatement = 343,
PartiallyEmittedExpression = 344,
CommaListExpression = 345,
MergeDeclarationMarker = 346,
EndOfDeclarationMarker = 347,
SyntheticReferenceExpression = 348,
Count = 349,
ClassStaticBlockDeclaration = 168,
Constructor = 169,
GetAccessor = 170,
SetAccessor = 171,
CallSignature = 172,
ConstructSignature = 173,
IndexSignature = 174,
TypePredicate = 175,
TypeReference = 176,
FunctionType = 177,
ConstructorType = 178,
TypeQuery = 179,
TypeLiteral = 180,
ArrayType = 181,
TupleType = 182,
OptionalType = 183,
RestType = 184,
UnionType = 185,
IntersectionType = 186,
ConditionalType = 187,
InferType = 188,
ParenthesizedType = 189,
ThisType = 190,
TypeOperator = 191,
IndexedAccessType = 192,
MappedType = 193,
LiteralType = 194,
NamedTupleMember = 195,
TemplateLiteralType = 196,
TemplateLiteralTypeSpan = 197,
ImportType = 198,
ObjectBindingPattern = 199,
ArrayBindingPattern = 200,
BindingElement = 201,
ArrayLiteralExpression = 202,
ObjectLiteralExpression = 203,
PropertyAccessExpression = 204,
ElementAccessExpression = 205,
CallExpression = 206,
NewExpression = 207,
TaggedTemplateExpression = 208,
TypeAssertionExpression = 209,
ParenthesizedExpression = 210,
FunctionExpression = 211,
ArrowFunction = 212,
DeleteExpression = 213,
TypeOfExpression = 214,
VoidExpression = 215,
AwaitExpression = 216,
PrefixUnaryExpression = 217,
PostfixUnaryExpression = 218,
BinaryExpression = 219,
ConditionalExpression = 220,
TemplateExpression = 221,
YieldExpression = 222,
SpreadElement = 223,
ClassExpression = 224,
OmittedExpression = 225,
ExpressionWithTypeArguments = 226,
AsExpression = 227,
NonNullExpression = 228,
MetaProperty = 229,
SyntheticExpression = 230,
TemplateSpan = 231,
SemicolonClassElement = 232,
Block = 233,
EmptyStatement = 234,
VariableStatement = 235,
ExpressionStatement = 236,
IfStatement = 237,
DoStatement = 238,
WhileStatement = 239,
ForStatement = 240,
ForInStatement = 241,
ForOfStatement = 242,
ContinueStatement = 243,
BreakStatement = 244,
ReturnStatement = 245,
WithStatement = 246,
SwitchStatement = 247,
LabeledStatement = 248,
ThrowStatement = 249,
TryStatement = 250,
DebuggerStatement = 251,
VariableDeclaration = 252,
VariableDeclarationList = 253,
FunctionDeclaration = 254,
ClassDeclaration = 255,
InterfaceDeclaration = 256,
TypeAliasDeclaration = 257,
EnumDeclaration = 258,
ModuleDeclaration = 259,
ModuleBlock = 260,
CaseBlock = 261,
NamespaceExportDeclaration = 262,
ImportEqualsDeclaration = 263,
ImportDeclaration = 264,
ImportClause = 265,
NamespaceImport = 266,
NamedImports = 267,
ImportSpecifier = 268,
ExportAssignment = 269,
ExportDeclaration = 270,
NamedExports = 271,
NamespaceExport = 272,
ExportSpecifier = 273,
MissingDeclaration = 274,
ExternalModuleReference = 275,
JsxElement = 276,
JsxSelfClosingElement = 277,
JsxOpeningElement = 278,
JsxClosingElement = 279,
JsxFragment = 280,
JsxOpeningFragment = 281,
JsxClosingFragment = 282,
JsxAttribute = 283,
JsxAttributes = 284,
JsxSpreadAttribute = 285,
JsxExpression = 286,
CaseClause = 287,
DefaultClause = 288,
HeritageClause = 289,
CatchClause = 290,
PropertyAssignment = 291,
ShorthandPropertyAssignment = 292,
SpreadAssignment = 293,
EnumMember = 294,
UnparsedPrologue = 295,
UnparsedPrepend = 296,
UnparsedText = 297,
UnparsedInternalText = 298,
UnparsedSyntheticReference = 299,
SourceFile = 300,
Bundle = 301,
UnparsedSource = 302,
InputFiles = 303,
JSDocTypeExpression = 304,
JSDocNameReference = 305,
JSDocMemberName = 306,
JSDocAllType = 307,
JSDocUnknownType = 308,
JSDocNullableType = 309,
JSDocNonNullableType = 310,
JSDocOptionalType = 311,
JSDocFunctionType = 312,
JSDocVariadicType = 313,
JSDocNamepathType = 314,
JSDocComment = 315,
JSDocText = 316,
JSDocTypeLiteral = 317,
JSDocSignature = 318,
JSDocLink = 319,
JSDocLinkCode = 320,
JSDocLinkPlain = 321,
JSDocTag = 322,
JSDocAugmentsTag = 323,
JSDocImplementsTag = 324,
JSDocAuthorTag = 325,
JSDocDeprecatedTag = 326,
JSDocClassTag = 327,
JSDocPublicTag = 328,
JSDocPrivateTag = 329,
JSDocProtectedTag = 330,
JSDocReadonlyTag = 331,
JSDocOverrideTag = 332,
JSDocCallbackTag = 333,
JSDocEnumTag = 334,
JSDocParameterTag = 335,
JSDocReturnTag = 336,
JSDocThisTag = 337,
JSDocTypeTag = 338,
JSDocTemplateTag = 339,
JSDocTypedefTag = 340,
JSDocSeeTag = 341,
JSDocPropertyTag = 342,
SyntaxList = 343,
NotEmittedStatement = 344,
PartiallyEmittedExpression = 345,
CommaListExpression = 346,
MergeDeclarationMarker = 347,
EndOfDeclarationMarker = 348,
SyntheticReferenceExpression = 349,
Count = 350,
FirstAssignment = 63,
LastAssignment = 78,
FirstCompoundAssignment = 64,
@@ -465,8 +466,8 @@ declare namespace ts {
LastKeyword = 158,
FirstFutureReservedWord = 117,
LastFutureReservedWord = 125,
FirstTypeNode = 174,
LastTypeNode = 197,
FirstTypeNode = 175,
LastTypeNode = 198,
FirstPunctuation = 18,
LastPunctuation = 78,
FirstToken = 0,
@@ -479,13 +480,13 @@ declare namespace ts {
LastTemplateToken = 17,
FirstBinaryOperator = 29,
LastBinaryOperator = 78,
FirstStatement = 234,
LastStatement = 250,
FirstStatement = 235,
LastStatement = 251,
FirstNode = 159,
FirstJSDocNode = 303,
LastJSDocNode = 341,
FirstJSDocTagNode = 321,
LastJSDocTagNode = 341,
FirstJSDocNode = 304,
LastJSDocNode = 342,
FirstJSDocTagNode = 322,
LastJSDocTagNode = 342,
}
export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
@@ -568,7 +569,7 @@ declare namespace ts {
}
export interface JSDocContainer {
}
export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken;
export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ClassStaticBlockDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken;
export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType;
export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement;
export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute;
@@ -850,6 +851,11 @@ declare namespace ts {
readonly parent: ObjectTypeDeclaration;
readonly type: TypeNode;
}
export interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer {
readonly kind: SyntaxKind.ClassStaticBlockDeclaration;
readonly parent: ClassDeclaration | ClassExpression;
readonly body: Block;
}
export interface TypeNode extends Node {
_typeNodeBrand: any;
}
@@ -3292,6 +3298,8 @@ declare namespace ts {
updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
createTemplateLiteralTypeSpan(type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan;
updateTemplateLiteralTypeSpan(node: TemplateLiteralTypeSpan, type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan;
createClassStaticBlockDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration;
updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration;
createKeywordTypeNode<TKind extends KeywordTypeSyntaxKind>(kind: TKind): KeywordTypeNode<TKind>;
createTypePredicateNode(assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode;
updateTypePredicateNode(node: TypePredicateNode, assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode;
@@ -4455,6 +4463,7 @@ declare namespace ts {
function isPropertyDeclaration(node: Node): node is PropertyDeclaration;
function isMethodSignature(node: Node): node is MethodSignature;
function isMethodDeclaration(node: Node): node is MethodDeclaration;
function isClassStaticBlockDeclaration(node: Node): node is ClassStaticBlockDeclaration;
function isConstructorDeclaration(node: Node): node is ConstructorDeclaration;
function isGetAccessorDeclaration(node: Node): node is GetAccessorDeclaration;
function isSetAccessorDeclaration(node: Node): node is SetAccessorDeclaration;
@@ -6427,7 +6436,10 @@ declare namespace ts {
* interface Y { foo:number; }
*/
memberVariableElement = "property",
/** class X { constructor() { } } */
/**
* class X { constructor() { } }
* class X { static { } }
*/
constructorImplementationElement = "constructor",
/** interface Y { ():number; } */
callSignatureElement = "call",
@@ -0,0 +1,139 @@
╭ name: bar
├ kind: function
├ file: /tests/cases/fourslash/callHierarchyClassStaticBlock.ts
├ span:
│ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:7:9-11:10
│ │ 7: function bar() {
│ │ ^^^^^^^^^^^^^^^^
│ │ 8: baz();
│ │ ^^^^^^^^^^^^^^^^^^
│ │ 9: quxx();
│ │ ^^^^^^^^^^^^^^^^^^^
│ │ 10: baz();
│ │ ^^^^^^^^^^^^^^^^^^
│ │ 11: }
│ │ ^^^^^^^^^
│ ╰
├ selectionSpan:
│ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:7:18-7:21
│ │ 7: function bar() {
│ │ ^^^
│ ╰
├ incoming:
│ ╭ from:
│ │ ╭ name: foo
│ │ ├ kind: function
│ │ ├ file: /tests/cases/fourslash/callHierarchyClassStaticBlock.ts
│ │ ├ span:
│ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:3:9-5:10
│ │ │ │ 3: function foo() {
│ │ │ │ ^^^^^^^^^^^^^^^^
│ │ │ │ 4: bar();
│ │ │ │ ^^^^^^^^^^^^^^^^^^
│ │ │ │ 5: }
│ │ │ │ ^^^^^^^^^
│ │ │ ╰
│ │ ├ selectionSpan:
│ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:3:18-3:21
│ │ │ │ 3: function foo() {
│ │ │ │ ^^^
│ │ │ ╰
│ │ ├ incoming:
│ │ │ ╭ from:
│ │ │ │ ╭ name: static {}
│ │ │ │ ├ kind: constructor
│ │ │ │ ├ file: /tests/cases/fourslash/callHierarchyClassStaticBlock.ts
│ │ │ │ ├ span:
│ │ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:2:5-14:6
│ │ │ │ │ │ 2: static {
│ │ │ │ │ │ ^^^^^^^^
│ │ │ │ │ │ 3: function foo() {
│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ 4: bar();
│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ 5: }
│ │ │ │ │ │ ^^^^^^^^^
│ │ │ │ │ │ 6:
│ │ │ │ │ │ ^
│ │ │ │ │ │ 7: function bar() {
│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ 8: baz();
│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ 9: quxx();
│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ 10: baz();
│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ 11: }
│ │ │ │ │ │ ^^^^^^^^^
│ │ │ │ │ │ 12:
│ │ │ │ │ │ ^
│ │ │ │ │ │ 13: foo();
│ │ │ │ │ │ ^^^^^^^^^^^^^^
│ │ │ │ │ │ 14: }
│ │ │ │ │ │ ^^^^^
│ │ │ │ │ ╰
│ │ │ │ ├ selectionSpan:
│ │ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:2:5-2:11
│ │ │ │ │ │ 2: static {
│ │ │ │ │ │ ^^^^^^
│ │ │ │ │ ╰
│ │ │ │ ╰ incoming: none
│ │ │ ├ fromSpans:
│ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:13:9-13:12
│ │ │ │ │ 13: foo();
│ │ │ │ │ ^^^
│ │ ╰ ╰ ╰
│ ├ fromSpans:
│ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:4:13-4:16
│ │ │ 4: bar();
│ │ │ ^^^
│ ╰ ╰
├ outgoing:
│ ╭ to:
│ │ ╭ name: baz
│ │ ├ kind: function
│ │ ├ file: /tests/cases/fourslash/callHierarchyClassStaticBlock.ts
│ │ ├ span:
│ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:17:1-18:2
│ │ │ │ 17: function baz() {
│ │ │ │ ^^^^^^^^^^^^^^^^
│ │ │ │ 18: }
│ │ │ │ ^
│ │ │ ╰
│ │ ├ selectionSpan:
│ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:17:10-17:13
│ │ │ │ 17: function baz() {
│ │ │ │ ^^^
│ │ │ ╰
│ │ ╰ outgoing: none
│ ├ fromSpans:
│ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:8:13-8:16
│ │ │ 8: baz();
│ │ │ ^^^
│ │ ╰
│ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:10:13-10:16
│ │ │ 10: baz();
│ │ │ ^^^
│ ╰ ╰
│ ╭ to:
│ │ ╭ name: quxx
│ │ ├ kind: function
│ │ ├ file: /tests/cases/fourslash/callHierarchyClassStaticBlock.ts
│ │ ├ span:
│ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:20:1-21:2
│ │ │ │ 20: function quxx() {
│ │ │ │ ^^^^^^^^^^^^^^^^^
│ │ │ │ 21: }
│ │ │ │ ^
│ │ │ ╰
│ │ ├ selectionSpan:
│ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:20:10-20:14
│ │ │ │ 20: function quxx() {
│ │ │ │ ^^^^
│ │ │ ╰
│ │ ╰ outgoing: none
│ ├ fromSpans:
│ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock.ts:9:13-9:17
│ │ │ 9: quxx();
│ │ │ ^^^^
╰ ╰ ╰
@@ -0,0 +1,139 @@
╭ name: static {}
├ kind: constructor
├ file: /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts
├ span:
│ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:2:5-14:6
│ │ 2: static {
│ │ ^^^^^^^^
│ │ 3: function foo() {
│ │ ^^^^^^^^^^^^^^^^^^^^^^^^
│ │ 4: bar();
│ │ ^^^^^^^^^^^^^^^^^^
│ │ 5: }
│ │ ^^^^^^^^^
│ │ 6:
│ │ ^
│ │ 7: function bar() {
│ │ ^^^^^^^^^^^^^^^^^^^^^^^^
│ │ 8: baz();
│ │ ^^^^^^^^^^^^^^^^^^
│ │ 9: quxx();
│ │ ^^^^^^^^^^^^^^^^^^^
│ │ 10: baz();
│ │ ^^^^^^^^^^^^^^^^^^
│ │ 11: }
│ │ ^^^^^^^^^
│ │ 12:
│ │ ^
│ │ 13: foo();
│ │ ^^^^^^^^^^^^^^
│ │ 14: }
│ │ ^^^^^
│ ╰
├ selectionSpan:
│ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:2:5-2:11
│ │ 2: static {
│ │ ^^^^^^
│ ╰
├ incoming: none
├ outgoing:
│ ╭ to:
│ │ ╭ name: foo
│ │ ├ kind: function
│ │ ├ file: /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts
│ │ ├ span:
│ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:3:9-5:10
│ │ │ │ 3: function foo() {
│ │ │ │ ^^^^^^^^^^^^^^^^
│ │ │ │ 4: bar();
│ │ │ │ ^^^^^^^^^^^^^^^^^^
│ │ │ │ 5: }
│ │ │ │ ^^^^^^^^^
│ │ │ ╰
│ │ ├ selectionSpan:
│ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:3:18-3:21
│ │ │ │ 3: function foo() {
│ │ │ │ ^^^
│ │ │ ╰
│ │ ├ outgoing:
│ │ │ ╭ to:
│ │ │ │ ╭ name: bar
│ │ │ │ ├ kind: function
│ │ │ │ ├ file: /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts
│ │ │ │ ├ span:
│ │ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:7:9-11:10
│ │ │ │ │ │ 7: function bar() {
│ │ │ │ │ │ ^^^^^^^^^^^^^^^^
│ │ │ │ │ │ 8: baz();
│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ 9: quxx();
│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ 10: baz();
│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ 11: }
│ │ │ │ │ │ ^^^^^^^^^
│ │ │ │ │ ╰
│ │ │ │ ├ selectionSpan:
│ │ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:7:18-7:21
│ │ │ │ │ │ 7: function bar() {
│ │ │ │ │ │ ^^^
│ │ │ │ │ ╰
│ │ │ │ ├ outgoing:
│ │ │ │ │ ╭ to:
│ │ │ │ │ │ ╭ name: baz
│ │ │ │ │ │ ├ kind: function
│ │ │ │ │ │ ├ file: /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts
│ │ │ │ │ │ ├ span:
│ │ │ │ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:17:1-18:2
│ │ │ │ │ │ │ │ 17: function baz() {
│ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^
│ │ │ │ │ │ │ │ 18: }
│ │ │ │ │ │ │ │ ^
│ │ │ │ │ │ │ ╰
│ │ │ │ │ │ ├ selectionSpan:
│ │ │ │ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:17:10-17:13
│ │ │ │ │ │ │ │ 17: function baz() {
│ │ │ │ │ │ │ │ ^^^
│ │ │ │ │ │ │ ╰
│ │ │ │ │ │ ╰ outgoing: none
│ │ │ │ │ ├ fromSpans:
│ │ │ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:8:13-8:16
│ │ │ │ │ │ │ 8: baz();
│ │ │ │ │ │ │ ^^^
│ │ │ │ │ │ ╰
│ │ │ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:10:13-10:16
│ │ │ │ │ │ │ 10: baz();
│ │ │ │ │ │ │ ^^^
│ │ │ │ │ ╰ ╰
│ │ │ │ │ ╭ to:
│ │ │ │ │ │ ╭ name: quxx
│ │ │ │ │ │ ├ kind: function
│ │ │ │ │ │ ├ file: /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts
│ │ │ │ │ │ ├ span:
│ │ │ │ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:20:1-21:2
│ │ │ │ │ │ │ │ 20: function quxx() {
│ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ │ │ 21: }
│ │ │ │ │ │ │ │ ^
│ │ │ │ │ │ │ ╰
│ │ │ │ │ │ ├ selectionSpan:
│ │ │ │ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:20:10-20:14
│ │ │ │ │ │ │ │ 20: function quxx() {
│ │ │ │ │ │ │ │ ^^^^
│ │ │ │ │ │ │ ╰
│ │ │ │ │ │ ╰ outgoing: none
│ │ │ │ │ ├ fromSpans:
│ │ │ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:9:13-9:17
│ │ │ │ │ │ │ 9: quxx();
│ │ │ │ │ │ │ ^^^^
│ │ │ │ ╰ ╰ ╰
│ │ │ ├ fromSpans:
│ │ │ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:4:13-4:16
│ │ │ │ │ 4: bar();
│ │ │ │ │ ^^^
│ │ ╰ ╰ ╰
│ ├ fromSpans:
│ │ ╭ /tests/cases/fourslash/callHierarchyClassStaticBlock2.ts:13:9-13:12
│ │ │ 13: foo();
│ │ │ ^^^
╰ ╰ ╰
@@ -0,0 +1,20 @@
//// [classStaticBlock1.ts]
const a = 2;
class C {
static {
const a = 1;
a;
}
}
//// [classStaticBlock1.js]
const a = 2;
class C {
}
(() => {
const a = 1;
a;
})();
@@ -0,0 +1,16 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock1.ts ===
const a = 2;
>a : Symbol(a, Decl(classStaticBlock1.ts, 0, 5))
class C {
>C : Symbol(C, Decl(classStaticBlock1.ts, 0, 12))
static {
const a = 1;
>a : Symbol(a, Decl(classStaticBlock1.ts, 4, 13))
a;
>a : Symbol(a, Decl(classStaticBlock1.ts, 4, 13))
}
}
@@ -0,0 +1,18 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock1.ts ===
const a = 2;
>a : 2
>2 : 2
class C {
>C : C
static {
const a = 1;
>a : 1
>1 : 1
a;
>a : 1
}
}
@@ -0,0 +1,23 @@
//// [classStaticBlock1.ts]
const a = 2;
class C {
static {
const a = 1;
a;
}
}
//// [classStaticBlock1.js]
var a = 2;
var C = /** @class */ (function () {
function C() {
}
return C;
}());
(function () {
var a = 1;
a;
})();
@@ -0,0 +1,16 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock1.ts ===
const a = 2;
>a : Symbol(a, Decl(classStaticBlock1.ts, 0, 5))
class C {
>C : Symbol(C, Decl(classStaticBlock1.ts, 0, 12))
static {
const a = 1;
>a : Symbol(a, Decl(classStaticBlock1.ts, 4, 13))
a;
>a : Symbol(a, Decl(classStaticBlock1.ts, 4, 13))
}
}
@@ -0,0 +1,18 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock1.ts ===
const a = 2;
>a : 2
>2 : 2
class C {
>C : C
static {
const a = 1;
>a : 1
>1 : 1
a;
>a : 1
}
}
@@ -0,0 +1,20 @@
//// [classStaticBlock1.ts]
const a = 2;
class C {
static {
const a = 1;
a;
}
}
//// [classStaticBlock1.js]
const a = 2;
class C {
static {
const a = 1;
a;
}
}
@@ -0,0 +1,16 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock1.ts ===
const a = 2;
>a : Symbol(a, Decl(classStaticBlock1.ts, 0, 5))
class C {
>C : Symbol(C, Decl(classStaticBlock1.ts, 0, 12))
static {
const a = 1;
>a : Symbol(a, Decl(classStaticBlock1.ts, 4, 13))
a;
>a : Symbol(a, Decl(classStaticBlock1.ts, 4, 13))
}
}
@@ -0,0 +1,18 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock1.ts ===
const a = 2;
>a : 2
>2 : 2
class C {
>C : C
static {
const a = 1;
>a : 1
>1 : 1
a;
>a : 1
}
}
@@ -0,0 +1,54 @@
//// [classStaticBlock10.ts]
var a1 = 1;
var a2 = 1;
const b1 = 2;
const b2 = 2;
function f () {
var a1 = 11;
const b1 = 22;
class C1 {
static {
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
}
}
}
class C2 {
static {
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
}
}
//// [classStaticBlock10.js]
var a1 = 1;
var a2 = 1;
const b1 = 2;
const b2 = 2;
function f() {
var a1 = 11;
const b1 = 22;
class C1 {
}
(() => {
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
})();
}
class C2 {
}
(() => {
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
})();
@@ -0,0 +1,58 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock10.ts ===
var a1 = 1;
>a1 : Symbol(a1, Decl(classStaticBlock10.ts, 0, 3))
var a2 = 1;
>a2 : Symbol(a2, Decl(classStaticBlock10.ts, 1, 3))
const b1 = 2;
>b1 : Symbol(b1, Decl(classStaticBlock10.ts, 2, 5))
const b2 = 2;
>b2 : Symbol(b2, Decl(classStaticBlock10.ts, 3, 5))
function f () {
>f : Symbol(f, Decl(classStaticBlock10.ts, 3, 13))
var a1 = 11;
>a1 : Symbol(a1, Decl(classStaticBlock10.ts, 6, 7))
const b1 = 22;
>b1 : Symbol(b1, Decl(classStaticBlock10.ts, 7, 9))
class C1 {
>C1 : Symbol(C1, Decl(classStaticBlock10.ts, 7, 18))
static {
var a1 = 111;
>a1 : Symbol(a1, Decl(classStaticBlock10.ts, 11, 15))
var a2 = 111;
>a2 : Symbol(a2, Decl(classStaticBlock10.ts, 12, 15))
const b1 = 222;
>b1 : Symbol(b1, Decl(classStaticBlock10.ts, 13, 17))
const b2 = 222;
>b2 : Symbol(b2, Decl(classStaticBlock10.ts, 14, 17))
}
}
}
class C2 {
>C2 : Symbol(C2, Decl(classStaticBlock10.ts, 17, 1))
static {
var a1 = 111;
>a1 : Symbol(a1, Decl(classStaticBlock10.ts, 21, 11))
var a2 = 111;
>a2 : Symbol(a2, Decl(classStaticBlock10.ts, 22, 11))
const b1 = 222;
>b1 : Symbol(b1, Decl(classStaticBlock10.ts, 23, 13))
const b2 = 222;
>b2 : Symbol(b2, Decl(classStaticBlock10.ts, 24, 13))
}
}
@@ -0,0 +1,72 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock10.ts ===
var a1 = 1;
>a1 : number
>1 : 1
var a2 = 1;
>a2 : number
>1 : 1
const b1 = 2;
>b1 : 2
>2 : 2
const b2 = 2;
>b2 : 2
>2 : 2
function f () {
>f : () => void
var a1 = 11;
>a1 : number
>11 : 11
const b1 = 22;
>b1 : 22
>22 : 22
class C1 {
>C1 : C1
static {
var a1 = 111;
>a1 : number
>111 : 111
var a2 = 111;
>a2 : number
>111 : 111
const b1 = 222;
>b1 : 222
>222 : 222
const b2 = 222;
>b2 : 222
>222 : 222
}
}
}
class C2 {
>C2 : C2
static {
var a1 = 111;
>a1 : number
>111 : 111
var a2 = 111;
>a2 : number
>111 : 111
const b1 = 222;
>b1 : 222
>222 : 222
const b2 = 222;
>b2 : 222
>222 : 222
}
}
@@ -0,0 +1,60 @@
//// [classStaticBlock10.ts]
var a1 = 1;
var a2 = 1;
const b1 = 2;
const b2 = 2;
function f () {
var a1 = 11;
const b1 = 22;
class C1 {
static {
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
}
}
}
class C2 {
static {
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
}
}
//// [classStaticBlock10.js]
var a1 = 1;
var a2 = 1;
var b1 = 2;
var b2 = 2;
function f() {
var a1 = 11;
var b1 = 22;
var C1 = /** @class */ (function () {
function C1() {
}
return C1;
}());
(function () {
var a1 = 111;
var a2 = 111;
var b1 = 222;
var b2 = 222;
})();
}
var C2 = /** @class */ (function () {
function C2() {
}
return C2;
}());
(function () {
var a1 = 111;
var a2 = 111;
var b1 = 222;
var b2 = 222;
})();
@@ -0,0 +1,58 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock10.ts ===
var a1 = 1;
>a1 : Symbol(a1, Decl(classStaticBlock10.ts, 0, 3))
var a2 = 1;
>a2 : Symbol(a2, Decl(classStaticBlock10.ts, 1, 3))
const b1 = 2;
>b1 : Symbol(b1, Decl(classStaticBlock10.ts, 2, 5))
const b2 = 2;
>b2 : Symbol(b2, Decl(classStaticBlock10.ts, 3, 5))
function f () {
>f : Symbol(f, Decl(classStaticBlock10.ts, 3, 13))
var a1 = 11;
>a1 : Symbol(a1, Decl(classStaticBlock10.ts, 6, 7))
const b1 = 22;
>b1 : Symbol(b1, Decl(classStaticBlock10.ts, 7, 9))
class C1 {
>C1 : Symbol(C1, Decl(classStaticBlock10.ts, 7, 18))
static {
var a1 = 111;
>a1 : Symbol(a1, Decl(classStaticBlock10.ts, 11, 15))
var a2 = 111;
>a2 : Symbol(a2, Decl(classStaticBlock10.ts, 12, 15))
const b1 = 222;
>b1 : Symbol(b1, Decl(classStaticBlock10.ts, 13, 17))
const b2 = 222;
>b2 : Symbol(b2, Decl(classStaticBlock10.ts, 14, 17))
}
}
}
class C2 {
>C2 : Symbol(C2, Decl(classStaticBlock10.ts, 17, 1))
static {
var a1 = 111;
>a1 : Symbol(a1, Decl(classStaticBlock10.ts, 21, 11))
var a2 = 111;
>a2 : Symbol(a2, Decl(classStaticBlock10.ts, 22, 11))
const b1 = 222;
>b1 : Symbol(b1, Decl(classStaticBlock10.ts, 23, 13))
const b2 = 222;
>b2 : Symbol(b2, Decl(classStaticBlock10.ts, 24, 13))
}
}
@@ -0,0 +1,72 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock10.ts ===
var a1 = 1;
>a1 : number
>1 : 1
var a2 = 1;
>a2 : number
>1 : 1
const b1 = 2;
>b1 : 2
>2 : 2
const b2 = 2;
>b2 : 2
>2 : 2
function f () {
>f : () => void
var a1 = 11;
>a1 : number
>11 : 11
const b1 = 22;
>b1 : 22
>22 : 22
class C1 {
>C1 : C1
static {
var a1 = 111;
>a1 : number
>111 : 111
var a2 = 111;
>a2 : number
>111 : 111
const b1 = 222;
>b1 : 222
>222 : 222
const b2 = 222;
>b2 : 222
>222 : 222
}
}
}
class C2 {
>C2 : C2
static {
var a1 = 111;
>a1 : number
>111 : 111
var a2 = 111;
>a2 : number
>111 : 111
const b1 = 222;
>b1 : 222
>222 : 222
const b2 = 222;
>b2 : 222
>222 : 222
}
}
@@ -0,0 +1,54 @@
//// [classStaticBlock10.ts]
var a1 = 1;
var a2 = 1;
const b1 = 2;
const b2 = 2;
function f () {
var a1 = 11;
const b1 = 22;
class C1 {
static {
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
}
}
}
class C2 {
static {
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
}
}
//// [classStaticBlock10.js]
var a1 = 1;
var a2 = 1;
const b1 = 2;
const b2 = 2;
function f() {
var a1 = 11;
const b1 = 22;
class C1 {
static {
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
}
}
}
class C2 {
static {
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
}
}
@@ -0,0 +1,58 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock10.ts ===
var a1 = 1;
>a1 : Symbol(a1, Decl(classStaticBlock10.ts, 0, 3))
var a2 = 1;
>a2 : Symbol(a2, Decl(classStaticBlock10.ts, 1, 3))
const b1 = 2;
>b1 : Symbol(b1, Decl(classStaticBlock10.ts, 2, 5))
const b2 = 2;
>b2 : Symbol(b2, Decl(classStaticBlock10.ts, 3, 5))
function f () {
>f : Symbol(f, Decl(classStaticBlock10.ts, 3, 13))
var a1 = 11;
>a1 : Symbol(a1, Decl(classStaticBlock10.ts, 6, 7))
const b1 = 22;
>b1 : Symbol(b1, Decl(classStaticBlock10.ts, 7, 9))
class C1 {
>C1 : Symbol(C1, Decl(classStaticBlock10.ts, 7, 18))
static {
var a1 = 111;
>a1 : Symbol(a1, Decl(classStaticBlock10.ts, 11, 15))
var a2 = 111;
>a2 : Symbol(a2, Decl(classStaticBlock10.ts, 12, 15))
const b1 = 222;
>b1 : Symbol(b1, Decl(classStaticBlock10.ts, 13, 17))
const b2 = 222;
>b2 : Symbol(b2, Decl(classStaticBlock10.ts, 14, 17))
}
}
}
class C2 {
>C2 : Symbol(C2, Decl(classStaticBlock10.ts, 17, 1))
static {
var a1 = 111;
>a1 : Symbol(a1, Decl(classStaticBlock10.ts, 21, 11))
var a2 = 111;
>a2 : Symbol(a2, Decl(classStaticBlock10.ts, 22, 11))
const b1 = 222;
>b1 : Symbol(b1, Decl(classStaticBlock10.ts, 23, 13))
const b2 = 222;
>b2 : Symbol(b2, Decl(classStaticBlock10.ts, 24, 13))
}
}
@@ -0,0 +1,72 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock10.ts ===
var a1 = 1;
>a1 : number
>1 : 1
var a2 = 1;
>a2 : number
>1 : 1
const b1 = 2;
>b1 : 2
>2 : 2
const b2 = 2;
>b2 : 2
>2 : 2
function f () {
>f : () => void
var a1 = 11;
>a1 : number
>11 : 11
const b1 = 22;
>b1 : 22
>22 : 22
class C1 {
>C1 : C1
static {
var a1 = 111;
>a1 : number
>111 : 111
var a2 = 111;
>a2 : number
>111 : 111
const b1 = 222;
>b1 : 222
>222 : 222
const b2 = 222;
>b2 : 222
>222 : 222
}
}
}
class C2 {
>C2 : C2
static {
var a1 = 111;
>a1 : number
>111 : 111
var a2 = 111;
>a2 : number
>111 : 111
const b1 = 222;
>b1 : 222
>222 : 222
const b2 = 222;
>b2 : 222
>222 : 222
}
}
@@ -0,0 +1,40 @@
//// [classStaticBlock11.ts]
let getX;
class C {
#x = 1
constructor(x: number) {
this.#x = x;
}
static {
// getX has privileged access to #x
getX = (obj: C) => obj.#x;
}
}
//// [classStaticBlock11.js]
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _C_x;
let getX;
class C {
constructor(x) {
_C_x.set(this, 1);
__classPrivateFieldSet(this, _C_x, x, "f");
}
}
_C_x = new WeakMap();
(() => {
// getX has privileged access to #x
getX = (obj) => __classPrivateFieldGet(obj, _C_x, "f");
})();
@@ -0,0 +1,30 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock11.ts ===
let getX;
>getX : Symbol(getX, Decl(classStaticBlock11.ts, 0, 3))
class C {
>C : Symbol(C, Decl(classStaticBlock11.ts, 0, 9))
#x = 1
>#x : Symbol(C.#x, Decl(classStaticBlock11.ts, 1, 9))
constructor(x: number) {
>x : Symbol(x, Decl(classStaticBlock11.ts, 3, 14))
this.#x = x;
>this.#x : Symbol(C.#x, Decl(classStaticBlock11.ts, 1, 9))
>this : Symbol(C, Decl(classStaticBlock11.ts, 0, 9))
>x : Symbol(x, Decl(classStaticBlock11.ts, 3, 14))
}
static {
// getX has privileged access to #x
getX = (obj: C) => obj.#x;
>getX : Symbol(getX, Decl(classStaticBlock11.ts, 0, 3))
>obj : Symbol(obj, Decl(classStaticBlock11.ts, 9, 12))
>C : Symbol(C, Decl(classStaticBlock11.ts, 0, 9))
>obj.#x : Symbol(C.#x, Decl(classStaticBlock11.ts, 1, 9))
>obj : Symbol(obj, Decl(classStaticBlock11.ts, 9, 12))
}
}
@@ -0,0 +1,33 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock11.ts ===
let getX;
>getX : any
class C {
>C : C
#x = 1
>#x : number
>1 : 1
constructor(x: number) {
>x : number
this.#x = x;
>this.#x = x : number
>this.#x : number
>this : this
>x : number
}
static {
// getX has privileged access to #x
getX = (obj: C) => obj.#x;
>getX = (obj: C) => obj.#x : (obj: C) => number
>getX : any
>(obj: C) => obj.#x : (obj: C) => number
>obj : C
>obj.#x : number
>obj : C
}
}
@@ -0,0 +1,27 @@
//// [classStaticBlock11.ts]
let getX;
class C {
#x = 1
constructor(x: number) {
this.#x = x;
}
static {
// getX has privileged access to #x
getX = (obj: C) => obj.#x;
}
}
//// [classStaticBlock11.js]
let getX;
class C {
#x = 1;
constructor(x) {
this.#x = x;
}
static {
// getX has privileged access to #x
getX = (obj) => obj.#x;
}
}
@@ -0,0 +1,30 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock11.ts ===
let getX;
>getX : Symbol(getX, Decl(classStaticBlock11.ts, 0, 3))
class C {
>C : Symbol(C, Decl(classStaticBlock11.ts, 0, 9))
#x = 1
>#x : Symbol(C.#x, Decl(classStaticBlock11.ts, 1, 9))
constructor(x: number) {
>x : Symbol(x, Decl(classStaticBlock11.ts, 3, 14))
this.#x = x;
>this.#x : Symbol(C.#x, Decl(classStaticBlock11.ts, 1, 9))
>this : Symbol(C, Decl(classStaticBlock11.ts, 0, 9))
>x : Symbol(x, Decl(classStaticBlock11.ts, 3, 14))
}
static {
// getX has privileged access to #x
getX = (obj: C) => obj.#x;
>getX : Symbol(getX, Decl(classStaticBlock11.ts, 0, 3))
>obj : Symbol(obj, Decl(classStaticBlock11.ts, 9, 12))
>C : Symbol(C, Decl(classStaticBlock11.ts, 0, 9))
>obj.#x : Symbol(C.#x, Decl(classStaticBlock11.ts, 1, 9))
>obj : Symbol(obj, Decl(classStaticBlock11.ts, 9, 12))
}
}
@@ -0,0 +1,33 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock11.ts ===
let getX;
>getX : any
class C {
>C : C
#x = 1
>#x : number
>1 : 1
constructor(x: number) {
>x : number
this.#x = x;
>this.#x = x : number
>this.#x : number
>this : this
>x : number
}
static {
// getX has privileged access to #x
getX = (obj: C) => obj.#x;
>getX = (obj: C) => obj.#x : (obj: C) => number
>getX : any
>(obj: C) => obj.#x : (obj: C) => number
>obj : C
>obj.#x : number
>obj : C
}
}
@@ -0,0 +1,24 @@
//// [classStaticBlock12.ts]
class C {
static #x = 1;
static {
C.#x;
}
}
//// [classStaticBlock12.js]
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _a, _C_x;
class C {
}
_a = C;
_C_x = { value: 1 };
(() => {
__classPrivateFieldGet(C, _a, "f", _C_x);
})();
@@ -0,0 +1,14 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock12.ts ===
class C {
>C : Symbol(C, Decl(classStaticBlock12.ts, 0, 0))
static #x = 1;
>#x : Symbol(C.#x, Decl(classStaticBlock12.ts, 0, 9))
static {
C.#x;
>C.#x : Symbol(C.#x, Decl(classStaticBlock12.ts, 0, 9))
>C : Symbol(C, Decl(classStaticBlock12.ts, 0, 0))
}
}
@@ -0,0 +1,15 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock12.ts ===
class C {
>C : C
static #x = 1;
>#x : number
>1 : 1
static {
C.#x;
>C.#x : number
>C : typeof C
}
}
@@ -0,0 +1,31 @@
//// [classStaticBlock13.ts]
class C {
static #x = 123;
static {
console.log(C.#x)
}
foo () {
return C.#x;
}
}
//// [classStaticBlock13.js]
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _a, _C_x;
class C {
foo() {
return __classPrivateFieldGet(C, _a, "f", _C_x);
}
}
_a = C;
_C_x = { value: 123 };
(() => {
console.log(__classPrivateFieldGet(C, _a, "f", _C_x));
})();
@@ -0,0 +1,25 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock13.ts ===
class C {
>C : Symbol(C, Decl(classStaticBlock13.ts, 0, 0))
static #x = 123;
>#x : Symbol(C.#x, Decl(classStaticBlock13.ts, 0, 9))
static {
console.log(C.#x)
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>C.#x : Symbol(C.#x, Decl(classStaticBlock13.ts, 0, 9))
>C : Symbol(C, Decl(classStaticBlock13.ts, 0, 0))
}
foo () {
>foo : Symbol(C.foo, Decl(classStaticBlock13.ts, 5, 3))
return C.#x;
>C.#x : Symbol(C.#x, Decl(classStaticBlock13.ts, 0, 9))
>C : Symbol(C, Decl(classStaticBlock13.ts, 0, 0))
}
}
@@ -0,0 +1,27 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock13.ts ===
class C {
>C : C
static #x = 123;
>#x : number
>123 : 123
static {
console.log(C.#x)
>console.log(C.#x) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>C.#x : number
>C : typeof C
}
foo () {
>foo : () => number
return C.#x;
>C.#x : number
>C : typeof C
}
}
@@ -0,0 +1,24 @@
//// [classStaticBlock13.ts]
class C {
static #x = 123;
static {
console.log(C.#x)
}
foo () {
return C.#x;
}
}
//// [classStaticBlock13.js]
class C {
static #x = 123;
static {
console.log(C.#x);
}
foo() {
return C.#x;
}
}
@@ -0,0 +1,25 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock13.ts ===
class C {
>C : Symbol(C, Decl(classStaticBlock13.ts, 0, 0))
static #x = 123;
>#x : Symbol(C.#x, Decl(classStaticBlock13.ts, 0, 9))
static {
console.log(C.#x)
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>C.#x : Symbol(C.#x, Decl(classStaticBlock13.ts, 0, 9))
>C : Symbol(C, Decl(classStaticBlock13.ts, 0, 0))
}
foo () {
>foo : Symbol(C.foo, Decl(classStaticBlock13.ts, 5, 3))
return C.#x;
>C.#x : Symbol(C.#x, Decl(classStaticBlock13.ts, 0, 9))
>C : Symbol(C, Decl(classStaticBlock13.ts, 0, 0))
}
}
@@ -0,0 +1,27 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock13.ts ===
class C {
>C : C
static #x = 123;
>#x : number
>123 : 123
static {
console.log(C.#x)
>console.log(C.#x) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>C.#x : number
>C : typeof C
}
foo () {
>foo : () => number
return C.#x;
>C.#x : number
>C : typeof C
}
}
@@ -0,0 +1,35 @@
//// [classStaticBlock14.ts]
class C {
static #_1 = 1;
static #_3 = 1;
static #_5 = 1;
static {}
static {}
static {}
static {}
static {}
static {}
}
//// [classStaticBlock14.js]
var _a, _C__1, _C__3, _C__5;
class C {
}
_a = C;
_C__1 = { value: 1 };
_C__3 = { value: 1 };
_C__5 = { value: 1 };
(() => {
})();
(() => {
})();
(() => {
})();
(() => {
})();
(() => {
})();
(() => {
})();
@@ -0,0 +1,21 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock14.ts ===
class C {
>C : Symbol(C, Decl(classStaticBlock14.ts, 0, 0))
static #_1 = 1;
>#_1 : Symbol(C.#_1, Decl(classStaticBlock14.ts, 0, 9))
static #_3 = 1;
>#_3 : Symbol(C.#_3, Decl(classStaticBlock14.ts, 1, 17))
static #_5 = 1;
>#_5 : Symbol(C.#_5, Decl(classStaticBlock14.ts, 2, 17))
static {}
static {}
static {}
static {}
static {}
static {}
}
@@ -0,0 +1,24 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock14.ts ===
class C {
>C : C
static #_1 = 1;
>#_1 : number
>1 : 1
static #_3 = 1;
>#_3 : number
>1 : 1
static #_5 = 1;
>#_5 : number
>1 : 1
static {}
static {}
static {}
static {}
static {}
static {}
}
@@ -0,0 +1,41 @@
//// [classStaticBlock15.ts]
var _C__1;
class C {
static #_1 = 1;
static #_3 = 3;
static #_5 = 5;
static {}
static {}
static {}
static {}
static {}
static {}
}
console.log(_C__1)
//// [classStaticBlock15.js]
var _a, _C__1_1, _C__3, _C__5;
var _C__1;
class C {
}
_a = C;
_C__1_1 = { value: 1 };
_C__3 = { value: 3 };
_C__5 = { value: 5 };
(() => {
})();
(() => {
})();
(() => {
})();
(() => {
})();
(() => {
})();
(() => {
})();
console.log(_C__1);
@@ -0,0 +1,30 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock15.ts ===
var _C__1;
>_C__1 : Symbol(_C__1, Decl(classStaticBlock15.ts, 0, 3))
class C {
>C : Symbol(C, Decl(classStaticBlock15.ts, 0, 10))
static #_1 = 1;
>#_1 : Symbol(C.#_1, Decl(classStaticBlock15.ts, 2, 9))
static #_3 = 3;
>#_3 : Symbol(C.#_3, Decl(classStaticBlock15.ts, 3, 17))
static #_5 = 5;
>#_5 : Symbol(C.#_5, Decl(classStaticBlock15.ts, 4, 17))
static {}
static {}
static {}
static {}
static {}
static {}
}
console.log(_C__1)
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>_C__1 : Symbol(_C__1, Decl(classStaticBlock15.ts, 0, 3))
@@ -0,0 +1,34 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock15.ts ===
var _C__1;
>_C__1 : any
class C {
>C : C
static #_1 = 1;
>#_1 : number
>1 : 1
static #_3 = 3;
>#_3 : number
>3 : 3
static #_5 = 5;
>#_5 : number
>5 : 5
static {}
static {}
static {}
static {}
static {}
static {}
}
console.log(_C__1)
>console.log(_C__1) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>_C__1 : any
@@ -0,0 +1,33 @@
//// [classStaticBlock15.ts]
var _C__1;
class C {
static #_1 = 1;
static #_3 = 3;
static #_5 = 5;
static {}
static {}
static {}
static {}
static {}
static {}
}
console.log(_C__1)
//// [classStaticBlock15.js]
var _C__1;
class C {
static #_1 = 1;
static #_3 = 3;
static #_5 = 5;
static { }
static { }
static { }
static { }
static { }
static { }
}
console.log(_C__1);
@@ -0,0 +1,30 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock15.ts ===
var _C__1;
>_C__1 : Symbol(_C__1, Decl(classStaticBlock15.ts, 0, 3))
class C {
>C : Symbol(C, Decl(classStaticBlock15.ts, 0, 10))
static #_1 = 1;
>#_1 : Symbol(C.#_1, Decl(classStaticBlock15.ts, 2, 9))
static #_3 = 3;
>#_3 : Symbol(C.#_3, Decl(classStaticBlock15.ts, 3, 17))
static #_5 = 5;
>#_5 : Symbol(C.#_5, Decl(classStaticBlock15.ts, 4, 17))
static {}
static {}
static {}
static {}
static {}
static {}
}
console.log(_C__1)
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>_C__1 : Symbol(_C__1, Decl(classStaticBlock15.ts, 0, 3))
@@ -0,0 +1,34 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock15.ts ===
var _C__1;
>_C__1 : any
class C {
>C : C
static #_1 = 1;
>#_1 : number
>1 : 1
static #_3 = 3;
>#_3 : number
>3 : 3
static #_5 = 5;
>#_5 : number
>5 : 5
static {}
static {}
static {}
static {}
static {}
static {}
}
console.log(_C__1)
>console.log(_C__1) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>_C__1 : any
@@ -0,0 +1,37 @@
tests/cases/conformance/classes/classStaticBlock/classStaticBlock16.ts(11,5): error TS2448: Block-scoped variable 'getY' used before its declaration.
tests/cases/conformance/classes/classStaticBlock/classStaticBlock16.ts(11,28): error TS18013: Property '#y' is not accessible outside class 'D' because it has a private identifier.
tests/cases/conformance/classes/classStaticBlock/classStaticBlock16.ts(21,28): error TS18013: Property '#x' is not accessible outside class 'C' because it has a private identifier.
==== tests/cases/conformance/classes/classStaticBlock/classStaticBlock16.ts (3 errors) ====
let getX: (c: C) => number;
class C {
#x = 1
constructor(x: number) {
this.#x = x;
}
static {
// getX has privileged access to #x
getX = (obj: C) => obj.#x;
getY = (obj: D) => obj.#y;
~~~~
!!! error TS2448: Block-scoped variable 'getY' used before its declaration.
!!! related TS2728 tests/cases/conformance/classes/classStaticBlock/classStaticBlock16.ts:15:5: 'getY' is declared here.
~~
!!! error TS18013: Property '#y' is not accessible outside class 'D' because it has a private identifier.
}
}
let getY: (c: D) => number;
class D {
#y = 1
static {
// getY has privileged access to y
getX = (obj: C) => obj.#x;
~~
!!! error TS18013: Property '#x' is not accessible outside class 'C' because it has a private identifier.
getY = (obj: D) => obj.#y;
}
}
@@ -0,0 +1,64 @@
//// [classStaticBlock16.ts]
let getX: (c: C) => number;
class C {
#x = 1
constructor(x: number) {
this.#x = x;
}
static {
// getX has privileged access to #x
getX = (obj: C) => obj.#x;
getY = (obj: D) => obj.#y;
}
}
let getY: (c: D) => number;
class D {
#y = 1
static {
// getY has privileged access to y
getX = (obj: C) => obj.#x;
getY = (obj: D) => obj.#y;
}
}
//// [classStaticBlock16.js]
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _C_x, _D_y;
let getX;
class C {
constructor(x) {
_C_x.set(this, 1);
__classPrivateFieldSet(this, _C_x, x, "f");
}
}
_C_x = new WeakMap();
(() => {
// getX has privileged access to #x
getX = (obj) => __classPrivateFieldGet(obj, _C_x, "f");
getY = (obj) => obj.;
})();
let getY;
class D {
constructor() {
_D_y.set(this, 1);
}
}
_D_y = new WeakMap();
(() => {
// getY has privileged access to y
getX = (obj) => obj.;
getY = (obj) => __classPrivateFieldGet(obj, _D_y, "f");
})();
@@ -0,0 +1,65 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock16.ts ===
let getX: (c: C) => number;
>getX : Symbol(getX, Decl(classStaticBlock16.ts, 0, 3))
>c : Symbol(c, Decl(classStaticBlock16.ts, 0, 11))
>C : Symbol(C, Decl(classStaticBlock16.ts, 0, 27))
class C {
>C : Symbol(C, Decl(classStaticBlock16.ts, 0, 27))
#x = 1
>#x : Symbol(C.#x, Decl(classStaticBlock16.ts, 1, 9))
constructor(x: number) {
>x : Symbol(x, Decl(classStaticBlock16.ts, 3, 14))
this.#x = x;
>this.#x : Symbol(C.#x, Decl(classStaticBlock16.ts, 1, 9))
>this : Symbol(C, Decl(classStaticBlock16.ts, 0, 27))
>x : Symbol(x, Decl(classStaticBlock16.ts, 3, 14))
}
static {
// getX has privileged access to #x
getX = (obj: C) => obj.#x;
>getX : Symbol(getX, Decl(classStaticBlock16.ts, 0, 3))
>obj : Symbol(obj, Decl(classStaticBlock16.ts, 9, 12))
>C : Symbol(C, Decl(classStaticBlock16.ts, 0, 27))
>obj.#x : Symbol(C.#x, Decl(classStaticBlock16.ts, 1, 9))
>obj : Symbol(obj, Decl(classStaticBlock16.ts, 9, 12))
getY = (obj: D) => obj.#y;
>getY : Symbol(getY, Decl(classStaticBlock16.ts, 14, 3))
>obj : Symbol(obj, Decl(classStaticBlock16.ts, 10, 12))
>D : Symbol(D, Decl(classStaticBlock16.ts, 14, 27))
>obj : Symbol(obj, Decl(classStaticBlock16.ts, 10, 12))
}
}
let getY: (c: D) => number;
>getY : Symbol(getY, Decl(classStaticBlock16.ts, 14, 3))
>c : Symbol(c, Decl(classStaticBlock16.ts, 14, 11))
>D : Symbol(D, Decl(classStaticBlock16.ts, 14, 27))
class D {
>D : Symbol(D, Decl(classStaticBlock16.ts, 14, 27))
#y = 1
>#y : Symbol(D.#y, Decl(classStaticBlock16.ts, 15, 9))
static {
// getY has privileged access to y
getX = (obj: C) => obj.#x;
>getX : Symbol(getX, Decl(classStaticBlock16.ts, 0, 3))
>obj : Symbol(obj, Decl(classStaticBlock16.ts, 20, 12))
>C : Symbol(C, Decl(classStaticBlock16.ts, 0, 27))
>obj : Symbol(obj, Decl(classStaticBlock16.ts, 20, 12))
getY = (obj: D) => obj.#y;
>getY : Symbol(getY, Decl(classStaticBlock16.ts, 14, 3))
>obj : Symbol(obj, Decl(classStaticBlock16.ts, 21, 12))
>D : Symbol(D, Decl(classStaticBlock16.ts, 14, 27))
>obj.#y : Symbol(D.#y, Decl(classStaticBlock16.ts, 15, 9))
>obj : Symbol(obj, Decl(classStaticBlock16.ts, 21, 12))
}
}
@@ -0,0 +1,72 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock16.ts ===
let getX: (c: C) => number;
>getX : (c: C) => number
>c : C
class C {
>C : C
#x = 1
>#x : number
>1 : 1
constructor(x: number) {
>x : number
this.#x = x;
>this.#x = x : number
>this.#x : number
>this : this
>x : number
}
static {
// getX has privileged access to #x
getX = (obj: C) => obj.#x;
>getX = (obj: C) => obj.#x : (obj: C) => number
>getX : (c: C) => number
>(obj: C) => obj.#x : (obj: C) => number
>obj : C
>obj.#x : number
>obj : C
getY = (obj: D) => obj.#y;
>getY = (obj: D) => obj.#y : (obj: D) => any
>getY : (c: D) => number
>(obj: D) => obj.#y : (obj: D) => any
>obj : D
>obj.#y : any
>obj : D
}
}
let getY: (c: D) => number;
>getY : (c: D) => number
>c : D
class D {
>D : D
#y = 1
>#y : number
>1 : 1
static {
// getY has privileged access to y
getX = (obj: C) => obj.#x;
>getX = (obj: C) => obj.#x : (obj: C) => any
>getX : (c: C) => number
>(obj: C) => obj.#x : (obj: C) => any
>obj : C
>obj.#x : any
>obj : C
getY = (obj: D) => obj.#y;
>getY = (obj: D) => obj.#y : (obj: D) => number
>getY : (c: D) => number
>(obj: D) => obj.#y : (obj: D) => number
>obj : D
>obj.#y : number
>obj : D
}
}
@@ -0,0 +1,74 @@
//// [classStaticBlock17.ts]
let friendA: { getX(o: A): number, setX(o: A, v: number): void };
class A {
#x: number;
constructor (v: number) {
this.#x = v;
}
getX () {
return this.#x;
}
static {
friendA = {
getX(obj) { return obj.#x },
setX(obj, value) { obj.#x = value }
};
}
};
class B {
constructor(a: A) {
const x = friendA.getX(a); // ok
friendA.setX(a, x + 1); // ok
}
};
const a = new A(41);
const b = new B(a);
a.getX();
//// [classStaticBlock17.js]
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _A_x;
let friendA;
class A {
constructor(v) {
_A_x.set(this, void 0);
__classPrivateFieldSet(this, _A_x, v, "f");
}
getX() {
return __classPrivateFieldGet(this, _A_x, "f");
}
}
_A_x = new WeakMap();
(() => {
friendA = {
getX(obj) { return __classPrivateFieldGet(obj, _A_x, "f"); },
setX(obj, value) { __classPrivateFieldSet(obj, _A_x, value, "f"); }
};
})();
;
class B {
constructor(a) {
const x = friendA.getX(a); // ok
friendA.setX(a, x + 1); // ok
}
}
;
const a = new A(41);
const b = new B(a);
a.getX();
@@ -0,0 +1,93 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock17.ts ===
let friendA: { getX(o: A): number, setX(o: A, v: number): void };
>friendA : Symbol(friendA, Decl(classStaticBlock17.ts, 0, 3))
>getX : Symbol(getX, Decl(classStaticBlock17.ts, 0, 14))
>o : Symbol(o, Decl(classStaticBlock17.ts, 0, 20))
>A : Symbol(A, Decl(classStaticBlock17.ts, 0, 65))
>setX : Symbol(setX, Decl(classStaticBlock17.ts, 0, 34))
>o : Symbol(o, Decl(classStaticBlock17.ts, 0, 40))
>A : Symbol(A, Decl(classStaticBlock17.ts, 0, 65))
>v : Symbol(v, Decl(classStaticBlock17.ts, 0, 45))
class A {
>A : Symbol(A, Decl(classStaticBlock17.ts, 0, 65))
#x: number;
>#x : Symbol(A.#x, Decl(classStaticBlock17.ts, 2, 9))
constructor (v: number) {
>v : Symbol(v, Decl(classStaticBlock17.ts, 5, 15))
this.#x = v;
>this.#x : Symbol(A.#x, Decl(classStaticBlock17.ts, 2, 9))
>this : Symbol(A, Decl(classStaticBlock17.ts, 0, 65))
>v : Symbol(v, Decl(classStaticBlock17.ts, 5, 15))
}
getX () {
>getX : Symbol(A.getX, Decl(classStaticBlock17.ts, 7, 3))
return this.#x;
>this.#x : Symbol(A.#x, Decl(classStaticBlock17.ts, 2, 9))
>this : Symbol(A, Decl(classStaticBlock17.ts, 0, 65))
}
static {
friendA = {
>friendA : Symbol(friendA, Decl(classStaticBlock17.ts, 0, 3))
getX(obj) { return obj.#x },
>getX : Symbol(getX, Decl(classStaticBlock17.ts, 14, 15))
>obj : Symbol(obj, Decl(classStaticBlock17.ts, 15, 11))
>obj.#x : Symbol(A.#x, Decl(classStaticBlock17.ts, 2, 9))
>obj : Symbol(obj, Decl(classStaticBlock17.ts, 15, 11))
setX(obj, value) { obj.#x = value }
>setX : Symbol(setX, Decl(classStaticBlock17.ts, 15, 34))
>obj : Symbol(obj, Decl(classStaticBlock17.ts, 16, 11))
>value : Symbol(value, Decl(classStaticBlock17.ts, 16, 15))
>obj.#x : Symbol(A.#x, Decl(classStaticBlock17.ts, 2, 9))
>obj : Symbol(obj, Decl(classStaticBlock17.ts, 16, 11))
>value : Symbol(value, Decl(classStaticBlock17.ts, 16, 15))
};
}
};
class B {
>B : Symbol(B, Decl(classStaticBlock17.ts, 19, 2))
constructor(a: A) {
>a : Symbol(a, Decl(classStaticBlock17.ts, 22, 14))
>A : Symbol(A, Decl(classStaticBlock17.ts, 0, 65))
const x = friendA.getX(a); // ok
>x : Symbol(x, Decl(classStaticBlock17.ts, 23, 9))
>friendA.getX : Symbol(getX, Decl(classStaticBlock17.ts, 0, 14))
>friendA : Symbol(friendA, Decl(classStaticBlock17.ts, 0, 3))
>getX : Symbol(getX, Decl(classStaticBlock17.ts, 0, 14))
>a : Symbol(a, Decl(classStaticBlock17.ts, 22, 14))
friendA.setX(a, x + 1); // ok
>friendA.setX : Symbol(setX, Decl(classStaticBlock17.ts, 0, 34))
>friendA : Symbol(friendA, Decl(classStaticBlock17.ts, 0, 3))
>setX : Symbol(setX, Decl(classStaticBlock17.ts, 0, 34))
>a : Symbol(a, Decl(classStaticBlock17.ts, 22, 14))
>x : Symbol(x, Decl(classStaticBlock17.ts, 23, 9))
}
};
const a = new A(41);
>a : Symbol(a, Decl(classStaticBlock17.ts, 28, 5))
>A : Symbol(A, Decl(classStaticBlock17.ts, 0, 65))
const b = new B(a);
>b : Symbol(b, Decl(classStaticBlock17.ts, 29, 5))
>B : Symbol(B, Decl(classStaticBlock17.ts, 19, 2))
>a : Symbol(a, Decl(classStaticBlock17.ts, 28, 5))
a.getX();
>a.getX : Symbol(A.getX, Decl(classStaticBlock17.ts, 7, 3))
>a : Symbol(a, Decl(classStaticBlock17.ts, 28, 5))
>getX : Symbol(A.getX, Decl(classStaticBlock17.ts, 7, 3))
@@ -0,0 +1,102 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock17.ts ===
let friendA: { getX(o: A): number, setX(o: A, v: number): void };
>friendA : { getX(o: A): number; setX(o: A, v: number): void; }
>getX : (o: A) => number
>o : A
>setX : (o: A, v: number) => void
>o : A
>v : number
class A {
>A : A
#x: number;
>#x : number
constructor (v: number) {
>v : number
this.#x = v;
>this.#x = v : number
>this.#x : number
>this : this
>v : number
}
getX () {
>getX : () => number
return this.#x;
>this.#x : number
>this : this
}
static {
friendA = {
>friendA = { getX(obj) { return obj.#x }, setX(obj, value) { obj.#x = value } } : { getX(obj: A): number; setX(obj: A, value: number): void; }
>friendA : { getX(o: A): number; setX(o: A, v: number): void; }
>{ getX(obj) { return obj.#x }, setX(obj, value) { obj.#x = value } } : { getX(obj: A): number; setX(obj: A, value: number): void; }
getX(obj) { return obj.#x },
>getX : (obj: A) => number
>obj : A
>obj.#x : number
>obj : A
setX(obj, value) { obj.#x = value }
>setX : (obj: A, value: number) => void
>obj : A
>value : number
>obj.#x = value : number
>obj.#x : number
>obj : A
>value : number
};
}
};
class B {
>B : B
constructor(a: A) {
>a : A
const x = friendA.getX(a); // ok
>x : number
>friendA.getX(a) : number
>friendA.getX : (o: A) => number
>friendA : { getX(o: A): number; setX(o: A, v: number): void; }
>getX : (o: A) => number
>a : A
friendA.setX(a, x + 1); // ok
>friendA.setX(a, x + 1) : void
>friendA.setX : (o: A, v: number) => void
>friendA : { getX(o: A): number; setX(o: A, v: number): void; }
>setX : (o: A, v: number) => void
>a : A
>x + 1 : number
>x : number
>1 : 1
}
};
const a = new A(41);
>a : A
>new A(41) : A
>A : typeof A
>41 : 41
const b = new B(a);
>b : B
>new B(a) : B
>B : typeof B
>a : A
a.getX();
>a.getX() : number
>a.getX : () => number
>a : A
>getX : () => number
@@ -0,0 +1,34 @@
//// [classStaticBlock18.ts]
function foo () {
return class {
static foo = 1;
static {
const c = class {
static bar = 2;
static {
// do
}
}
}
}
}
//// [classStaticBlock18.js]
function foo() {
var _a;
return _a = class {
},
_a.foo = 1,
(() => {
var _a;
const c = (_a = class {
},
_a.bar = 2,
(() => {
// do
})(),
_a);
})(),
_a;
}
@@ -0,0 +1,23 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock18.ts ===
function foo () {
>foo : Symbol(foo, Decl(classStaticBlock18.ts, 0, 0))
return class {
static foo = 1;
>foo : Symbol((Anonymous class).foo, Decl(classStaticBlock18.ts, 1, 16))
static {
const c = class {
>c : Symbol(c, Decl(classStaticBlock18.ts, 4, 11))
static bar = 2;
>bar : Symbol(c.bar, Decl(classStaticBlock18.ts, 4, 23))
static {
// do
}
}
}
}
}
@@ -0,0 +1,28 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock18.ts ===
function foo () {
>foo : () => typeof (Anonymous class)
return class {
>class { static foo = 1; static { const c = class { static bar = 2; static { // do } } } } : typeof (Anonymous class)
static foo = 1;
>foo : number
>1 : 1
static {
const c = class {
>c : typeof c
>class { static bar = 2; static { // do } } : typeof c
static bar = 2;
>bar : number
>2 : 2
static {
// do
}
}
}
}
}
@@ -0,0 +1,40 @@
//// [classStaticBlock18.ts]
function foo () {
return class {
static foo = 1;
static {
const c = class {
static bar = 2;
static {
// do
}
}
}
}
}
//// [classStaticBlock18.js]
function foo() {
var _a;
return _a = /** @class */ (function () {
function class_1() {
}
return class_1;
}()),
_a.foo = 1,
(function () {
var _a;
var c = (_a = /** @class */ (function () {
function class_2() {
}
return class_2;
}()),
_a.bar = 2,
(function () {
// do
})(),
_a);
})(),
_a;
}
@@ -0,0 +1,23 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock18.ts ===
function foo () {
>foo : Symbol(foo, Decl(classStaticBlock18.ts, 0, 0))
return class {
static foo = 1;
>foo : Symbol((Anonymous class).foo, Decl(classStaticBlock18.ts, 1, 16))
static {
const c = class {
>c : Symbol(c, Decl(classStaticBlock18.ts, 4, 11))
static bar = 2;
>bar : Symbol(c.bar, Decl(classStaticBlock18.ts, 4, 23))
static {
// do
}
}
}
}
}
@@ -0,0 +1,28 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock18.ts ===
function foo () {
>foo : () => typeof (Anonymous class)
return class {
>class { static foo = 1; static { const c = class { static bar = 2; static { // do } } } } : typeof (Anonymous class)
static foo = 1;
>foo : number
>1 : 1
static {
const c = class {
>c : typeof c
>class { static bar = 2; static { // do } } : typeof c
static bar = 2;
>bar : number
>2 : 2
static {
// do
}
}
}
}
}
@@ -0,0 +1,30 @@
//// [classStaticBlock18.ts]
function foo () {
return class {
static foo = 1;
static {
const c = class {
static bar = 2;
static {
// do
}
}
}
}
}
//// [classStaticBlock18.js]
function foo() {
return class {
static foo = 1;
static {
const c = class {
static bar = 2;
static {
// do
}
};
}
};
}
@@ -0,0 +1,23 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock18.ts ===
function foo () {
>foo : Symbol(foo, Decl(classStaticBlock18.ts, 0, 0))
return class {
static foo = 1;
>foo : Symbol((Anonymous class).foo, Decl(classStaticBlock18.ts, 1, 16))
static {
const c = class {
>c : Symbol(c, Decl(classStaticBlock18.ts, 4, 11))
static bar = 2;
>bar : Symbol(c.bar, Decl(classStaticBlock18.ts, 4, 23))
static {
// do
}
}
}
}
}
@@ -0,0 +1,28 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock18.ts ===
function foo () {
>foo : () => typeof (Anonymous class)
return class {
>class { static foo = 1; static { const c = class { static bar = 2; static { // do } } } } : typeof (Anonymous class)
static foo = 1;
>foo : number
>1 : 1
static {
const c = class {
>c : typeof c
>class { static bar = 2; static { // do } } : typeof c
static bar = 2;
>bar : number
>2 : 2
static {
// do
}
}
}
}
}
@@ -0,0 +1,13 @@
tests/cases/conformance/classes/classStaticBlock/classStaticBlock19.ts(2,5): error TS1206: Decorators are not valid here.
==== tests/cases/conformance/classes/classStaticBlock/classStaticBlock19.ts (1 errors) ====
class C {
@decorator
~
!!! error TS1206: Decorators are not valid here.
static {
// something
}
}
@@ -0,0 +1,18 @@
//// [classStaticBlock19.ts]
class C {
@decorator
static {
// something
}
}
//// [classStaticBlock19.js]
var C = /** @class */ (function () {
function C() {
}
return C;
}());
(function () {
// something
})();
@@ -0,0 +1,10 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock19.ts ===
class C {
>C : Symbol(C, Decl(classStaticBlock19.ts, 0, 0))
@decorator
static {
// something
}
}
@@ -0,0 +1,12 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock19.ts ===
class C {
>C : C
@decorator
>decorator : any
static {
// something
}
}
@@ -0,0 +1,36 @@
//// [classStaticBlock2.ts]
const a = 1;
const b = 2;
class C {
static {
const a = 11;
a;
b;
}
static {
const a = 11;
a;
b;
}
}
//// [classStaticBlock2.js]
const a = 1;
const b = 2;
class C {
}
(() => {
const a = 11;
a;
b;
})();
(() => {
const a = 11;
a;
b;
})();
@@ -0,0 +1,33 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock2.ts ===
const a = 1;
>a : Symbol(a, Decl(classStaticBlock2.ts, 0, 5))
const b = 2;
>b : Symbol(b, Decl(classStaticBlock2.ts, 1, 5))
class C {
>C : Symbol(C, Decl(classStaticBlock2.ts, 1, 12))
static {
const a = 11;
>a : Symbol(a, Decl(classStaticBlock2.ts, 5, 13))
a;
>a : Symbol(a, Decl(classStaticBlock2.ts, 5, 13))
b;
>b : Symbol(b, Decl(classStaticBlock2.ts, 1, 5))
}
static {
const a = 11;
>a : Symbol(a, Decl(classStaticBlock2.ts, 12, 13))
a;
>a : Symbol(a, Decl(classStaticBlock2.ts, 12, 13))
b;
>b : Symbol(b, Decl(classStaticBlock2.ts, 1, 5))
}
}
@@ -0,0 +1,37 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock2.ts ===
const a = 1;
>a : 1
>1 : 1
const b = 2;
>b : 2
>2 : 2
class C {
>C : C
static {
const a = 11;
>a : 11
>11 : 11
a;
>a : 11
b;
>b : 2
}
static {
const a = 11;
>a : 11
>11 : 11
a;
>a : 11
b;
>b : 2
}
}
@@ -0,0 +1,39 @@
//// [classStaticBlock2.ts]
const a = 1;
const b = 2;
class C {
static {
const a = 11;
a;
b;
}
static {
const a = 11;
a;
b;
}
}
//// [classStaticBlock2.js]
var a = 1;
var b = 2;
var C = /** @class */ (function () {
function C() {
}
return C;
}());
(function () {
var a = 11;
a;
b;
})();
(function () {
var a = 11;
a;
b;
})();
@@ -0,0 +1,33 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock2.ts ===
const a = 1;
>a : Symbol(a, Decl(classStaticBlock2.ts, 0, 5))
const b = 2;
>b : Symbol(b, Decl(classStaticBlock2.ts, 1, 5))
class C {
>C : Symbol(C, Decl(classStaticBlock2.ts, 1, 12))
static {
const a = 11;
>a : Symbol(a, Decl(classStaticBlock2.ts, 5, 13))
a;
>a : Symbol(a, Decl(classStaticBlock2.ts, 5, 13))
b;
>b : Symbol(b, Decl(classStaticBlock2.ts, 1, 5))
}
static {
const a = 11;
>a : Symbol(a, Decl(classStaticBlock2.ts, 12, 13))
a;
>a : Symbol(a, Decl(classStaticBlock2.ts, 12, 13))
b;
>b : Symbol(b, Decl(classStaticBlock2.ts, 1, 5))
}
}
@@ -0,0 +1,37 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock2.ts ===
const a = 1;
>a : 1
>1 : 1
const b = 2;
>b : 2
>2 : 2
class C {
>C : C
static {
const a = 11;
>a : 11
>11 : 11
a;
>a : 11
b;
>b : 2
}
static {
const a = 11;
>a : 11
>11 : 11
a;
>a : 11
b;
>b : 2
}
}
@@ -0,0 +1,36 @@
//// [classStaticBlock2.ts]
const a = 1;
const b = 2;
class C {
static {
const a = 11;
a;
b;
}
static {
const a = 11;
a;
b;
}
}
//// [classStaticBlock2.js]
const a = 1;
const b = 2;
class C {
static {
const a = 11;
a;
b;
}
static {
const a = 11;
a;
b;
}
}
@@ -0,0 +1,33 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock2.ts ===
const a = 1;
>a : Symbol(a, Decl(classStaticBlock2.ts, 0, 5))
const b = 2;
>b : Symbol(b, Decl(classStaticBlock2.ts, 1, 5))
class C {
>C : Symbol(C, Decl(classStaticBlock2.ts, 1, 12))
static {
const a = 11;
>a : Symbol(a, Decl(classStaticBlock2.ts, 5, 13))
a;
>a : Symbol(a, Decl(classStaticBlock2.ts, 5, 13))
b;
>b : Symbol(b, Decl(classStaticBlock2.ts, 1, 5))
}
static {
const a = 11;
>a : Symbol(a, Decl(classStaticBlock2.ts, 12, 13))
a;
>a : Symbol(a, Decl(classStaticBlock2.ts, 12, 13))
b;
>b : Symbol(b, Decl(classStaticBlock2.ts, 1, 5))
}
}
@@ -0,0 +1,37 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock2.ts ===
const a = 1;
>a : 1
>1 : 1
const b = 2;
>b : 2
>2 : 2
class C {
>C : C
static {
const a = 11;
>a : 11
>11 : 11
a;
>a : 11
b;
>b : 2
}
static {
const a = 11;
>a : 11
>11 : 11
a;
>a : 11
b;
>b : 2
}
}
@@ -0,0 +1,26 @@
tests/cases/conformance/classes/classStaticBlock/classStaticBlock20.ts(2,5): error TS1184: Modifiers cannot appear here.
tests/cases/conformance/classes/classStaticBlock/classStaticBlock20.ts(6,5): error TS1184: Modifiers cannot appear here.
tests/cases/conformance/classes/classStaticBlock/classStaticBlock20.ts(10,5): error TS1184: Modifiers cannot appear here.
==== tests/cases/conformance/classes/classStaticBlock/classStaticBlock20.ts (3 errors) ====
class C {
async static {
~~~~~
!!! error TS1184: Modifiers cannot appear here.
// something
}
public static {
~~~~~~
!!! error TS1184: Modifiers cannot appear here.
// something
}
readonly private static {
~~~~~~~~
!!! error TS1184: Modifiers cannot appear here.
// something
}
}
@@ -0,0 +1,31 @@
//// [classStaticBlock20.ts]
class C {
async static {
// something
}
public static {
// something
}
readonly private static {
// something
}
}
//// [classStaticBlock20.js]
var C = /** @class */ (function () {
function C() {
}
return C;
}());
(function () {
// something
})();
(function () {
// something
})();
(function () {
// something
})();
@@ -0,0 +1,17 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock20.ts ===
class C {
>C : Symbol(C, Decl(classStaticBlock20.ts, 0, 0))
async static {
// something
}
public static {
// something
}
readonly private static {
// something
}
}
@@ -0,0 +1,17 @@
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlock20.ts ===
class C {
>C : C
async static {
// something
}
public static {
// something
}
readonly private static {
// something
}
}
Loaded 100 of 217 files, more files were not shown because too many files have changed in this diff. Show more