mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Change static fields emits (#43114)
* use emit into iife * Update emit * Revert un-related changes * Allow super in static context * Allow this and super in static property declaration * Add more tests * Avoid errors * Accept baseline * Accept baseline * Add decorated classes test * Add errors * Avoid this in emitter * make lint happy * Add class expression tests * Add computed name test * Avoid super if target below es6 * Adjust function boundary * Add internal * Fix minor CR issues * accept baseline * Update behavior * Avoid spaces * Make lint happy * Avoid function boundary utils * Update baseline * Avoid errors * Accept baseline * Accept baseline * Accept baseline * Accept baseline * Use substitutions * Full coverage for super, this, merge static and private context * Fix use-before-def in static fields Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
This commit is contained in:
@@ -669,7 +669,7 @@ namespace ts {
|
||||
}
|
||||
// We create a return control flow graph for IIFEs and constructors. For constructors
|
||||
// we use the return control flow graph in strict property initialization checks.
|
||||
currentReturnTarget = isIIFE || node.kind === SyntaxKind.Constructor || (isInJSFile(node) && (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression)) ? createBranchLabel() : undefined;
|
||||
currentReturnTarget = isIIFE || node.kind === SyntaxKind.Constructor || node.kind === SyntaxKind.ClassStaticBlockDeclaration || (isInJSFile(node) && (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression)) ? createBranchLabel() : undefined;
|
||||
currentExceptionTarget = undefined;
|
||||
currentBreakTarget = undefined;
|
||||
currentContinueTarget = undefined;
|
||||
@@ -678,10 +678,10 @@ namespace ts {
|
||||
bindChildren(node);
|
||||
// Reset all reachability check related flags on node (for incremental scenarios)
|
||||
node.flags &= ~NodeFlags.ReachabilityAndEmitFlags;
|
||||
if (!(currentFlow.flags & FlowFlags.Unreachable) && containerFlags & ContainerFlags.IsFunctionLike && nodeIsPresent((node as FunctionLikeDeclaration).body)) {
|
||||
if (!(currentFlow.flags & FlowFlags.Unreachable) && containerFlags & ContainerFlags.IsFunctionLike && nodeIsPresent((node as FunctionLikeDeclaration | ClassStaticBlockDeclaration).body)) {
|
||||
node.flags |= NodeFlags.HasImplicitReturn;
|
||||
if (hasExplicitReturn) node.flags |= NodeFlags.HasExplicitReturn;
|
||||
(node as FunctionLikeDeclaration).endFlowNode = currentFlow;
|
||||
(node as FunctionLikeDeclaration | ClassStaticBlockDeclaration).endFlowNode = currentFlow;
|
||||
}
|
||||
if (node.kind === SyntaxKind.SourceFile) {
|
||||
node.flags |= emitFlags;
|
||||
@@ -691,8 +691,8 @@ namespace ts {
|
||||
if (currentReturnTarget) {
|
||||
addAntecedent(currentReturnTarget, currentFlow);
|
||||
currentFlow = finishFlowLabel(currentReturnTarget);
|
||||
if (node.kind === SyntaxKind.Constructor || (isInJSFile(node) && (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression))) {
|
||||
(node as FunctionLikeDeclaration).returnFlowNode = currentFlow;
|
||||
if (node.kind === SyntaxKind.Constructor || node.kind === SyntaxKind.ClassStaticBlockDeclaration || (isInJSFile(node) && (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression))) {
|
||||
(node as FunctionLikeDeclaration | ClassStaticBlockDeclaration).returnFlowNode = currentFlow;
|
||||
}
|
||||
}
|
||||
if (!isIIFE) {
|
||||
@@ -1944,7 +1944,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function declareClassMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
|
||||
return hasSyntacticModifier(node, ModifierFlags.Static)
|
||||
return isStatic(node)
|
||||
? declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes)
|
||||
: declareSymbol(container.symbol.members!, container.symbol, node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
@@ -2950,7 +2950,7 @@ namespace ts {
|
||||
// this.foo assignment in a JavaScript class
|
||||
// Bind this property to the containing class
|
||||
const containingClass = thisContainer.parent;
|
||||
const symbolTable = hasSyntacticModifier(thisContainer, ModifierFlags.Static) ? containingClass.symbol.exports! : containingClass.symbol.members!;
|
||||
const symbolTable = isStatic(thisContainer) ? containingClass.symbol.exports! : containingClass.symbol.members!;
|
||||
if (hasDynamicName(node)) {
|
||||
bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable);
|
||||
}
|
||||
|
||||
+136
-75
@@ -1579,21 +1579,34 @@ namespace ts {
|
||||
if (isFunctionLike(current)) {
|
||||
return true;
|
||||
}
|
||||
if (isClassStaticBlockDeclaration(current)) {
|
||||
return declaration.pos < usage.pos;
|
||||
}
|
||||
|
||||
const initializerOfProperty = current.parent &&
|
||||
current.parent.kind === SyntaxKind.PropertyDeclaration &&
|
||||
(current.parent as PropertyDeclaration).initializer === current;
|
||||
|
||||
if (initializerOfProperty) {
|
||||
if (hasSyntacticModifier(current.parent, ModifierFlags.Static)) {
|
||||
if (declaration.kind === SyntaxKind.MethodDeclaration) {
|
||||
return true;
|
||||
const propertyDeclaration = tryCast(current.parent, isPropertyDeclaration);
|
||||
if (propertyDeclaration) {
|
||||
const initializerOfProperty = propertyDeclaration.initializer === current;
|
||||
if (initializerOfProperty) {
|
||||
if (isStatic(current.parent)) {
|
||||
if (declaration.kind === SyntaxKind.MethodDeclaration) {
|
||||
return true;
|
||||
}
|
||||
if (isPropertyDeclaration(declaration) && getContainingClass(usage) === getContainingClass(declaration)) {
|
||||
const propName = declaration.name;
|
||||
if (isIdentifier(propName) || isPrivateIdentifier(propName)) {
|
||||
const type = getTypeOfSymbol(getSymbolOfNode(declaration));
|
||||
const staticBlocks = filter(declaration.parent.members, isClassStaticBlockDeclaration);
|
||||
if (isPropertyInitializedInStaticBlocks(propName, type, staticBlocks, declaration.parent.pos, current.pos)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const isDeclarationInstanceProperty = declaration.kind === SyntaxKind.PropertyDeclaration && !hasSyntacticModifier(declaration, ModifierFlags.Static);
|
||||
if (!isDeclarationInstanceProperty || getContainingClass(usage) !== getContainingClass(declaration)) {
|
||||
return true;
|
||||
else {
|
||||
const isDeclarationInstanceProperty = declaration.kind === SyntaxKind.PropertyDeclaration && !isStatic(declaration);
|
||||
if (!isDeclarationInstanceProperty || getContainingClass(usage) !== getContainingClass(declaration)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1857,7 +1870,7 @@ namespace ts {
|
||||
// local variables of the constructor. This effectively means that entities from outer scopes
|
||||
// by the same name as a constructor parameter or local variable are inaccessible
|
||||
// in initializer expressions for instance member variables.
|
||||
if (!hasSyntacticModifier(location, ModifierFlags.Static)) {
|
||||
if (!isStatic(location)) {
|
||||
const ctor = findConstructorDeclaration(location.parent as ClassLikeDeclaration);
|
||||
if (ctor && ctor.locals) {
|
||||
if (lookup(ctor.locals, name, meaning & SymbolFlags.Value)) {
|
||||
@@ -1879,7 +1892,7 @@ namespace ts {
|
||||
result = undefined;
|
||||
break;
|
||||
}
|
||||
if (lastLocation && hasSyntacticModifier(lastLocation, ModifierFlags.Static)) {
|
||||
if (lastLocation && isStatic(lastLocation)) {
|
||||
// TypeScript 1.0 spec (April 2014): 3.4.1
|
||||
// The scope of a type parameter extends over the entire declaration with which the type
|
||||
// parameter list is associated, with the exception of static member declarations in classes.
|
||||
@@ -2189,7 +2202,7 @@ namespace ts {
|
||||
// initializers in instance property declaration of class like entities are executed in constructor and thus deferred
|
||||
return isTypeQueryNode(location) || ((
|
||||
isFunctionLikeDeclaration(location) ||
|
||||
(location.kind === SyntaxKind.PropertyDeclaration && !hasSyntacticModifier(location, ModifierFlags.Static))
|
||||
(location.kind === SyntaxKind.PropertyDeclaration && !isStatic(location))
|
||||
) && (!lastLocation || lastLocation !== (location as SignatureDeclaration | PropertyDeclaration).name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred
|
||||
}
|
||||
if (lastLocation && lastLocation === (location as FunctionExpression | ArrowFunction).name) {
|
||||
@@ -2258,7 +2271,7 @@ namespace ts {
|
||||
|
||||
// No static member is present.
|
||||
// Check if we're in an instance method and look for a relevant instance member.
|
||||
if (location === container && !hasSyntacticModifier(location, ModifierFlags.Static)) {
|
||||
if (location === container && !isStatic(location)) {
|
||||
const instanceType = (getDeclaredTypeOfSymbol(classSymbol) as InterfaceType).thisType!; // TODO: GH#18217
|
||||
if (getPropertyOfType(instanceType, name)) {
|
||||
error(errorLocation, Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg));
|
||||
@@ -4855,7 +4868,7 @@ namespace ts {
|
||||
}
|
||||
function shouldWriteTypeOfFunctionSymbol() {
|
||||
const isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method) && // typeof static method
|
||||
some(symbol.declarations, declaration => hasSyntacticModifier(declaration, ModifierFlags.Static));
|
||||
some(symbol.declarations, declaration => isStatic(declaration));
|
||||
const isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) &&
|
||||
(symbol.parent || // is exported function symbol
|
||||
forEach(symbol.declarations, declaration =>
|
||||
@@ -7008,7 +7021,7 @@ namespace ts {
|
||||
|
||||
function isNamespaceMember(p: Symbol) {
|
||||
return !!(p.flags & (SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias)) ||
|
||||
!(p.flags & SymbolFlags.Prototype || p.escapedName === "prototype" || p.valueDeclaration && getEffectiveModifierFlags(p.valueDeclaration) & ModifierFlags.Static && isClassLike(p.valueDeclaration.parent));
|
||||
!(p.flags & SymbolFlags.Prototype || p.escapedName === "prototype" || p.valueDeclaration && isStatic(p.valueDeclaration) && isClassLike(p.valueDeclaration.parent));
|
||||
}
|
||||
|
||||
function sanitizeJSDocImplements(clauses: readonly ExpressionWithTypeArguments[]): ExpressionWithTypeArguments[] | undefined {
|
||||
@@ -8448,14 +8461,23 @@ namespace ts {
|
||||
return addOptionality(type, isProperty, isOptional);
|
||||
}
|
||||
|
||||
if (isPropertyDeclaration(declaration) && !hasStaticModifier(declaration) && (noImplicitAny || isInJSFile(declaration))) {
|
||||
if (isPropertyDeclaration(declaration) && (noImplicitAny || isInJSFile(declaration))) {
|
||||
// We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file.
|
||||
// Use control flow analysis of this.xxx assignments in the constructor to determine the type of the property.
|
||||
const constructor = findConstructorDeclaration(declaration.parent);
|
||||
const type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) :
|
||||
getEffectiveModifierFlags(declaration) & ModifierFlags.Ambient ? getTypeOfPropertyInBaseClass(declaration.symbol) :
|
||||
undefined;
|
||||
return type && addOptionality(type, /*isProperty*/ true, isOptional);
|
||||
// Use control flow analysis of this.xxx assignments in the constructor or static block to determine the type of the property.
|
||||
if (!hasStaticModifier(declaration)) {
|
||||
const constructor = findConstructorDeclaration(declaration.parent);
|
||||
const type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) :
|
||||
getEffectiveModifierFlags(declaration) & ModifierFlags.Ambient ? getTypeOfPropertyInBaseClass(declaration.symbol) :
|
||||
undefined;
|
||||
return type && addOptionality(type, /*isProperty*/ true, isOptional);
|
||||
}
|
||||
else {
|
||||
const staticBlocks = filter(declaration.parent.members, isClassStaticBlockDeclaration);
|
||||
const type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) :
|
||||
getEffectiveModifierFlags(declaration) & ModifierFlags.Ambient ? getTypeOfPropertyInBaseClass(declaration.symbol) :
|
||||
undefined;
|
||||
return type && addOptionality(type, /*isProperty*/ true, isOptional);
|
||||
}
|
||||
}
|
||||
|
||||
if (isJsxAttribute(declaration)) {
|
||||
@@ -8530,6 +8552,27 @@ namespace ts {
|
||||
return getFlowTypeOfReference(reference, autoType, undefinedType);
|
||||
}
|
||||
|
||||
function getFlowTypeInStaticBlocks(symbol: Symbol, staticBlocks: readonly ClassStaticBlockDeclaration[]) {
|
||||
const accessName = startsWith(symbol.escapedName as string, "__#")
|
||||
? factory.createPrivateIdentifier((symbol.escapedName as string).split("@")[1])
|
||||
: unescapeLeadingUnderscores(symbol.escapedName);
|
||||
for (const staticBlock of staticBlocks) {
|
||||
const reference = factory.createPropertyAccessExpression(factory.createThis(), accessName);
|
||||
setParent(reference.expression, reference);
|
||||
setParent(reference, staticBlock);
|
||||
reference.flowNode = staticBlock.returnFlowNode;
|
||||
const flowType = getFlowTypeOfProperty(reference, symbol);
|
||||
if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) {
|
||||
error(symbol.valueDeclaration, Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
|
||||
}
|
||||
// We don't infer a type if assignments are only null or undefined.
|
||||
if (everyType(flowType, isNullableType)) {
|
||||
continue;
|
||||
}
|
||||
return convertAutoToAny(flowType);
|
||||
}
|
||||
}
|
||||
|
||||
function getFlowTypeInConstructor(symbol: Symbol, constructor: ConstructorDeclaration) {
|
||||
const accessName = startsWith(symbol.escapedName as string, "__#")
|
||||
? factory.createPrivateIdentifier((symbol.escapedName as string).split("@")[1])
|
||||
@@ -10131,7 +10174,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isStaticPrivateIdentifierProperty(s: Symbol): boolean {
|
||||
return !!s.valueDeclaration && isPrivateIdentifierClassElementDeclaration(s.valueDeclaration) && hasSyntacticModifier(s.valueDeclaration, ModifierFlags.Static);
|
||||
return !!s.valueDeclaration && isPrivateIdentifierClassElementDeclaration(s.valueDeclaration) && isStatic(s.valueDeclaration);
|
||||
}
|
||||
|
||||
function resolveDeclaredMembers(type: InterfaceType): InterfaceTypeWithDeclaredMembers {
|
||||
@@ -15617,7 +15660,7 @@ namespace ts {
|
||||
const container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
const parent = container && container.parent;
|
||||
if (parent && (isClassLike(parent) || parent.kind === SyntaxKind.InterfaceDeclaration)) {
|
||||
if (!hasSyntacticModifier(container, ModifierFlags.Static) &&
|
||||
if (!isStatic(container) &&
|
||||
(!isConstructorDeclaration(container) || isNodeDescendantOf(node, container.body))) {
|
||||
return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent as ClassLikeDeclaration | InterfaceDeclaration)).thisType!;
|
||||
}
|
||||
@@ -24298,7 +24341,7 @@ namespace ts {
|
||||
let container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
while (container.kind !== SyntaxKind.SourceFile) {
|
||||
if (container.parent === declaration) {
|
||||
if (container.kind === SyntaxKind.PropertyDeclaration && hasSyntacticModifier(container, ModifierFlags.Static)) {
|
||||
if (container.kind === SyntaxKind.PropertyDeclaration && isStatic(container)) {
|
||||
getNodeLinks(declaration).flags |= NodeCheckFlags.ClassWithConstructorReference;
|
||||
getNodeLinks(node).flags |= NodeCheckFlags.ConstructorReferenceInClass;
|
||||
}
|
||||
@@ -24561,6 +24604,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkThisInStaticClassFieldInitializerInDecoratedClass(thisExpression: Node, container: Node) {
|
||||
if (isPropertyDeclaration(container) && hasStaticModifier(container) &&
|
||||
container.initializer && textRangeContainsPositionInclusive(container.initializer, thisExpression.pos) && length(container.parent.decorators)) {
|
||||
error(thisExpression, Diagnostics.Cannot_use_this_in_a_static_property_initializer_of_a_decorated_class);
|
||||
}
|
||||
}
|
||||
|
||||
function checkThisExpression(node: Node): Type {
|
||||
const isNodeInTypeQuery = isInTypeQuery(node);
|
||||
// Stop at the first arrow function so that we can
|
||||
@@ -24578,6 +24628,7 @@ namespace ts {
|
||||
capturedByArrowFunction = true;
|
||||
}
|
||||
|
||||
checkThisInStaticClassFieldInitializerInDecoratedClass(node, container);
|
||||
switch (container.kind) {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
error(node, Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body);
|
||||
@@ -24593,16 +24644,6 @@ 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.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
if (hasSyntacticModifier(container, ModifierFlags.Static) && !(compilerOptions.target === ScriptTarget.ESNext && useDefineForClassFields)) {
|
||||
error(node, Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer);
|
||||
// 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;
|
||||
@@ -24661,8 +24702,7 @@ namespace ts {
|
||||
|
||||
if (isClassLike(container.parent)) {
|
||||
const symbol = getSymbolOfNode(container.parent);
|
||||
const isStatic = hasSyntacticModifier(container, ModifierFlags.Static) || isClassStaticBlockDeclaration(container);
|
||||
const type = isStatic ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol) as InterfaceType).thisType!;
|
||||
const type = isStatic(container) ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol) as InterfaceType).thisType!;
|
||||
return getFlowTypeOfReference(node, type);
|
||||
}
|
||||
|
||||
@@ -24692,7 +24732,7 @@ namespace ts {
|
||||
}
|
||||
if (isClassLike(container.parent)) {
|
||||
const symbol = getSymbolOfNode(container.parent);
|
||||
return hasSyntacticModifier(container, ModifierFlags.Static) ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol) as InterfaceType).thisType!;
|
||||
return isStatic(container) ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol) as InterfaceType).thisType!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24813,7 +24853,7 @@ namespace ts {
|
||||
checkThisBeforeSuper(node, container, Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
|
||||
}
|
||||
|
||||
if (hasSyntacticModifier(container, ModifierFlags.Static) || isCallExpression) {
|
||||
if (isStatic(container) || isCallExpression) {
|
||||
nodeCheckFlag = NodeCheckFlags.SuperStatic;
|
||||
}
|
||||
else {
|
||||
@@ -24949,11 +24989,13 @@ namespace ts {
|
||||
|
||||
// topmost container must be something that is directly nested in the class declaration\object literal expression
|
||||
if (isClassLike(container.parent) || container.parent.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
if (hasSyntacticModifier(container, ModifierFlags.Static)) {
|
||||
if (isStatic(container)) {
|
||||
return container.kind === SyntaxKind.MethodDeclaration ||
|
||||
container.kind === SyntaxKind.MethodSignature ||
|
||||
container.kind === SyntaxKind.GetAccessor ||
|
||||
container.kind === SyntaxKind.SetAccessor;
|
||||
container.kind === SyntaxKind.SetAccessor ||
|
||||
container.kind === SyntaxKind.PropertyDeclaration ||
|
||||
container.kind === SyntaxKind.ClassStaticBlockDeclaration;
|
||||
}
|
||||
else {
|
||||
return container.kind === SyntaxKind.MethodDeclaration ||
|
||||
@@ -25092,7 +25134,7 @@ namespace ts {
|
||||
case SyntaxKind.BindingElement:
|
||||
return getContextualTypeForBindingElement(declaration);
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
if (hasSyntacticModifier(declaration, ModifierFlags.Static)) {
|
||||
if (isStatic(declaration)) {
|
||||
return getContextualTypeForStaticPropertyDeclaration(declaration);
|
||||
}
|
||||
// By default, do nothing and return undefined - only the above cases have context implied by a parent
|
||||
@@ -27595,10 +27637,12 @@ namespace ts {
|
||||
let assumeUninitialized = false;
|
||||
if (strictNullChecks && strictPropertyInitialization && isAccessExpression(node) && node.expression.kind === SyntaxKind.ThisKeyword) {
|
||||
const declaration = prop && prop.valueDeclaration;
|
||||
if (declaration && isInstancePropertyWithoutInitializer(declaration)) {
|
||||
const flowContainer = getControlFlowContainer(node);
|
||||
if (flowContainer.kind === SyntaxKind.Constructor && flowContainer.parent === declaration.parent && !(declaration.flags & NodeFlags.Ambient)) {
|
||||
assumeUninitialized = true;
|
||||
if (declaration && isPropertyWithoutInitializer(declaration)) {
|
||||
if (!isStatic(declaration)) {
|
||||
const flowContainer = getControlFlowContainer(node);
|
||||
if (flowContainer.kind === SyntaxKind.Constructor && flowContainer.parent === declaration.parent && !(declaration.flags & NodeFlags.Ambient)) {
|
||||
assumeUninitialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27764,7 +27808,7 @@ namespace ts {
|
||||
|
||||
function typeHasStaticProperty(propName: __String, containingType: Type): boolean {
|
||||
const prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName);
|
||||
return prop !== undefined && !!prop.valueDeclaration && hasSyntacticModifier(prop.valueDeclaration, ModifierFlags.Static);
|
||||
return prop !== undefined && !!prop.valueDeclaration && isStatic(prop.valueDeclaration);
|
||||
}
|
||||
|
||||
function getSuggestedLibForNonExistentName(name: __String | Identifier) {
|
||||
@@ -33328,16 +33372,16 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
const isStatic = hasSyntacticModifier(member, ModifierFlags.Static);
|
||||
const isStaticMember = isStatic(member);
|
||||
const name = member.name;
|
||||
if (!name) {
|
||||
continue;
|
||||
}
|
||||
const isPrivate = isPrivateIdentifier(name);
|
||||
const privateStaticFlags = isPrivate && isStatic ? DeclarationMeaning.PrivateStatic : 0;
|
||||
const privateStaticFlags = isPrivate && isStaticMember ? DeclarationMeaning.PrivateStatic : 0;
|
||||
const names =
|
||||
isPrivate ? privateIdentifiers :
|
||||
isStatic ? staticNames :
|
||||
isStaticMember ? staticNames :
|
||||
instanceNames;
|
||||
|
||||
const memberName = name && getPropertyNameForPropertyNameNode(name);
|
||||
@@ -33407,8 +33451,8 @@ namespace ts {
|
||||
function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) {
|
||||
for (const member of node.members) {
|
||||
const memberNameNode = member.name;
|
||||
const isStatic = hasSyntacticModifier(member, ModifierFlags.Static);
|
||||
if (isStatic && memberNameNode) {
|
||||
const isStaticMember = isStatic(member);
|
||||
if (isStaticMember && memberNameNode) {
|
||||
const memberName = getPropertyNameForPropertyNameNode(memberNameNode);
|
||||
switch (memberName) {
|
||||
case "name":
|
||||
@@ -33590,7 +33634,7 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
return n.kind === SyntaxKind.PropertyDeclaration &&
|
||||
!hasSyntacticModifier(n, ModifierFlags.Static) &&
|
||||
!isStatic(n) &&
|
||||
!!(n as PropertyDeclaration).initializer;
|
||||
}
|
||||
|
||||
@@ -34075,13 +34119,13 @@ namespace ts {
|
||||
)) {
|
||||
const reportError =
|
||||
(node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) &&
|
||||
hasSyntacticModifier(node, ModifierFlags.Static) !== hasSyntacticModifier(subsequentNode, ModifierFlags.Static);
|
||||
isStatic(node) !== isStatic(subsequentNode);
|
||||
// we can get here in two cases
|
||||
// 1. mixed static and instance class members
|
||||
// 2. something with the same name was defined before the set of overloads that prevents them from merging
|
||||
// here we'll report error only for the first case since for second we should already report error in binder
|
||||
if (reportError) {
|
||||
const diagnostic = hasSyntacticModifier(node, ModifierFlags.Static) ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static;
|
||||
const diagnostic = isStatic(node) ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static;
|
||||
error(errorNode, diagnostic);
|
||||
}
|
||||
return;
|
||||
@@ -37053,13 +37097,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkIndexConstraints(type: Type, isStatic?: boolean) {
|
||||
function checkIndexConstraints(type: Type, isStaticIndex?: boolean) {
|
||||
const indexInfos = getIndexInfosOfType(type);
|
||||
if (indexInfos.length === 0) {
|
||||
return;
|
||||
}
|
||||
for (const prop of getPropertiesOfObjectType(type)) {
|
||||
if (!(isStatic && prop.flags & SymbolFlags.Prototype)) {
|
||||
if (!(isStaticIndex && prop.flags & SymbolFlags.Prototype)) {
|
||||
checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, TypeFlags.StringOrNumberLiteralOrUnique, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop));
|
||||
}
|
||||
}
|
||||
@@ -37068,7 +37112,7 @@ namespace ts {
|
||||
for (const member of typeDeclaration.members) {
|
||||
// Only process instance properties with computed names here. Static properties cannot be in conflict with indexers,
|
||||
// and properties with literal names were already checked.
|
||||
if (!hasSyntacticModifier(member, ModifierFlags.Static) && !hasBindableName(member)) {
|
||||
if (!isStatic(member) && !hasBindableName(member)) {
|
||||
const symbol = getSymbolOfNode(member);
|
||||
checkIndexConstraintForProperty(type, symbol, getTypeOfExpression((member as DynamicNamedDeclaration).name.expression), getNonMissingTypeOfSymbol(symbol));
|
||||
}
|
||||
@@ -37412,7 +37456,7 @@ namespace ts {
|
||||
|
||||
if (produceDiagnostics) {
|
||||
checkIndexConstraints(type);
|
||||
checkIndexConstraints(staticType, /*isStatic*/ true);
|
||||
checkIndexConstraints(staticType, /*isStaticIndex*/ true);
|
||||
checkTypeForDuplicateIndexSignatures(node);
|
||||
checkPropertyInitialization(node);
|
||||
}
|
||||
@@ -37442,7 +37486,7 @@ namespace ts {
|
||||
|
||||
function checkClassMember(member: ClassElement | ParameterPropertyDeclaration, memberIsParameterProperty?: boolean) {
|
||||
const hasOverride = hasOverrideModifier(member);
|
||||
const hasStatic = hasStaticModifier(member);
|
||||
const hasStatic = isStatic(member);
|
||||
if (baseWithThis && (hasOverride || compilerOptions.noImplicitOverride)) {
|
||||
const declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member);
|
||||
if (!declaredProp) {
|
||||
@@ -37489,7 +37533,7 @@ namespace ts {
|
||||
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
||||
let issuedMemberError = false;
|
||||
for (const member of node.members) {
|
||||
if (hasStaticModifier(member)) {
|
||||
if (isStatic(member)) {
|
||||
continue;
|
||||
}
|
||||
const declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member);
|
||||
@@ -37745,7 +37789,7 @@ namespace ts {
|
||||
if (getEffectiveModifierFlags(member) & ModifierFlags.Ambient) {
|
||||
continue;
|
||||
}
|
||||
if (isInstancePropertyWithoutInitializer(member)) {
|
||||
if (!isStatic(member) && isPropertyWithoutInitializer(member)) {
|
||||
const propName = (member as PropertyDeclaration).name;
|
||||
if (isIdentifier(propName) || isPrivateIdentifier(propName)) {
|
||||
const type = getTypeOfSymbol(getSymbolOfNode(member));
|
||||
@@ -37759,13 +37803,30 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isInstancePropertyWithoutInitializer(node: Node) {
|
||||
function isPropertyWithoutInitializer(node: Node) {
|
||||
return node.kind === SyntaxKind.PropertyDeclaration &&
|
||||
!hasSyntacticModifier(node, ModifierFlags.Static | ModifierFlags.Abstract) &&
|
||||
!hasAbstractModifier(node) &&
|
||||
!(node as PropertyDeclaration).exclamationToken &&
|
||||
!(node as PropertyDeclaration).initializer;
|
||||
}
|
||||
|
||||
function isPropertyInitializedInStaticBlocks(propName: Identifier | PrivateIdentifier, propType: Type, staticBlocks: readonly ClassStaticBlockDeclaration[], startPos: number, endPos: number) {
|
||||
for (const staticBlock of staticBlocks) {
|
||||
// static block must be within the provided range as they are evaluated in document order (unlike constructors)
|
||||
if (staticBlock.pos >= startPos && staticBlock.pos <= endPos) {
|
||||
const reference = factory.createPropertyAccessExpression(factory.createThis(), propName);
|
||||
setParent(reference.expression, reference);
|
||||
setParent(reference, staticBlock);
|
||||
reference.flowNode = staticBlock.returnFlowNode;
|
||||
const flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
|
||||
if (!(getFalsyFlags(flowType) & TypeFlags.Undefined)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isPropertyInitializedInConstructor(propName: Identifier | PrivateIdentifier, propType: Type, constructor: ConstructorDeclaration) {
|
||||
const reference = factory.createPropertyAccessExpression(factory.createThis(), propName);
|
||||
setParent(reference.expression, reference);
|
||||
@@ -39177,7 +39238,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const symbols = createSymbolTable();
|
||||
let isStatic = false;
|
||||
let isStaticSymbol = false;
|
||||
|
||||
populateSymbols();
|
||||
|
||||
@@ -39215,7 +39276,7 @@ namespace ts {
|
||||
// add the type parameters into the symbol table
|
||||
// (type parameters of classDeclaration/classExpression and interface are in member property of the symbol.
|
||||
// Note: that the memberFlags come from previous iteration.
|
||||
if (!isStatic) {
|
||||
if (!isStaticSymbol) {
|
||||
copySymbols(getMembersOfSymbol(getSymbolOfNode(location as ClassDeclaration | InterfaceDeclaration)), meaning & SymbolFlags.Type);
|
||||
}
|
||||
break;
|
||||
@@ -39231,7 +39292,7 @@ namespace ts {
|
||||
copySymbol(argumentsSymbol, meaning);
|
||||
}
|
||||
|
||||
isStatic = hasSyntacticModifier(location, ModifierFlags.Static);
|
||||
isStaticSymbol = isStatic(location);
|
||||
location = location.parent;
|
||||
}
|
||||
|
||||
@@ -39830,7 +39891,7 @@ namespace ts {
|
||||
*/
|
||||
function getParentTypeOfClassElement(node: ClassElement) {
|
||||
const classSymbol = getSymbolOfNode(node.parent)!;
|
||||
return hasSyntacticModifier(node, ModifierFlags.Static)
|
||||
return isStatic(node)
|
||||
? getTypeOfSymbol(classSymbol)
|
||||
: getDeclaredTypeOfSymbol(classSymbol);
|
||||
}
|
||||
@@ -41874,8 +41935,8 @@ namespace ts {
|
||||
break;
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
if (!hasSyntacticModifier(parent, ModifierFlags.Static) ||
|
||||
!hasEffectiveModifier(parent, ModifierFlags.Readonly)) {
|
||||
if (!isStatic(parent) ||
|
||||
!hasEffectiveReadonlyModifier(parent)) {
|
||||
return grammarErrorOnNode((parent as PropertyDeclaration).name, Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly);
|
||||
}
|
||||
break;
|
||||
@@ -42292,7 +42353,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (isPropertyDeclaration(node) && node.exclamationToken && (!isClassLike(node.parent) || !node.type || node.initializer ||
|
||||
node.flags & NodeFlags.Ambient || hasSyntacticModifier(node, ModifierFlags.Static | ModifierFlags.Abstract))) {
|
||||
node.flags & NodeFlags.Ambient || isStatic(node) || hasAbstractModifier(node))) {
|
||||
const message = node.initializer
|
||||
? Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
|
||||
: !node.type
|
||||
|
||||
@@ -3344,6 +3344,14 @@
|
||||
"category": "Error",
|
||||
"code": 2815
|
||||
},
|
||||
"Cannot use 'this' in a static property initializer of a decorated class.": {
|
||||
"category": "Error",
|
||||
"code": 2816
|
||||
},
|
||||
"Property '{0}' has no initializer and is not definitely assigned in a class static block.": {
|
||||
"category": "Error",
|
||||
"code": 2817
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -496,8 +496,11 @@ namespace ts {
|
||||
createArraySliceCall,
|
||||
createArrayConcatCall,
|
||||
createObjectDefinePropertyCall,
|
||||
createReflectGetCall,
|
||||
createReflectSetCall,
|
||||
createPropertyDescriptor,
|
||||
createCallBinding,
|
||||
createAssignmentTargetWrapper,
|
||||
|
||||
// Utilities
|
||||
inlineExpressions,
|
||||
@@ -998,8 +1001,10 @@ namespace ts {
|
||||
case SyntaxKind.UndefinedKeyword: // `undefined` is an Identifier in the expression case.
|
||||
transformFlags = TransformFlags.ContainsTypeScript;
|
||||
break;
|
||||
case SyntaxKind.StaticKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
transformFlags = TransformFlags.ContainsES2015 | TransformFlags.ContainsLexicalSuper;
|
||||
break;
|
||||
case SyntaxKind.StaticKeyword:
|
||||
transformFlags = TransformFlags.ContainsES2015;
|
||||
break;
|
||||
case SyntaxKind.ThisKeyword:
|
||||
@@ -2624,7 +2629,7 @@ namespace ts {
|
||||
propagateChildFlags(node.equalsGreaterThanToken) |
|
||||
TransformFlags.ContainsES2015;
|
||||
if (modifiersToFlags(node.modifiers) & ModifierFlags.Async) {
|
||||
node.transformFlags |= TransformFlags.ContainsES2017;
|
||||
node.transformFlags |= TransformFlags.ContainsES2017 | TransformFlags.ContainsLexicalThis;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
@@ -5435,6 +5440,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createMethodCall(object: Expression, methodName: string | Identifier, argumentsList: readonly Expression[]) {
|
||||
// Preserve the optionality of `object`.
|
||||
if (isCallChain(object)) {
|
||||
return createCallChain(
|
||||
createPropertyAccessChain(object, /*questionDotToken*/ undefined, methodName),
|
||||
/*questionDotToken*/ undefined,
|
||||
/*typeArguments*/ undefined,
|
||||
argumentsList
|
||||
);
|
||||
}
|
||||
return createCallExpression(
|
||||
createPropertyAccessExpression(object, methodName),
|
||||
/*typeArguments*/ undefined,
|
||||
@@ -5470,6 +5484,14 @@ namespace ts {
|
||||
return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]);
|
||||
}
|
||||
|
||||
function createReflectGetCall(target: Expression, propertyKey: Expression, receiver?: Expression): CallExpression {
|
||||
return createGlobalMethodCall("Reflect", "get", receiver ? [target, propertyKey, receiver] : [target, propertyKey]);
|
||||
}
|
||||
|
||||
function createReflectSetCall(target: Expression, propertyKey: Expression, value: Expression, receiver?: Expression): CallExpression {
|
||||
return createGlobalMethodCall("Reflect", "set", receiver ? [target, propertyKey, value, receiver] : [target, propertyKey, value]);
|
||||
}
|
||||
|
||||
function tryAddPropertyAssignment(properties: Push<PropertyAssignment>, propertyName: string, expression: Expression | undefined) {
|
||||
if (expression) {
|
||||
properties.push(createPropertyAssignment(propertyName, expression));
|
||||
@@ -5645,6 +5667,34 @@ namespace ts {
|
||||
return { target, thisArg };
|
||||
}
|
||||
|
||||
function createAssignmentTargetWrapper(paramName: Identifier, expression: Expression): LeftHandSideExpression {
|
||||
return createPropertyAccessExpression(
|
||||
// Explicit parens required because of v8 regression (https://bugs.chromium.org/p/v8/issues/detail?id=9560)
|
||||
createParenthesizedExpression(
|
||||
createObjectLiteralExpression([
|
||||
createSetAccessorDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
"value",
|
||||
[createParameterDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
paramName,
|
||||
/*questionToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
/*initializer*/ undefined
|
||||
)],
|
||||
createBlock([
|
||||
createExpressionStatement(expression)
|
||||
])
|
||||
)
|
||||
])
|
||||
),
|
||||
"value"
|
||||
);
|
||||
}
|
||||
|
||||
function inlineExpressions(expressions: readonly Expression[]) {
|
||||
// Avoid deeply nested comma expressions as traversing them during emit can result in "Maximum call
|
||||
// stack size exceeded" errors.
|
||||
|
||||
@@ -303,6 +303,67 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand the read and increment/decrement operations a pre- or post-increment or pre- or post-decrement expression.
|
||||
*
|
||||
* ```ts
|
||||
* // input
|
||||
* <expression>++
|
||||
* // output (if result is not discarded)
|
||||
* var <temp>;
|
||||
* (<temp> = <expression>, <resultVariable> = <temp>++, <temp>)
|
||||
* // output (if result is discarded)
|
||||
* var <temp>;
|
||||
* (<temp> = <expression>, <temp>++, <temp>)
|
||||
*
|
||||
* // input
|
||||
* ++<expression>
|
||||
* // output (if result is not discarded)
|
||||
* var <temp>;
|
||||
* (<temp> = <expression>, <resultVariable> = ++<temp>)
|
||||
* // output (if result is discarded)
|
||||
* var <temp>;
|
||||
* (<temp> = <expression>, ++<temp>)
|
||||
* ```
|
||||
*
|
||||
* It is up to the caller to supply a temporary variable for `<resultVariable>` if one is needed.
|
||||
* The temporary variable `<temp>` is injected so that `++` and `--` work uniformly with `number` and `bigint`.
|
||||
* The result of the expression is always the final result of incrementing or decrementing the expression, so that it can be used for storage.
|
||||
*
|
||||
* @param factory {@link NodeFactory} used to create the expanded representation.
|
||||
* @param node The original prefix or postfix unary node.
|
||||
* @param expression The expression to use as the value to increment or decrement
|
||||
* @param resultVariable A temporary variable in which to store the result. Pass `undefined` if the result is discarded, or if the value of `<temp>` is the expected result.
|
||||
*/
|
||||
export function expandPreOrPostfixIncrementOrDecrementExpression(factory: NodeFactory, node: PrefixUnaryExpression | PostfixUnaryExpression, expression: Expression, recordTempVariable: (node: Identifier) => void, resultVariable: Identifier | undefined) {
|
||||
const operator = node.operator;
|
||||
Debug.assert(operator === SyntaxKind.PlusPlusToken || operator === SyntaxKind.MinusMinusToken, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression");
|
||||
|
||||
const temp = factory.createTempVariable(recordTempVariable);
|
||||
expression = factory.createAssignment(temp, expression);
|
||||
setTextRange(expression, node.operand);
|
||||
|
||||
let operation: Expression = isPrefixUnaryExpression(node) ?
|
||||
factory.createPrefixUnaryExpression(operator, temp) :
|
||||
factory.createPostfixUnaryExpression(temp, operator);
|
||||
setTextRange(operation, node);
|
||||
|
||||
if (resultVariable) {
|
||||
operation = factory.createAssignment(resultVariable, operation);
|
||||
setTextRange(operation, node);
|
||||
}
|
||||
|
||||
expression = factory.createComma(expression, operation);
|
||||
setTextRange(expression, node);
|
||||
|
||||
if (isPostfixUnaryExpression(node)) {
|
||||
expression = factory.createComma(expression, temp);
|
||||
setTextRange(expression, node);
|
||||
}
|
||||
|
||||
return expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether an identifier should only be referred to by its internal name.
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -75,7 +75,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Static)) {
|
||||
if (isStatic(node)) {
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
@@ -106,7 +106,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Static)) {
|
||||
if (isStatic(node)) {
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
@@ -173,7 +173,7 @@ namespace ts {
|
||||
else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.PropertySignature ||
|
||||
(node.kind === SyntaxKind.Parameter && hasSyntacticModifier(node.parent, ModifierFlags.Private))) {
|
||||
// TODO(jfreeman): Deal with computed properties in error reporting.
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Static)) {
|
||||
if (isStatic(node)) {
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
@@ -210,7 +210,7 @@ namespace ts {
|
||||
if (node.kind === SyntaxKind.SetAccessor) {
|
||||
// Getters can infer the return type from the returned expression, but setters cannot, so the
|
||||
// "_from_external_module_1_but_cannot_be_named" case cannot occur.
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Static)) {
|
||||
if (isStatic(node)) {
|
||||
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
|
||||
Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
|
||||
Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1;
|
||||
@@ -222,7 +222,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Static)) {
|
||||
if (isStatic(node)) {
|
||||
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
@@ -270,7 +270,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Static)) {
|
||||
if (isStatic(node)) {
|
||||
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
|
||||
@@ -349,7 +349,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (hasSyntacticModifier(node.parent, ModifierFlags.Static)) {
|
||||
if (isStatic(node.parent)) {
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
@@ -417,7 +417,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (hasSyntacticModifier(node.parent, ModifierFlags.Static)) {
|
||||
if (isStatic(node.parent)) {
|
||||
diagnosticMessage = Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
|
||||
}
|
||||
else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
|
||||
@@ -169,6 +169,8 @@ namespace ts {
|
||||
ForStatement = 1 << 11, // Enclosing block-scoped container is a ForStatement
|
||||
ForInOrForOfStatement = 1 << 12, // Enclosing block-scoped container is a ForInStatement or ForOfStatement
|
||||
ConstructorWithCapturedSuper = 1 << 13, // Enclosed in a constructor that captures 'this' for use with 'super'
|
||||
StaticInitializer = 1 << 14, // Enclosed in a static initializer
|
||||
|
||||
// NOTE: do not add more ancestor flags without also updating AncestorFactsMask below.
|
||||
// NOTE: when adding a new ancestor flag, be sure to update the subtree flags below.
|
||||
|
||||
@@ -176,7 +178,7 @@ namespace ts {
|
||||
// Ancestor masks
|
||||
//
|
||||
|
||||
AncestorFactsMask = (ConstructorWithCapturedSuper << 1) - 1,
|
||||
AncestorFactsMask = (StaticInitializer << 1) - 1,
|
||||
|
||||
// We are always in *some* kind of block scope, but only specific block-scope containers are
|
||||
// top-level or Blocks.
|
||||
@@ -189,7 +191,7 @@ namespace ts {
|
||||
|
||||
// Functions, methods, and accessors are both new lexical scopes and new block scopes.
|
||||
FunctionIncludes = Function | TopLevel,
|
||||
FunctionExcludes = BlockScopeExcludes & ~TopLevel | ArrowFunction | AsyncFunctionBody | CapturesThis | NonStaticClassElement | ConstructorWithCapturedSuper | IterationContainer,
|
||||
FunctionExcludes = BlockScopeExcludes & ~TopLevel | ArrowFunction | AsyncFunctionBody | CapturesThis | NonStaticClassElement | ConstructorWithCapturedSuper | IterationContainer | StaticInitializer,
|
||||
|
||||
AsyncFunctionBodyIncludes = FunctionIncludes | AsyncFunctionBody,
|
||||
AsyncFunctionBodyExcludes = FunctionExcludes & ~NonStaticClassElement,
|
||||
@@ -225,12 +227,15 @@ namespace ts {
|
||||
IterationStatementBlockIncludes = IterationStatementBlock,
|
||||
IterationStatementBlockExcludes = BlockScopeExcludes,
|
||||
|
||||
StaticInitializerIncludes = FunctionIncludes | StaticInitializer,
|
||||
StaticInitializerExcludes = FunctionExcludes,
|
||||
|
||||
//
|
||||
// Subtree facts
|
||||
//
|
||||
|
||||
NewTarget = 1 << 14, // Contains a 'new.target' meta-property
|
||||
CapturedLexicalThis = 1 << 15, // Contains a lexical `this` reference captured by an arrow function.
|
||||
NewTarget = 1 << 15, // Contains a 'new.target' meta-property
|
||||
CapturedLexicalThis = 1 << 16, // Contains a lexical `this` reference captured by an arrow function.
|
||||
|
||||
//
|
||||
// Subtree masks
|
||||
@@ -377,6 +382,23 @@ namespace ts {
|
||||
return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ true) : node;
|
||||
}
|
||||
|
||||
function classWrapperStatementVisitor(node: Node): VisitResult<Node> {
|
||||
if (shouldVisitNode(node)) {
|
||||
const original = getOriginalNode(node);
|
||||
if (isPropertyDeclaration(original) && hasStaticModifier(original)) {
|
||||
const ancestorFacts = enterSubtree(
|
||||
HierarchyFacts.StaticInitializerExcludes,
|
||||
HierarchyFacts.StaticInitializerIncludes
|
||||
);
|
||||
const result = visitorWorker(node, /*expressionResultIsUnused*/ false);
|
||||
exitSubtree(ancestorFacts, HierarchyFacts.FunctionSubtreeExcludes, HierarchyFacts.None);
|
||||
return result;
|
||||
}
|
||||
return visitorWorker(node, /*expressionResultIsUnused*/ false);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function callExpressionVisitor(node: Node): VisitResult<Node> {
|
||||
if (node.kind === SyntaxKind.SuperKeyword) {
|
||||
return visitSuperKeyword(/*isExpressionOfCall*/ true);
|
||||
@@ -602,7 +624,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitThisKeyword(node: Node): Node {
|
||||
if (hierarchyFacts & HierarchyFacts.ArrowFunction) {
|
||||
if (hierarchyFacts & HierarchyFacts.ArrowFunction && !(hierarchyFacts & HierarchyFacts.StaticInitializer)) {
|
||||
hierarchyFacts |= HierarchyFacts.CapturedLexicalThis;
|
||||
}
|
||||
if (convertedLoopState) {
|
||||
@@ -1750,7 +1772,7 @@ namespace ts {
|
||||
* @param node An ArrowFunction node.
|
||||
*/
|
||||
function visitArrowFunction(node: ArrowFunction) {
|
||||
if (node.transformFlags & TransformFlags.ContainsLexicalThis) {
|
||||
if (node.transformFlags & TransformFlags.ContainsLexicalThis && !(hierarchyFacts & HierarchyFacts.StaticInitializer)) {
|
||||
hierarchyFacts |= HierarchyFacts.CapturedLexicalThis;
|
||||
}
|
||||
|
||||
@@ -1770,10 +1792,6 @@ namespace ts {
|
||||
setOriginalNode(func, node);
|
||||
setEmitFlags(func, EmitFlags.CapturesThis);
|
||||
|
||||
if (hierarchyFacts & HierarchyFacts.CapturedLexicalThis) {
|
||||
enableSubstitutionsForCapturedThis();
|
||||
}
|
||||
|
||||
// If an arrow function contains
|
||||
exitSubtree(ancestorFacts, HierarchyFacts.ArrowFunctionSubtreeExcludes, HierarchyFacts.None);
|
||||
|
||||
@@ -1853,7 +1871,7 @@ namespace ts {
|
||||
function transformFunctionLikeToExpression(node: FunctionLikeDeclaration, location: TextRange | undefined, name: Identifier | undefined, container: Node | undefined): FunctionExpression {
|
||||
const savedConvertedLoopState = convertedLoopState;
|
||||
convertedLoopState = undefined;
|
||||
const ancestorFacts = container && isClassLike(container) && !hasSyntacticModifier(node, ModifierFlags.Static)
|
||||
const ancestorFacts = container && isClassLike(container) && !isStatic(node)
|
||||
? enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes | HierarchyFacts.NonStaticClassElement)
|
||||
: enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes);
|
||||
const parameters = visitParameterList(node.parameters, visitor, context);
|
||||
@@ -3688,7 +3706,7 @@ namespace ts {
|
||||
// visit the class body statements outside of any converted loop body.
|
||||
const savedConvertedLoopState = convertedLoopState;
|
||||
convertedLoopState = undefined;
|
||||
const bodyStatements = visitNodes(body.statements, visitor, isStatement);
|
||||
const bodyStatements = visitNodes(body.statements, classWrapperStatementVisitor, isStatement);
|
||||
convertedLoopState = savedConvertedLoopState;
|
||||
|
||||
const classStatements = filter(bodyStatements, isVariableStatementWithInitializer);
|
||||
@@ -3715,7 +3733,10 @@ namespace ts {
|
||||
// return C;
|
||||
// }())
|
||||
//
|
||||
const aliasAssignment = tryCast(initializer, isAssignmentExpression);
|
||||
let aliasAssignment = tryCast(initializer, isAssignmentExpression);
|
||||
if (!aliasAssignment && isBinaryExpression(initializer) && initializer.operatorToken.kind === SyntaxKind.CommaToken) {
|
||||
aliasAssignment = tryCast(initializer.left, isAssignmentExpression);
|
||||
}
|
||||
|
||||
// The underlying call (3) is another IIFE that may contain a '_super' argument.
|
||||
const call = cast(aliasAssignment ? skipOuterExpressions(aliasAssignment.right) : initializer, isCallExpression);
|
||||
@@ -4358,7 +4379,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getClassMemberPrefix(node: ClassExpression | ClassDeclaration, member: ClassElement) {
|
||||
return hasSyntacticModifier(member, ModifierFlags.Static)
|
||||
return isStatic(member)
|
||||
? factory.getInternalName(node)
|
||||
: factory.createPropertyAccessExpression(factory.getInternalName(node), "prototype");
|
||||
}
|
||||
|
||||
@@ -945,7 +945,7 @@ namespace ts {
|
||||
* @param member The class member.
|
||||
*/
|
||||
function isStaticDecoratedClassElement(member: ClassElement, parent: ClassLikeDeclaration) {
|
||||
return isDecoratedClassElement(member, /*isStatic*/ true, parent);
|
||||
return isDecoratedClassElement(member, /*isStaticElement*/ true, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -955,7 +955,7 @@ namespace ts {
|
||||
* @param member The class member.
|
||||
*/
|
||||
function isInstanceDecoratedClassElement(member: ClassElement, parent: ClassLikeDeclaration) {
|
||||
return isDecoratedClassElement(member, /*isStatic*/ false, parent);
|
||||
return isDecoratedClassElement(member, /*isStaticElement*/ false, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -964,9 +964,9 @@ namespace ts {
|
||||
*
|
||||
* @param member The class member.
|
||||
*/
|
||||
function isDecoratedClassElement(member: ClassElement, isStatic: boolean, parent: ClassLikeDeclaration) {
|
||||
function isDecoratedClassElement(member: ClassElement, isStaticElement: boolean, parent: ClassLikeDeclaration) {
|
||||
return nodeOrChildIsDecorated(member, parent)
|
||||
&& isStatic === hasSyntacticModifier(member, ModifierFlags.Static);
|
||||
&& isStaticElement === isStatic(member);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3158,7 +3158,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getClassMemberPrefix(node: ClassExpression | ClassDeclaration, member: ClassElement) {
|
||||
return hasSyntacticModifier(member, ModifierFlags.Static)
|
||||
return isStatic(member)
|
||||
? factory.getDeclarationName(node)
|
||||
: getClassPrototype(node);
|
||||
}
|
||||
|
||||
@@ -385,6 +385,6 @@ namespace ts {
|
||||
* @param member The class element node.
|
||||
*/
|
||||
export function isNonStaticMethodOrAccessorWithPrivateName(member: ClassElement): member is PrivateIdentifierMethodDeclaration | PrivateIdentifierAccessorDeclaration {
|
||||
return !hasStaticModifier(member) && isMethodOrAccessor(member) && isPrivateIdentifier(member.name);
|
||||
return !isStatic(member) && isMethodOrAccessor(member) && isPrivateIdentifier(member.name);
|
||||
}
|
||||
}
|
||||
|
||||
+28
-7
@@ -1543,6 +1543,8 @@ namespace ts {
|
||||
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
|
||||
/* @internal */ endFlowNode?: FlowNode;
|
||||
/* @internal */ returnFlowNode?: FlowNode;
|
||||
}
|
||||
|
||||
export interface TypeNode extends Node {
|
||||
@@ -6632,7 +6634,7 @@ namespace ts {
|
||||
ContainsDynamicImport = 1 << 22,
|
||||
ContainsClassFields = 1 << 23,
|
||||
ContainsPossibleTopLevelAwait = 1 << 24,
|
||||
|
||||
ContainsLexicalSuper = 1 << 25,
|
||||
// Please leave this as 1 << 29.
|
||||
// It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
|
||||
// It is a good reminder of how much room we have left
|
||||
@@ -6660,12 +6662,12 @@ namespace ts {
|
||||
PropertyAccessExcludes = OuterExpressionExcludes,
|
||||
NodeExcludes = PropertyAccessExcludes,
|
||||
ArrowFunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait,
|
||||
FunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait,
|
||||
ConstructorExcludes = NodeExcludes | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait,
|
||||
MethodOrAccessorExcludes = NodeExcludes | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,
|
||||
PropertyExcludes = NodeExcludes | ContainsLexicalThis,
|
||||
FunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsLexicalSuper | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait,
|
||||
ConstructorExcludes = NodeExcludes | ContainsLexicalThis | ContainsLexicalSuper | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait,
|
||||
MethodOrAccessorExcludes = NodeExcludes | ContainsLexicalThis | ContainsLexicalSuper | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,
|
||||
PropertyExcludes = NodeExcludes | ContainsLexicalThis | ContainsLexicalSuper,
|
||||
ClassExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsComputedPropertyName,
|
||||
ModuleExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsHoistedDeclarationOrCompletion | ContainsPossibleTopLevelAwait,
|
||||
ModuleExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsLexicalSuper | ContainsBlockScopedBinding | ContainsHoistedDeclarationOrCompletion | ContainsPossibleTopLevelAwait,
|
||||
TypeExcludes = ~ContainsTypeScript,
|
||||
ObjectLiteralExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsComputedPropertyName | ContainsObjectRestOrSpread,
|
||||
ArrayLiteralOrCallOrNewExcludes = NodeExcludes | ContainsRestOrSpread,
|
||||
@@ -6673,10 +6675,11 @@ namespace ts {
|
||||
ParameterExcludes = NodeExcludes,
|
||||
CatchClauseExcludes = NodeExcludes | ContainsObjectRestOrSpread,
|
||||
BindingPatternExcludes = NodeExcludes | ContainsRestOrSpread,
|
||||
ContainsLexicalThisOrSuper = ContainsLexicalThis | ContainsLexicalSuper,
|
||||
|
||||
// Propagating flags
|
||||
// - Bitmasks for flags that should propagate from a child
|
||||
PropertyNamePropagatingFlags = ContainsLexicalThis,
|
||||
PropertyNamePropagatingFlags = ContainsLexicalThis | ContainsLexicalSuper,
|
||||
|
||||
// Masks
|
||||
// - Additional bitmasks
|
||||
@@ -7548,10 +7551,28 @@ namespace ts {
|
||||
/* @internal */ createFunctionCallCall(target: Expression, thisArg: Expression, argumentsList: readonly Expression[]): CallExpression;
|
||||
/* @internal */ createFunctionApplyCall(target: Expression, thisArg: Expression, argumentsExpression: Expression): CallExpression;
|
||||
/* @internal */ createObjectDefinePropertyCall(target: Expression, propertyName: string | Expression, attributes: Expression): CallExpression;
|
||||
/* @internal */ createReflectGetCall(target: Expression, propertyKey: Expression, receiver?: Expression): CallExpression;
|
||||
/* @internal */ createReflectSetCall(target: Expression, propertyKey: Expression, value: Expression, receiver?: Expression): CallExpression;
|
||||
/* @internal */ createPropertyDescriptor(attributes: PropertyDescriptorAttributes, singleLine?: boolean): ObjectLiteralExpression;
|
||||
/* @internal */ createArraySliceCall(array: Expression, start?: number | Expression): CallExpression;
|
||||
/* @internal */ createArrayConcatCall(array: Expression, values: readonly Expression[]): CallExpression;
|
||||
/* @internal */ createCallBinding(expression: Expression, recordTempVariable: (temp: Identifier) => void, languageVersion?: ScriptTarget, cacheIdentifiers?: boolean): CallBinding;
|
||||
/**
|
||||
* Wraps an expression that cannot be an assignment target in an expression that can be.
|
||||
*
|
||||
* Given a `paramName` of `_a`:
|
||||
* ```
|
||||
* Reflect.set(obj, "x", _a)
|
||||
* ```
|
||||
* Becomes
|
||||
* ```ts
|
||||
* ({ set value(_a) { Reflect.set(obj, "x", _a); } }).value
|
||||
* ```
|
||||
*
|
||||
* @param paramName
|
||||
* @param expression
|
||||
*/
|
||||
/* @internal */ createAssignmentTargetWrapper(paramName: Identifier, expression: Expression): LeftHandSideExpression;
|
||||
/* @internal */ inlineExpressions(expressions: readonly Expression[]): Expression;
|
||||
/**
|
||||
* Gets the internal name of a declaration. This is primarily used for declarations that can be
|
||||
|
||||
@@ -1710,6 +1710,7 @@ namespace ts {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.ClassStaticBlockDeclaration:
|
||||
return node;
|
||||
case SyntaxKind.Decorator:
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
@@ -4404,7 +4405,7 @@ namespace ts {
|
||||
else {
|
||||
forEach(declarations, member => {
|
||||
if (isAccessor(member)
|
||||
&& hasSyntacticModifier(member, ModifierFlags.Static) === hasSyntacticModifier(accessor, ModifierFlags.Static)) {
|
||||
&& isStatic(member) === isStatic(accessor)) {
|
||||
const memberName = getPropertyNameForPropertyNameNode(member.name);
|
||||
const accessorName = getPropertyNameForPropertyNameNode(accessor.name);
|
||||
if (memberName === accessorName) {
|
||||
@@ -4715,6 +4716,11 @@ namespace ts {
|
||||
return !!getSelectedSyntacticModifierFlags(node, flags);
|
||||
}
|
||||
|
||||
export function isStatic(node: Node) {
|
||||
// https://tc39.es/ecma262/#sec-static-semantics-isstatic
|
||||
return isClassElement(node) && hasStaticModifier(node) || isClassStaticBlockDeclaration(node);
|
||||
}
|
||||
|
||||
export function hasStaticModifier(node: Node): boolean {
|
||||
return hasSyntacticModifier(node, ModifierFlags.Static);
|
||||
}
|
||||
|
||||
@@ -1425,6 +1425,18 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function isObjectBindingOrAssignmentElement(node: Node): node is ObjectBindingOrAssignmentElement {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.PropertyAssignment: // AssignmentProperty
|
||||
case SyntaxKind.ShorthandPropertyAssignment: // AssignmentProperty
|
||||
case SyntaxKind.SpreadAssignment: // AssignmentRestProperty
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a node is an ArrayBindingOrAssignmentPattern
|
||||
*/
|
||||
|
||||
@@ -2313,6 +2313,9 @@ namespace ts.Completions {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isClassStaticBlockDeclaration(classElement)) {
|
||||
classElementModifierFlags |= ModifierFlags.Static;
|
||||
}
|
||||
|
||||
// No member list for private methods
|
||||
if (!(classElementModifierFlags & ModifierFlags.Private)) {
|
||||
@@ -2766,7 +2769,7 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
// do not filter it out if the static presence doesnt match
|
||||
if (hasEffectiveModifier(m, ModifierFlags.Static) !== !!(currentClassElementModifierFlags & ModifierFlags.Static)) {
|
||||
if (isStatic(m) !== !!(currentClassElementModifierFlags & ModifierFlags.Static)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1684,7 +1684,7 @@ namespace ts.FindAllReferences {
|
||||
Debug.assert(classLike.name === referenceLocation);
|
||||
const addRef = state.referenceAdder(search.symbol);
|
||||
for (const member of classLike.members) {
|
||||
if (!(isMethodOrAccessor(member) && hasSyntacticModifier(member, ModifierFlags.Static))) {
|
||||
if (!(isMethodOrAccessor(member) && isStatic(member))) {
|
||||
continue;
|
||||
}
|
||||
if (member.body) {
|
||||
@@ -1917,7 +1917,7 @@ namespace ts.FindAllReferences {
|
||||
// If we have a 'super' container, we must have an enclosing class.
|
||||
// Now make sure the owning class is the same as the search-space
|
||||
// and has the same static qualifier as the original 'super's owner.
|
||||
return container && (ModifierFlags.Static & getSyntacticModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined;
|
||||
return container && isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined;
|
||||
});
|
||||
|
||||
return [{ definition: { type: DefinitionKind.Symbol, symbol: searchSpaceNode.symbol }, references }];
|
||||
@@ -1983,7 +1983,7 @@ namespace ts.FindAllReferences {
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
// Make sure the container belongs to the same class/object literals
|
||||
// and has the appropriate static modifier from the original container.
|
||||
return container.parent && searchSpaceNode.symbol === container.parent.symbol && (getSyntacticModifierFlags(container) & ModifierFlags.Static) === staticFlag;
|
||||
return container.parent && searchSpaceNode.symbol === container.parent.symbol && isStatic(container) === !!staticFlag;
|
||||
case SyntaxKind.SourceFile:
|
||||
return container.kind === SyntaxKind.SourceFile && !isExternalModule(container as SourceFile) && !isParameterName(node);
|
||||
}
|
||||
@@ -2030,7 +2030,7 @@ namespace ts.FindAllReferences {
|
||||
(sym, root, base) => {
|
||||
// static method/property and instance method/property might have the same name. Only include static or only include instance.
|
||||
if (base) {
|
||||
if (isStatic(symbol) !== isStatic(base)) {
|
||||
if (isStaticSymbol(symbol) !== isStaticSymbol(base)) {
|
||||
base = undefined;
|
||||
}
|
||||
}
|
||||
@@ -2196,7 +2196,7 @@ namespace ts.FindAllReferences {
|
||||
readonly kind: NodeEntryKind | undefined;
|
||||
}
|
||||
|
||||
function isStatic(symbol: Symbol): boolean {
|
||||
function isStaticSymbol(symbol: Symbol): boolean {
|
||||
if (!symbol.valueDeclaration) { return false; }
|
||||
const modifierFlags = getEffectiveModifierFlags(symbol.valueDeclaration);
|
||||
return !!(modifierFlags & ModifierFlags.Static);
|
||||
@@ -2210,7 +2210,7 @@ namespace ts.FindAllReferences {
|
||||
// check whether the symbol used to search itself is just the searched one.
|
||||
if (baseSymbol) {
|
||||
// static method/property and instance method/property might have the same name. Only check static or only check instance.
|
||||
if (isStatic(referenceSymbol) !== isStatic(baseSymbol)) {
|
||||
if (isStaticSymbol(referenceSymbol) !== isStaticSymbol(baseSymbol)) {
|
||||
baseSymbol = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,7 +627,7 @@ namespace ts.NavigationBar {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return hasSyntacticModifier(a, ModifierFlags.Static) === hasSyntacticModifier(b, ModifierFlags.Static);
|
||||
return isStatic(a) === isStatic(b);
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return areSameModule(a as ModuleDeclaration, b as ModuleDeclaration)
|
||||
&& getFullyQualifiedModuleName(a as ModuleDeclaration) === getFullyQualifiedModuleName(b as ModuleDeclaration);
|
||||
|
||||
@@ -398,7 +398,7 @@ namespace ts.refactor.extractSymbol {
|
||||
let current: Node = nodeToCheck;
|
||||
while (current !== containingClass) {
|
||||
if (current.kind === SyntaxKind.PropertyDeclaration) {
|
||||
if (hasSyntacticModifier(current, ModifierFlags.Static)) {
|
||||
if (isStatic(current)) {
|
||||
rangeFacts |= RangeFacts.InStaticRegion;
|
||||
}
|
||||
break;
|
||||
@@ -411,7 +411,7 @@ namespace ts.refactor.extractSymbol {
|
||||
break;
|
||||
}
|
||||
else if (current.kind === SyntaxKind.MethodDeclaration) {
|
||||
if (hasSyntacticModifier(current, ModifierFlags.Static)) {
|
||||
if (isStatic(current)) {
|
||||
rangeFacts |= RangeFacts.InStaticRegion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,12 @@ class Test {
|
||||
//// [asyncArrowInClassES5.js]
|
||||
// https://github.com/Microsoft/TypeScript/issues/16924
|
||||
// Should capture `this`
|
||||
var _this = this;
|
||||
var Test = /** @class */ (function () {
|
||||
function Test() {
|
||||
}
|
||||
Test.member = function (x) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
var _a;
|
||||
_a = Test;
|
||||
Test.member = function (x) { return __awaiter(_a, void 0, void 0, function () { return __generator(_a, function (_b) {
|
||||
return [2 /*return*/];
|
||||
}); }); };
|
||||
return Test;
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock4.ts(5,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock4.ts(8,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock4.ts(8,14): error TS2729: Property 's2' is used before its initialization.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock4.ts(9,11): error TS2729: Property 's2' is used before its initialization.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classStaticBlock/classStaticBlock4.ts (4 errors) ====
|
||||
==== tests/cases/conformance/classes/classStaticBlock/classStaticBlock4.ts (2 errors) ====
|
||||
class C {
|
||||
static s1 = 1;
|
||||
|
||||
static {
|
||||
this.s1;
|
||||
~~~~
|
||||
!!! error TS2332: 'this' cannot be referenced in current location.
|
||||
C.s1;
|
||||
|
||||
this.s2;
|
||||
~~~~
|
||||
!!! error TS2332: 'this' cannot be referenced in current location.
|
||||
~~
|
||||
!!! error TS2729: Property 's2' is used before its initialization.
|
||||
!!! related TS2728 tests/cases/conformance/classes/classStaticBlock/classStaticBlock4.ts:12:12: 's2' is declared here.
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(8,16): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(11,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(12,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(13,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts (4 errors) ====
|
||||
class B {
|
||||
static a = 1;
|
||||
static b = 2;
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
static b = 3;
|
||||
static c = super.a
|
||||
~~~~~
|
||||
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
|
||||
static {
|
||||
this.b;
|
||||
~~~~
|
||||
!!! error TS2332: 'this' cannot be referenced in current location.
|
||||
super.b;
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
super.a;
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,18 @@ class C extends B {
|
||||
|
||||
|
||||
//// [classStaticBlock5.js]
|
||||
var _a, _b;
|
||||
class B {
|
||||
}
|
||||
B.a = 1;
|
||||
B.b = 2;
|
||||
class C extends B {
|
||||
class C extends (_b = B) {
|
||||
}
|
||||
_a = C;
|
||||
C.b = 3;
|
||||
C.c = super.a;
|
||||
C.c = Reflect.get(_b, "a", _a);
|
||||
(() => {
|
||||
this.b;
|
||||
super.b;
|
||||
super.a;
|
||||
_a.b;
|
||||
Reflect.get(_b, "b", _a);
|
||||
Reflect.get(_b, "a", _a);
|
||||
})();
|
||||
|
||||
@@ -18,6 +18,9 @@ class C extends B {
|
||||
|
||||
static c = super.a
|
||||
>c : Symbol(C.c, Decl(classStaticBlock5.ts, 6, 17))
|
||||
>super.a : Symbol(B.a, Decl(classStaticBlock5.ts, 0, 9))
|
||||
>super : Symbol(B, Decl(classStaticBlock5.ts, 0, 0))
|
||||
>a : Symbol(B.a, Decl(classStaticBlock5.ts, 0, 9))
|
||||
|
||||
static {
|
||||
this.b;
|
||||
@@ -26,7 +29,14 @@ class C extends B {
|
||||
>b : Symbol(C.b, Decl(classStaticBlock5.ts, 5, 19))
|
||||
|
||||
super.b;
|
||||
>super.b : Symbol(B.b, Decl(classStaticBlock5.ts, 1, 17))
|
||||
>super : Symbol(B, Decl(classStaticBlock5.ts, 0, 0))
|
||||
>b : Symbol(B.b, Decl(classStaticBlock5.ts, 1, 17))
|
||||
|
||||
super.a;
|
||||
>super.a : Symbol(B.a, Decl(classStaticBlock5.ts, 0, 9))
|
||||
>super : Symbol(B, Decl(classStaticBlock5.ts, 0, 0))
|
||||
>a : Symbol(B.a, Decl(classStaticBlock5.ts, 0, 9))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ class C extends B {
|
||||
>3 : 3
|
||||
|
||||
static c = super.a
|
||||
>c : any
|
||||
>super.a : any
|
||||
>super : any
|
||||
>a : any
|
||||
>c : number
|
||||
>super.a : number
|
||||
>super : typeof B
|
||||
>a : number
|
||||
|
||||
static {
|
||||
this.b;
|
||||
@@ -32,14 +32,14 @@ class C extends B {
|
||||
>b : number
|
||||
|
||||
super.b;
|
||||
>super.b : any
|
||||
>super : any
|
||||
>b : any
|
||||
>super.b : number
|
||||
>super : typeof B
|
||||
>b : number
|
||||
|
||||
super.a;
|
||||
>super.a : any
|
||||
>super : any
|
||||
>a : any
|
||||
>super.a : number
|
||||
>super : typeof B
|
||||
>a : number
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(8,16): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(11,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(12,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(13,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(8,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(12,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(13,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts (4 errors) ====
|
||||
==== tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts (3 errors) ====
|
||||
class B {
|
||||
static a = 1;
|
||||
static b = 2;
|
||||
@@ -13,19 +12,17 @@ tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(13,9): err
|
||||
class C extends B {
|
||||
static b = 3;
|
||||
static c = super.a
|
||||
~~~~~
|
||||
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
~
|
||||
!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
|
||||
static {
|
||||
this.b;
|
||||
~~~~
|
||||
!!! error TS2332: 'this' cannot be referenced in current location.
|
||||
super.b;
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
~
|
||||
!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
super.a;
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
~
|
||||
!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,10 +45,12 @@ var C = /** @class */ (function (_super) {
|
||||
function C() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
var _a;
|
||||
_a = C;
|
||||
C.b = 3;
|
||||
C.c = _super.a;
|
||||
(function () {
|
||||
_this.b;
|
||||
_a.b;
|
||||
_super.b;
|
||||
_super.a;
|
||||
})();
|
||||
|
||||
@@ -18,6 +18,9 @@ class C extends B {
|
||||
|
||||
static c = super.a
|
||||
>c : Symbol(C.c, Decl(classStaticBlock5.ts, 6, 17))
|
||||
>super.a : Symbol(B.a, Decl(classStaticBlock5.ts, 0, 9))
|
||||
>super : Symbol(B, Decl(classStaticBlock5.ts, 0, 0))
|
||||
>a : Symbol(B.a, Decl(classStaticBlock5.ts, 0, 9))
|
||||
|
||||
static {
|
||||
this.b;
|
||||
@@ -26,7 +29,14 @@ class C extends B {
|
||||
>b : Symbol(C.b, Decl(classStaticBlock5.ts, 5, 19))
|
||||
|
||||
super.b;
|
||||
>super.b : Symbol(B.b, Decl(classStaticBlock5.ts, 1, 17))
|
||||
>super : Symbol(B, Decl(classStaticBlock5.ts, 0, 0))
|
||||
>b : Symbol(B.b, Decl(classStaticBlock5.ts, 1, 17))
|
||||
|
||||
super.a;
|
||||
>super.a : Symbol(B.a, Decl(classStaticBlock5.ts, 0, 9))
|
||||
>super : Symbol(B, Decl(classStaticBlock5.ts, 0, 0))
|
||||
>a : Symbol(B.a, Decl(classStaticBlock5.ts, 0, 9))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ class C extends B {
|
||||
>3 : 3
|
||||
|
||||
static c = super.a
|
||||
>c : any
|
||||
>super.a : any
|
||||
>super : any
|
||||
>a : any
|
||||
>c : number
|
||||
>super.a : number
|
||||
>super : typeof B
|
||||
>a : number
|
||||
|
||||
static {
|
||||
this.b;
|
||||
@@ -32,14 +32,14 @@ class C extends B {
|
||||
>b : number
|
||||
|
||||
super.b;
|
||||
>super.b : any
|
||||
>super : any
|
||||
>b : any
|
||||
>super.b : number
|
||||
>super : typeof B
|
||||
>b : number
|
||||
|
||||
super.a;
|
||||
>super.a : any
|
||||
>super : any
|
||||
>a : any
|
||||
>super.a : number
|
||||
>super : typeof B
|
||||
>a : number
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(8,16): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(11,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(12,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts(13,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts (4 errors) ====
|
||||
class B {
|
||||
static a = 1;
|
||||
static b = 2;
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
static b = 3;
|
||||
static c = super.a
|
||||
~~~~~
|
||||
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
|
||||
static {
|
||||
this.b;
|
||||
~~~~
|
||||
!!! error TS2332: 'this' cannot be referenced in current location.
|
||||
super.b;
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
super.a;
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ class C extends B {
|
||||
|
||||
static c = super.a
|
||||
>c : Symbol(C.c, Decl(classStaticBlock5.ts, 6, 17))
|
||||
>super.a : Symbol(B.a, Decl(classStaticBlock5.ts, 0, 9))
|
||||
>super : Symbol(B, Decl(classStaticBlock5.ts, 0, 0))
|
||||
>a : Symbol(B.a, Decl(classStaticBlock5.ts, 0, 9))
|
||||
|
||||
static {
|
||||
this.b;
|
||||
@@ -26,7 +29,14 @@ class C extends B {
|
||||
>b : Symbol(C.b, Decl(classStaticBlock5.ts, 5, 19))
|
||||
|
||||
super.b;
|
||||
>super.b : Symbol(B.b, Decl(classStaticBlock5.ts, 1, 17))
|
||||
>super : Symbol(B, Decl(classStaticBlock5.ts, 0, 0))
|
||||
>b : Symbol(B.b, Decl(classStaticBlock5.ts, 1, 17))
|
||||
|
||||
super.a;
|
||||
>super.a : Symbol(B.a, Decl(classStaticBlock5.ts, 0, 9))
|
||||
>super : Symbol(B, Decl(classStaticBlock5.ts, 0, 0))
|
||||
>a : Symbol(B.a, Decl(classStaticBlock5.ts, 0, 9))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ class C extends B {
|
||||
>3 : 3
|
||||
|
||||
static c = super.a
|
||||
>c : any
|
||||
>super.a : any
|
||||
>super : any
|
||||
>a : any
|
||||
>c : number
|
||||
>super.a : number
|
||||
>super : typeof B
|
||||
>a : number
|
||||
|
||||
static {
|
||||
this.b;
|
||||
@@ -32,14 +32,14 @@ class C extends B {
|
||||
>b : number
|
||||
|
||||
super.b;
|
||||
>super.b : any
|
||||
>super : any
|
||||
>b : any
|
||||
>super.b : number
|
||||
>super : typeof B
|
||||
>b : number
|
||||
|
||||
super.a;
|
||||
>super.a : any
|
||||
>super : any
|
||||
>a : any
|
||||
>super.a : number
|
||||
>super : typeof B
|
||||
>a : number
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ tests/cases/conformance/classes/classStaticBlock/classStaticBlock6.ts(17,9): err
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock6.ts(18,9): error TS18037: Await expression cannot be used inside a class static block.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock6.ts(18,14): error TS1109: Expression expected.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock6.ts(19,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock6.ts(32,17): error TS2335: 'super' can only be referenced in a derived class.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock6.ts(32,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock6.ts(41,13): error TS2815: 'arguments' cannot be referenced in property initializers.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock6.ts(42,13): error TS18037: Await expression cannot be used inside a class static block.
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlock6.ts(42,18): error TS1109: Expression expected.
|
||||
@@ -65,7 +65,7 @@ tests/cases/conformance/classes/classStaticBlock/classStaticBlock6.ts(55,13): er
|
||||
}
|
||||
super();
|
||||
~~~~~
|
||||
!!! error TS2335: 'super' can only be referenced in a derived class.
|
||||
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlockUseBeforeDef1.ts ===
|
||||
class C {
|
||||
>C : Symbol(C, Decl(classStaticBlockUseBeforeDef1.ts, 0, 0))
|
||||
|
||||
static x;
|
||||
>x : Symbol(C.x, Decl(classStaticBlockUseBeforeDef1.ts, 0, 9))
|
||||
|
||||
static {
|
||||
this.x = 1;
|
||||
>this.x : Symbol(C.x, Decl(classStaticBlockUseBeforeDef1.ts, 0, 9))
|
||||
>this : Symbol(C, Decl(classStaticBlockUseBeforeDef1.ts, 0, 0))
|
||||
>x : Symbol(C.x, Decl(classStaticBlockUseBeforeDef1.ts, 0, 9))
|
||||
}
|
||||
static y = this.x;
|
||||
>y : Symbol(C.y, Decl(classStaticBlockUseBeforeDef1.ts, 4, 5))
|
||||
>this.x : Symbol(C.x, Decl(classStaticBlockUseBeforeDef1.ts, 0, 9))
|
||||
>this : Symbol(C, Decl(classStaticBlockUseBeforeDef1.ts, 0, 0))
|
||||
>x : Symbol(C.x, Decl(classStaticBlockUseBeforeDef1.ts, 0, 9))
|
||||
|
||||
static z;
|
||||
>z : Symbol(C.z, Decl(classStaticBlockUseBeforeDef1.ts, 5, 22))
|
||||
|
||||
static {
|
||||
this.z = this.y;
|
||||
>this.z : Symbol(C.z, Decl(classStaticBlockUseBeforeDef1.ts, 5, 22))
|
||||
>this : Symbol(C, Decl(classStaticBlockUseBeforeDef1.ts, 0, 0))
|
||||
>z : Symbol(C.z, Decl(classStaticBlockUseBeforeDef1.ts, 5, 22))
|
||||
>this.y : Symbol(C.y, Decl(classStaticBlockUseBeforeDef1.ts, 4, 5))
|
||||
>this : Symbol(C, Decl(classStaticBlockUseBeforeDef1.ts, 0, 0))
|
||||
>y : Symbol(C.y, Decl(classStaticBlockUseBeforeDef1.ts, 4, 5))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlockUseBeforeDef1.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
static x;
|
||||
>x : number
|
||||
|
||||
static {
|
||||
this.x = 1;
|
||||
>this.x = 1 : 1
|
||||
>this.x : number
|
||||
>this : typeof C
|
||||
>x : number
|
||||
>1 : 1
|
||||
}
|
||||
static y = this.x;
|
||||
>y : number
|
||||
>this.x : number
|
||||
>this : typeof C
|
||||
>x : number
|
||||
|
||||
static z;
|
||||
>z : number
|
||||
|
||||
static {
|
||||
this.z = this.y;
|
||||
>this.z = this.y : number
|
||||
>this.z : number
|
||||
>this : typeof C
|
||||
>z : number
|
||||
>this.y : number
|
||||
>this : typeof C
|
||||
>y : number
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/conformance/classes/classStaticBlock/classStaticBlockUseBeforeDef2.ts(3,14): error TS2729: Property 'x' is used before its initialization.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classStaticBlock/classStaticBlockUseBeforeDef2.ts (1 errors) ====
|
||||
class C {
|
||||
static {
|
||||
this.x = 1;
|
||||
~
|
||||
!!! error TS2729: Property 'x' is used before its initialization.
|
||||
!!! related TS2728 tests/cases/conformance/classes/classStaticBlock/classStaticBlockUseBeforeDef2.ts:5:12: 'x' is declared here.
|
||||
}
|
||||
static x;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlockUseBeforeDef2.ts ===
|
||||
class C {
|
||||
>C : Symbol(C, Decl(classStaticBlockUseBeforeDef2.ts, 0, 0))
|
||||
|
||||
static {
|
||||
this.x = 1;
|
||||
>this.x : Symbol(C.x, Decl(classStaticBlockUseBeforeDef2.ts, 3, 5))
|
||||
>this : Symbol(C, Decl(classStaticBlockUseBeforeDef2.ts, 0, 0))
|
||||
>x : Symbol(C.x, Decl(classStaticBlockUseBeforeDef2.ts, 3, 5))
|
||||
}
|
||||
static x;
|
||||
>x : Symbol(C.x, Decl(classStaticBlockUseBeforeDef2.ts, 3, 5))
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/classes/classStaticBlock/classStaticBlockUseBeforeDef2.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
static {
|
||||
this.x = 1;
|
||||
>this.x = 1 : 1
|
||||
>this.x : number
|
||||
>this : typeof C
|
||||
>x : number
|
||||
>1 : 1
|
||||
}
|
||||
static x;
|
||||
>x : number
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
tests/cases/conformance/salsa/a.js(14,13): error TS7008: Member 'inMethodNullable' implicitly has an 'any' type.
|
||||
tests/cases/conformance/salsa/a.js(20,9): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/salsa/a.js(39,9): error TS2322: Type 'boolean' is not assignable to type 'number'.
|
||||
tests/cases/conformance/salsa/a.js(93,13): error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
tests/cases/conformance/salsa/a.js(96,13): error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
|
||||
|
||||
==== tests/cases/conformance/salsa/a.js (5 errors) ====
|
||||
==== tests/cases/conformance/salsa/a.js (3 errors) ====
|
||||
class C {
|
||||
constructor() {
|
||||
if (Math.random()) {
|
||||
@@ -105,13 +103,9 @@ tests/cases/conformance/salsa/a.js(96,13): error TS2334: 'this' cannot be refere
|
||||
static prop = () => {
|
||||
if (Math.random()) {
|
||||
this.inStaticPropertyDeclaration = 0;
|
||||
~~~~
|
||||
!!! error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
}
|
||||
else {
|
||||
this.inStaticPropertyDeclaration = "string"
|
||||
~~~~
|
||||
!!! error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,6 @@ var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction;
|
||||
|
||||
|
||||
//// [output.js]
|
||||
var _this = this;
|
||||
var C = /** @class */ (function () {
|
||||
function C() {
|
||||
var _this = this;
|
||||
@@ -225,12 +224,14 @@ var C = /** @class */ (function () {
|
||||
this.inStaticSetter = "string";
|
||||
}
|
||||
};
|
||||
var _a;
|
||||
_a = C;
|
||||
C.prop = function () {
|
||||
if (Math.random()) {
|
||||
_this.inStaticPropertyDeclaration = 0;
|
||||
_a.inStaticPropertyDeclaration = 0;
|
||||
}
|
||||
else {
|
||||
_this.inStaticPropertyDeclaration = "string";
|
||||
_a.inStaticPropertyDeclaration = "string";
|
||||
}
|
||||
};
|
||||
return C;
|
||||
|
||||
@@ -44,31 +44,31 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
||||
var _C_test;
|
||||
class C {
|
||||
constructor() {
|
||||
var _a, _b;
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
||||
_C_test.set(this, 24);
|
||||
__classPrivateFieldSet(this, _C_test, +__classPrivateFieldGet(this, _C_test, "f") + 1, "f");
|
||||
__classPrivateFieldSet(this, _C_test, +__classPrivateFieldGet(this, _C_test, "f") - 1, "f");
|
||||
__classPrivateFieldSet(this, _C_test, +__classPrivateFieldGet(this, _C_test, "f") + 1, "f");
|
||||
__classPrivateFieldSet(this, _C_test, +__classPrivateFieldGet(this, _C_test, "f") - 1, "f");
|
||||
const a = (__classPrivateFieldSet(this, _C_test, (_a = +__classPrivateFieldGet(this, _C_test, "f")) + 1, "f"), _a);
|
||||
const b = (__classPrivateFieldSet(this, _C_test, (_b = +__classPrivateFieldGet(this, _C_test, "f")) - 1, "f"), _b);
|
||||
const c = __classPrivateFieldSet(this, _C_test, +__classPrivateFieldGet(this, _C_test, "f") + 1, "f");
|
||||
const d = __classPrivateFieldSet(this, _C_test, +__classPrivateFieldGet(this, _C_test, "f") - 1, "f");
|
||||
for (__classPrivateFieldSet(this, _C_test, 0, "f"); __classPrivateFieldGet(this, _C_test, "f") < 10; __classPrivateFieldSet(this, _C_test, +__classPrivateFieldGet(this, _C_test, "f") + 1, "f")) { }
|
||||
for (__classPrivateFieldSet(this, _C_test, 0, "f"); __classPrivateFieldGet(this, _C_test, "f") < 10; __classPrivateFieldSet(this, _C_test, +__classPrivateFieldGet(this, _C_test, "f") + 1, "f")) { }
|
||||
__classPrivateFieldSet(this, _C_test, (_a = __classPrivateFieldGet(this, _C_test, "f"), _a++, _a), "f");
|
||||
__classPrivateFieldSet(this, _C_test, (_b = __classPrivateFieldGet(this, _C_test, "f"), _b--, _b), "f");
|
||||
__classPrivateFieldSet(this, _C_test, (_c = __classPrivateFieldGet(this, _C_test, "f"), ++_c), "f");
|
||||
__classPrivateFieldSet(this, _C_test, (_d = __classPrivateFieldGet(this, _C_test, "f"), --_d), "f");
|
||||
const a = (__classPrivateFieldSet(this, _C_test, (_f = __classPrivateFieldGet(this, _C_test, "f"), _e = _f++, _f), "f"), _e);
|
||||
const b = (__classPrivateFieldSet(this, _C_test, (_h = __classPrivateFieldGet(this, _C_test, "f"), _g = _h--, _h), "f"), _g);
|
||||
const c = __classPrivateFieldSet(this, _C_test, (_j = __classPrivateFieldGet(this, _C_test, "f"), ++_j), "f");
|
||||
const d = __classPrivateFieldSet(this, _C_test, (_k = __classPrivateFieldGet(this, _C_test, "f"), --_k), "f");
|
||||
for (__classPrivateFieldSet(this, _C_test, 0, "f"); __classPrivateFieldGet(this, _C_test, "f") < 10; __classPrivateFieldSet(this, _C_test, (_l = __classPrivateFieldGet(this, _C_test, "f"), ++_l), "f")) { }
|
||||
for (__classPrivateFieldSet(this, _C_test, 0, "f"); __classPrivateFieldGet(this, _C_test, "f") < 10; __classPrivateFieldSet(this, _C_test, (_m = __classPrivateFieldGet(this, _C_test, "f"), _m++, _m), "f")) { }
|
||||
}
|
||||
test() {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
||||
__classPrivateFieldSet(_a = this.getInstance(), _C_test, +__classPrivateFieldGet(_a, _C_test, "f") + 1, "f");
|
||||
__classPrivateFieldSet(_b = this.getInstance(), _C_test, +__classPrivateFieldGet(_b, _C_test, "f") - 1, "f");
|
||||
__classPrivateFieldSet(_c = this.getInstance(), _C_test, +__classPrivateFieldGet(_c, _C_test, "f") + 1, "f");
|
||||
__classPrivateFieldSet(_d = this.getInstance(), _C_test, +__classPrivateFieldGet(_d, _C_test, "f") - 1, "f");
|
||||
const a = (__classPrivateFieldSet(_e = this.getInstance(), _C_test, (_f = +__classPrivateFieldGet(_e, _C_test, "f")) + 1, "f"), _f);
|
||||
const b = (__classPrivateFieldSet(_g = this.getInstance(), _C_test, (_h = +__classPrivateFieldGet(_g, _C_test, "f")) - 1, "f"), _h);
|
||||
const c = __classPrivateFieldSet(_j = this.getInstance(), _C_test, +__classPrivateFieldGet(_j, _C_test, "f") + 1, "f");
|
||||
const d = __classPrivateFieldSet(_k = this.getInstance(), _C_test, +__classPrivateFieldGet(_k, _C_test, "f") - 1, "f");
|
||||
for (__classPrivateFieldSet(this.getInstance(), _C_test, 0, "f"); __classPrivateFieldGet(this.getInstance(), _C_test, "f") < 10; __classPrivateFieldSet(_l = this.getInstance(), _C_test, +__classPrivateFieldGet(_l, _C_test, "f") + 1, "f")) { }
|
||||
for (__classPrivateFieldSet(this.getInstance(), _C_test, 0, "f"); __classPrivateFieldGet(this.getInstance(), _C_test, "f") < 10; __classPrivateFieldSet(_m = this.getInstance(), _C_test, +__classPrivateFieldGet(_m, _C_test, "f") + 1, "f")) { }
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
||||
__classPrivateFieldSet(_a = this.getInstance(), _C_test, (_b = __classPrivateFieldGet(_a, _C_test, "f"), _b++, _b), "f");
|
||||
__classPrivateFieldSet(_c = this.getInstance(), _C_test, (_d = __classPrivateFieldGet(_c, _C_test, "f"), _d--, _d), "f");
|
||||
__classPrivateFieldSet(_e = this.getInstance(), _C_test, (_f = __classPrivateFieldGet(_e, _C_test, "f"), ++_f), "f");
|
||||
__classPrivateFieldSet(_g = this.getInstance(), _C_test, (_h = __classPrivateFieldGet(_g, _C_test, "f"), --_h), "f");
|
||||
const a = (__classPrivateFieldSet(_j = this.getInstance(), _C_test, (_l = __classPrivateFieldGet(_j, _C_test, "f"), _k = _l++, _l), "f"), _k);
|
||||
const b = (__classPrivateFieldSet(_m = this.getInstance(), _C_test, (_p = __classPrivateFieldGet(_m, _C_test, "f"), _o = _p--, _p), "f"), _o);
|
||||
const c = __classPrivateFieldSet(_q = this.getInstance(), _C_test, (_r = __classPrivateFieldGet(_q, _C_test, "f"), ++_r), "f");
|
||||
const d = __classPrivateFieldSet(_s = this.getInstance(), _C_test, (_t = __classPrivateFieldGet(_s, _C_test, "f"), --_t), "f");
|
||||
for (__classPrivateFieldSet(this.getInstance(), _C_test, 0, "f"); __classPrivateFieldGet(this.getInstance(), _C_test, "f") < 10; __classPrivateFieldSet(_u = this.getInstance(), _C_test, (_v = __classPrivateFieldGet(_u, _C_test, "f"), ++_v), "f")) { }
|
||||
for (__classPrivateFieldSet(this.getInstance(), _C_test, 0, "f"); __classPrivateFieldGet(this.getInstance(), _C_test, "f") < 10; __classPrivateFieldSet(_w = this.getInstance(), _C_test, (_x = __classPrivateFieldGet(_w, _C_test, "f"), _x++, _x), "f")) { }
|
||||
}
|
||||
getInstance() { return new C(); }
|
||||
}
|
||||
|
||||
@@ -27,14 +27,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
||||
var _A3_instances, _A3_method;
|
||||
class A3 {
|
||||
constructor(a, b) {
|
||||
var _a, _b;
|
||||
var _a, _b, _c;
|
||||
_A3_instances.add(this);
|
||||
__classPrivateFieldSet(this, _A3_instances, () => { }, "m"); // Error, not writable
|
||||
__classPrivateFieldSet(a, _A3_instances, () => { }, "m"); // Error, not writable
|
||||
__classPrivateFieldSet(b, _A3_instances, () => { }, "m"); //Error, not writable
|
||||
(_a = this, { x: ({ set value(_b) { __classPrivateFieldSet(_a, _A3_instances, _b, "m"); } }).value } = { x: () => { } }); //Error, not writable
|
||||
let x = __classPrivateFieldGet(this, _A3_instances, "m", _A3_method);
|
||||
__classPrivateFieldSet(_b = b, _A3_instances, +__classPrivateFieldGet(_b, _A3_instances, "m", _A3_method) + 1, "m"); //Error, not writable
|
||||
__classPrivateFieldSet(_b = b, _A3_instances, (_c = __classPrivateFieldGet(_b, _A3_instances, "m", _A3_method), _c++, _c), "m"); //Error, not writable
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
@@ -44,30 +44,30 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
||||
var _a, _C_test;
|
||||
class C {
|
||||
constructor() {
|
||||
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
||||
__classPrivateFieldSet(_b = C, _a, +__classPrivateFieldGet(_b, _a, "f", _C_test) + 1, "f", _C_test);
|
||||
__classPrivateFieldSet(_c = C, _a, +__classPrivateFieldGet(_c, _a, "f", _C_test) - 1, "f", _C_test);
|
||||
__classPrivateFieldSet(_d = C, _a, +__classPrivateFieldGet(_d, _a, "f", _C_test) + 1, "f", _C_test);
|
||||
__classPrivateFieldSet(_e = C, _a, +__classPrivateFieldGet(_e, _a, "f", _C_test) - 1, "f", _C_test);
|
||||
const a = (__classPrivateFieldSet(_f = C, _a, (_g = +__classPrivateFieldGet(_f, _a, "f", _C_test)) + 1, "f", _C_test), _g);
|
||||
const b = (__classPrivateFieldSet(_h = C, _a, (_j = +__classPrivateFieldGet(_h, _a, "f", _C_test)) - 1, "f", _C_test), _j);
|
||||
const c = __classPrivateFieldSet(_k = C, _a, +__classPrivateFieldGet(_k, _a, "f", _C_test) + 1, "f", _C_test);
|
||||
const d = __classPrivateFieldSet(_l = C, _a, +__classPrivateFieldGet(_l, _a, "f", _C_test) - 1, "f", _C_test);
|
||||
for (__classPrivateFieldSet(C, _a, 0, "f", _C_test); __classPrivateFieldGet(C, _a, "f", _C_test) < 10; __classPrivateFieldSet(_m = C, _a, +__classPrivateFieldGet(_m, _a, "f", _C_test) + 1, "f", _C_test)) { }
|
||||
for (__classPrivateFieldSet(C, _a, 0, "f", _C_test); __classPrivateFieldGet(C, _a, "f", _C_test) < 10; __classPrivateFieldSet(_o = C, _a, +__classPrivateFieldGet(_o, _a, "f", _C_test) + 1, "f", _C_test)) { }
|
||||
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
||||
__classPrivateFieldSet(_b = C, _a, (_c = __classPrivateFieldGet(_b, _a, "f", _C_test), _c++, _c), "f", _C_test);
|
||||
__classPrivateFieldSet(_d = C, _a, (_e = __classPrivateFieldGet(_d, _a, "f", _C_test), _e--, _e), "f", _C_test);
|
||||
__classPrivateFieldSet(_f = C, _a, (_g = __classPrivateFieldGet(_f, _a, "f", _C_test), ++_g), "f", _C_test);
|
||||
__classPrivateFieldSet(_h = C, _a, (_j = __classPrivateFieldGet(_h, _a, "f", _C_test), --_j), "f", _C_test);
|
||||
const a = (__classPrivateFieldSet(_k = C, _a, (_m = __classPrivateFieldGet(_k, _a, "f", _C_test), _l = _m++, _m), "f", _C_test), _l);
|
||||
const b = (__classPrivateFieldSet(_o = C, _a, (_q = __classPrivateFieldGet(_o, _a, "f", _C_test), _p = _q--, _q), "f", _C_test), _p);
|
||||
const c = __classPrivateFieldSet(_r = C, _a, (_s = __classPrivateFieldGet(_r, _a, "f", _C_test), ++_s), "f", _C_test);
|
||||
const d = __classPrivateFieldSet(_t = C, _a, (_u = __classPrivateFieldGet(_t, _a, "f", _C_test), --_u), "f", _C_test);
|
||||
for (__classPrivateFieldSet(C, _a, 0, "f", _C_test); __classPrivateFieldGet(C, _a, "f", _C_test) < 10; __classPrivateFieldSet(_v = C, _a, (_w = __classPrivateFieldGet(_v, _a, "f", _C_test), ++_w), "f", _C_test)) { }
|
||||
for (__classPrivateFieldSet(C, _a, 0, "f", _C_test); __classPrivateFieldGet(C, _a, "f", _C_test) < 10; __classPrivateFieldSet(_x = C, _a, (_y = __classPrivateFieldGet(_x, _a, "f", _C_test), _y++, _y), "f", _C_test)) { }
|
||||
}
|
||||
test() {
|
||||
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
||||
__classPrivateFieldSet(_b = this.getClass(), _a, +__classPrivateFieldGet(_b, _a, "f", _C_test) + 1, "f", _C_test);
|
||||
__classPrivateFieldSet(_c = this.getClass(), _a, +__classPrivateFieldGet(_c, _a, "f", _C_test) - 1, "f", _C_test);
|
||||
__classPrivateFieldSet(_d = this.getClass(), _a, +__classPrivateFieldGet(_d, _a, "f", _C_test) + 1, "f", _C_test);
|
||||
__classPrivateFieldSet(_e = this.getClass(), _a, +__classPrivateFieldGet(_e, _a, "f", _C_test) - 1, "f", _C_test);
|
||||
const a = (__classPrivateFieldSet(_f = this.getClass(), _a, (_g = +__classPrivateFieldGet(_f, _a, "f", _C_test)) + 1, "f", _C_test), _g);
|
||||
const b = (__classPrivateFieldSet(_h = this.getClass(), _a, (_j = +__classPrivateFieldGet(_h, _a, "f", _C_test)) - 1, "f", _C_test), _j);
|
||||
const c = __classPrivateFieldSet(_k = this.getClass(), _a, +__classPrivateFieldGet(_k, _a, "f", _C_test) + 1, "f", _C_test);
|
||||
const d = __classPrivateFieldSet(_l = this.getClass(), _a, +__classPrivateFieldGet(_l, _a, "f", _C_test) - 1, "f", _C_test);
|
||||
for (__classPrivateFieldSet(this.getClass(), _a, 0, "f", _C_test); __classPrivateFieldGet(this.getClass(), _a, "f", _C_test) < 10; __classPrivateFieldSet(_m = this.getClass(), _a, +__classPrivateFieldGet(_m, _a, "f", _C_test) + 1, "f", _C_test)) { }
|
||||
for (__classPrivateFieldSet(this.getClass(), _a, 0, "f", _C_test); __classPrivateFieldGet(this.getClass(), _a, "f", _C_test) < 10; __classPrivateFieldSet(_o = this.getClass(), _a, +__classPrivateFieldGet(_o, _a, "f", _C_test) + 1, "f", _C_test)) { }
|
||||
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
||||
__classPrivateFieldSet(_b = this.getClass(), _a, (_c = __classPrivateFieldGet(_b, _a, "f", _C_test), _c++, _c), "f", _C_test);
|
||||
__classPrivateFieldSet(_d = this.getClass(), _a, (_e = __classPrivateFieldGet(_d, _a, "f", _C_test), _e--, _e), "f", _C_test);
|
||||
__classPrivateFieldSet(_f = this.getClass(), _a, (_g = __classPrivateFieldGet(_f, _a, "f", _C_test), ++_g), "f", _C_test);
|
||||
__classPrivateFieldSet(_h = this.getClass(), _a, (_j = __classPrivateFieldGet(_h, _a, "f", _C_test), --_j), "f", _C_test);
|
||||
const a = (__classPrivateFieldSet(_k = this.getClass(), _a, (_m = __classPrivateFieldGet(_k, _a, "f", _C_test), _l = _m++, _m), "f", _C_test), _l);
|
||||
const b = (__classPrivateFieldSet(_o = this.getClass(), _a, (_q = __classPrivateFieldGet(_o, _a, "f", _C_test), _p = _q--, _q), "f", _C_test), _p);
|
||||
const c = __classPrivateFieldSet(_r = this.getClass(), _a, (_s = __classPrivateFieldGet(_r, _a, "f", _C_test), ++_s), "f", _C_test);
|
||||
const d = __classPrivateFieldSet(_t = this.getClass(), _a, (_u = __classPrivateFieldGet(_t, _a, "f", _C_test), --_u), "f", _C_test);
|
||||
for (__classPrivateFieldSet(this.getClass(), _a, 0, "f", _C_test); __classPrivateFieldGet(this.getClass(), _a, "f", _C_test) < 10; __classPrivateFieldSet(_v = this.getClass(), _a, (_w = __classPrivateFieldGet(_v, _a, "f", _C_test), ++_w), "f", _C_test)) { }
|
||||
for (__classPrivateFieldSet(this.getClass(), _a, 0, "f", _C_test); __classPrivateFieldGet(this.getClass(), _a, "f", _C_test) < 10; __classPrivateFieldSet(_x = this.getClass(), _a, (_y = __classPrivateFieldGet(_x, _a, "f", _C_test), _y++, _y), "f", _C_test)) { }
|
||||
}
|
||||
getClass() { return C; }
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
||||
var _a, _A3_method;
|
||||
class A3 {
|
||||
constructor(a, b) {
|
||||
var _b;
|
||||
var _b, _c;
|
||||
__classPrivateFieldSet(A3, _a, () => { }, "m"); // Error, not writable
|
||||
__classPrivateFieldSet(a, _a, () => { }, "m"); // Error, not writable
|
||||
__classPrivateFieldSet(b, _a, () => { }, "m"); //Error, not writable
|
||||
({ x: ({ set value(_b) { __classPrivateFieldSet(A3, _a, _b, "m"); } }).value } = { x: () => { } }); //Error, not writable
|
||||
let x = __classPrivateFieldGet(A3, _a, "m", _A3_method);
|
||||
__classPrivateFieldSet(_b = b, _a, +__classPrivateFieldGet(_b, _a, "m", _A3_method) + 1, "m"); //Error, not writable
|
||||
__classPrivateFieldSet(_b = b, _a, (_c = __classPrivateFieldGet(_b, _a, "m", _A3_method), _c++, _c), "m"); //Error, not writable
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
@@ -63,20 +63,20 @@ class Test {
|
||||
_Test_instances.add(this);
|
||||
}
|
||||
m() {
|
||||
var _a, _b, _c;
|
||||
var _a, _b, _c, _d;
|
||||
const foo = { bar: 1 };
|
||||
console.log(__classPrivateFieldGet(this, _Test_instances, "a")); // error
|
||||
__classPrivateFieldSet(this, _Test_instances, { foo }, "a", _Test_value_set); // ok
|
||||
__classPrivateFieldSet(this, _Test_instances, { foo }, "a", _Test_value_set); // ok
|
||||
__classPrivateFieldGet(this, _Test_instances, "a").foo = foo; // error
|
||||
(_a = this, { o: ({ set value(_d) { __classPrivateFieldSet(_a, _Test_instances, _d, "a", _Test_value_set); } }).value } = { o: { foo } }); //ok
|
||||
(__classPrivateFieldGet(this, _Test_instances, "a") = __rest({ foo }, [])); //ok
|
||||
(_a = this, { o: ({ set value(_e) { __classPrivateFieldSet(_a, _Test_instances, _e, "a", _Test_value_set); } }).value } = { o: { foo } }); //ok
|
||||
(_b = this, ({ set value(_e) { __classPrivateFieldSet(_b, _Test_instances, _e, "a", _Test_value_set); } }).value = __rest({ foo }, [])); //ok
|
||||
({ foo: __classPrivateFieldGet(this, _Test_instances, "a").foo } = { foo }); //error
|
||||
({
|
||||
foo: Object.assign({}, __classPrivateFieldGet(this, _Test_instances, "a").foo),
|
||||
} = { foo }); //error
|
||||
let r = { o: __classPrivateFieldGet(this, _Test_instances, "a") }; //error
|
||||
_b = this, _c = this, [({ set value(_d) { __classPrivateFieldSet(_b, _Test_instances, _d, "a", _Test_valueOne_set); } }).value, ...({ set value(_d) { __classPrivateFieldSet(_c, _Test_instances, _d, "a", _Test_valueRest_set); } }).value] = [1, 2, 3];
|
||||
_c = this, _d = this, [({ set value(_e) { __classPrivateFieldSet(_c, _Test_instances, _e, "a", _Test_valueOne_set); } }).value, ...({ set value(_e) { __classPrivateFieldSet(_d, _Test_instances, _e, "a", _Test_valueRest_set); } }).value] = [1, 2, 3];
|
||||
let arr = [
|
||||
__classPrivateFieldGet(this, _Test_instances, "a"),
|
||||
...__classPrivateFieldGet(this, _Test_instances, "a")
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -360,12 +360,12 @@ sourceFile:sourceMapValidationDecorators.ts
|
||||
1->
|
||||
2 > x1
|
||||
3 > : number =
|
||||
4 > 10
|
||||
5 > ;
|
||||
4 > 10;
|
||||
5 >
|
||||
1->Emitted(34, 5) Source(33, 20) + SourceIndex(0)
|
||||
2 >Emitted(34, 15) Source(33, 22) + SourceIndex(0)
|
||||
3 >Emitted(34, 18) Source(33, 33) + SourceIndex(0)
|
||||
4 >Emitted(34, 20) Source(33, 35) + SourceIndex(0)
|
||||
4 >Emitted(34, 20) Source(33, 36) + SourceIndex(0)
|
||||
5 >Emitted(34, 21) Source(33, 36) + SourceIndex(0)
|
||||
---
|
||||
>>> __decorate([
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
tests/cases/compiler/superAccess2.ts(7,15): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superAccess2.ts(8,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
tests/cases/compiler/superAccess2.ts(8,22): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superAccess2.ts(11,28): error TS2336: 'super' cannot be referenced in constructor arguments.
|
||||
tests/cases/compiler/superAccess2.ts(11,28): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
@@ -14,7 +13,7 @@ tests/cases/compiler/superAccess2.ts(20,26): error TS1034: 'super' must be follo
|
||||
tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not exist on type 'typeof P'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/superAccess2.ts (14 errors) ====
|
||||
==== tests/cases/compiler/superAccess2.ts (13 errors) ====
|
||||
class P {
|
||||
x() { }
|
||||
static y() { }
|
||||
@@ -25,8 +24,6 @@ tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not
|
||||
~
|
||||
!!! error TS1034: 'super' must be followed by an argument list or member access.
|
||||
static yy = super; // error for static initializer accessing super
|
||||
~~~~~
|
||||
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
~
|
||||
!!! error TS1034: 'super' must be followed by an argument list or member access.
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class Q extends P {
|
||||
|
||||
static yy = super; // error for static initializer accessing super
|
||||
>yy : Symbol(Q.yy, Decl(superAccess2.ts, 6, 15))
|
||||
>super : Symbol(P, Decl(superAccess2.ts, 0, 0))
|
||||
|
||||
// Super is not allowed in constructor args
|
||||
constructor(public z = super, zz = super, zzz = () => super) {
|
||||
|
||||
@@ -22,7 +22,7 @@ class Q extends P {
|
||||
static yy = super; // error for static initializer accessing super
|
||||
>yy : any
|
||||
>super : any
|
||||
>super : any
|
||||
>super : typeof P
|
||||
> : any
|
||||
|
||||
// Super is not allowed in constructor args
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
//// [thisAndSuperInStaticMembers1.ts]
|
||||
declare class B {
|
||||
static a: any;
|
||||
static f(): number;
|
||||
a: number;
|
||||
f(): number;
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
static x: any = undefined!;
|
||||
static y1 = this.x;
|
||||
static y2 = this.x();
|
||||
static y3 = this?.x();
|
||||
static y4 = this[("x")]();
|
||||
static y5 = this?.[("x")]();
|
||||
static z1 = super.a;
|
||||
static z2 = super["a"];
|
||||
static z3 = super.f();
|
||||
static z4 = super["f"]();
|
||||
static z5 = super.a = 0;
|
||||
static z6 = super.a += 1;
|
||||
static z7 = (() => { super.a = 0; })();
|
||||
static z8 = [super.a] = [0];
|
||||
static z9 = [super.a = 0] = [0];
|
||||
static z10 = [...super.a] = [0];
|
||||
static z11 = { x: super.a } = { x: 0 };
|
||||
static z12 = { x: super.a = 0 } = { x: 0 };
|
||||
static z13 = { ...super.a } = { x: 0 };
|
||||
static z14 = ++super.a;
|
||||
static z15 = --super.a;
|
||||
static z16 = ++super[("a")];
|
||||
static z17 = super.a++;
|
||||
static z18 = super.a``;
|
||||
|
||||
// these should be unaffected
|
||||
x = 1;
|
||||
y = this.x;
|
||||
z = super.f();
|
||||
}
|
||||
|
||||
//// [thisAndSuperInStaticMembers1.js]
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
var _a;
|
||||
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
||||
class C extends (_c = B) {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// these should be unaffected
|
||||
Object.defineProperty(this, "x", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 1
|
||||
});
|
||||
Object.defineProperty(this, "y", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: this.x
|
||||
});
|
||||
Object.defineProperty(this, "z", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: super.f()
|
||||
});
|
||||
}
|
||||
}
|
||||
_b = C;
|
||||
Object.defineProperty(C, "x", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: undefined
|
||||
});
|
||||
Object.defineProperty(C, "y1", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _b.x
|
||||
});
|
||||
Object.defineProperty(C, "y2", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _b.x()
|
||||
});
|
||||
Object.defineProperty(C, "y3", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _b === null || _b === void 0 ? void 0 : _b.x()
|
||||
});
|
||||
Object.defineProperty(C, "y4", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _b[("x")]()
|
||||
});
|
||||
Object.defineProperty(C, "y5", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _b === null || _b === void 0 ? void 0 : _b[("x")]()
|
||||
});
|
||||
Object.defineProperty(C, "z1", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: Reflect.get(_c, "a", _b)
|
||||
});
|
||||
Object.defineProperty(C, "z2", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: Reflect.get(_c, "a", _b)
|
||||
});
|
||||
Object.defineProperty(C, "z3", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: Reflect.get(_c, "f", _b).call(_b)
|
||||
});
|
||||
Object.defineProperty(C, "z4", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: Reflect.get(_c, "f", _b).call(_b)
|
||||
});
|
||||
Object.defineProperty(C, "z5", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (Reflect.set(_c, "a", _d = 0, _b), _d)
|
||||
});
|
||||
Object.defineProperty(C, "z6", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (Reflect.set(_c, "a", _e = Reflect.get(_c, "a", _b) + 1, _b), _e)
|
||||
});
|
||||
Object.defineProperty(C, "z7", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (() => { Reflect.set(_c, "a", 0, _b); })()
|
||||
});
|
||||
Object.defineProperty(C, "z8", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: [({ set value(_a) { Reflect.set(_c, "a", _a, _b); } }).value] = [0]
|
||||
});
|
||||
Object.defineProperty(C, "z9", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: [({ set value(_a) { Reflect.set(_c, "a", _a, _b); } }).value = 0] = [0]
|
||||
});
|
||||
Object.defineProperty(C, "z10", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: [...({ set value(_a) { Reflect.set(_c, "a", _a, _b); } }).value] = [0]
|
||||
});
|
||||
Object.defineProperty(C, "z11", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: { x: ({ set value(_a) { Reflect.set(_c, "a", _a, _b); } }).value } = { x: 0 }
|
||||
});
|
||||
Object.defineProperty(C, "z12", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: { x: ({ set value(_a) { Reflect.set(_c, "a", _a, _b); } }).value = 0 } = { x: 0 }
|
||||
});
|
||||
Object.defineProperty(C, "z13", Object.assign({ enumerable: true, configurable: true, writable: true, value: (_a = { x: 0 }, ({ set value(_a) { Reflect.set(_c, "a", _a, _b); } }).value = __rest(_a, []), _a) }));
|
||||
Object.defineProperty(C, "z14", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (Reflect.set(_c, "a", (_g = Reflect.get(_c, "a", _b), _f = ++_g), _b), _f)
|
||||
});
|
||||
Object.defineProperty(C, "z15", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (Reflect.set(_c, "a", (_j = Reflect.get(_c, "a", _b), _h = --_j), _b), _h)
|
||||
});
|
||||
Object.defineProperty(C, "z16", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (Reflect.set(_c, _k = ("a"), (_m = Reflect.get(_c, _k, _b), _l = ++_m), _b), _l)
|
||||
});
|
||||
Object.defineProperty(C, "z17", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (Reflect.set(_c, "a", (_p = Reflect.get(_c, "a", _b), _o = _p++, _p), _b), _o)
|
||||
});
|
||||
Object.defineProperty(C, "z18", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: Reflect.get(_c, "a", _b).bind(_b) ``
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
//// [thisAndSuperInStaticMembers1.ts]
|
||||
declare class B {
|
||||
static a: any;
|
||||
static f(): number;
|
||||
a: number;
|
||||
f(): number;
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
static x: any = undefined!;
|
||||
static y1 = this.x;
|
||||
static y2 = this.x();
|
||||
static y3 = this?.x();
|
||||
static y4 = this[("x")]();
|
||||
static y5 = this?.[("x")]();
|
||||
static z1 = super.a;
|
||||
static z2 = super["a"];
|
||||
static z3 = super.f();
|
||||
static z4 = super["f"]();
|
||||
static z5 = super.a = 0;
|
||||
static z6 = super.a += 1;
|
||||
static z7 = (() => { super.a = 0; })();
|
||||
static z8 = [super.a] = [0];
|
||||
static z9 = [super.a = 0] = [0];
|
||||
static z10 = [...super.a] = [0];
|
||||
static z11 = { x: super.a } = { x: 0 };
|
||||
static z12 = { x: super.a = 0 } = { x: 0 };
|
||||
static z13 = { ...super.a } = { x: 0 };
|
||||
static z14 = ++super.a;
|
||||
static z15 = --super.a;
|
||||
static z16 = ++super[("a")];
|
||||
static z17 = super.a++;
|
||||
static z18 = super.a``;
|
||||
|
||||
// these should be unaffected
|
||||
x = 1;
|
||||
y = this.x;
|
||||
z = super.f();
|
||||
}
|
||||
|
||||
//// [thisAndSuperInStaticMembers1.js]
|
||||
class C extends B {
|
||||
static x = undefined;
|
||||
static y1 = this.x;
|
||||
static y2 = this.x();
|
||||
static y3 = this?.x();
|
||||
static y4 = this[("x")]();
|
||||
static y5 = this?.[("x")]();
|
||||
static z1 = super.a;
|
||||
static z2 = super["a"];
|
||||
static z3 = super.f();
|
||||
static z4 = super["f"]();
|
||||
static z5 = super.a = 0;
|
||||
static z6 = super.a += 1;
|
||||
static z7 = (() => { super.a = 0; })();
|
||||
static z8 = [super.a] = [0];
|
||||
static z9 = [super.a = 0] = [0];
|
||||
static z10 = [...super.a] = [0];
|
||||
static z11 = { x: super.a } = { x: 0 };
|
||||
static z12 = { x: super.a = 0 } = { x: 0 };
|
||||
static z13 = { ...super.a } = { x: 0 };
|
||||
static z14 = ++super.a;
|
||||
static z15 = --super.a;
|
||||
static z16 = ++super[("a")];
|
||||
static z17 = super.a++;
|
||||
static z18 = super.a ``;
|
||||
// these should be unaffected
|
||||
x = 1;
|
||||
y = this.x;
|
||||
z = super.f();
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
//// [thisAndSuperInStaticMembers2.ts]
|
||||
declare class B {
|
||||
static a: any;
|
||||
static f(): number;
|
||||
a: number;
|
||||
f(): number;
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
static x: any = undefined!;
|
||||
static y1 = this.x;
|
||||
static y2 = this.x();
|
||||
static y3 = this?.x();
|
||||
static y4 = this[("x")]();
|
||||
static y5 = this?.[("x")]();
|
||||
static z1 = super.a;
|
||||
static z2 = super["a"];
|
||||
static z3 = super.f();
|
||||
static z4 = super["f"]();
|
||||
static z5 = super.a = 0;
|
||||
static z6 = super.a += 1;
|
||||
static z7 = (() => { super.a = 0; })();
|
||||
static z8 = [super.a] = [0];
|
||||
static z9 = [super.a = 0] = [0];
|
||||
static z10 = [...super.a] = [0];
|
||||
static z11 = { x: super.a } = { x: 0 };
|
||||
static z12 = { x: super.a = 0 } = { x: 0 };
|
||||
static z13 = { ...super.a } = { x: 0 };
|
||||
static z14 = ++super.a;
|
||||
static z15 = --super.a;
|
||||
static z16 = ++super[("a")];
|
||||
static z17 = super.a++;
|
||||
static z18 = super.a``;
|
||||
|
||||
// these should be unaffected
|
||||
x = 1;
|
||||
y = this.x;
|
||||
z = super.f();
|
||||
}
|
||||
|
||||
//// [thisAndSuperInStaticMembers2.js]
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
var _a;
|
||||
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
||||
class C extends (_c = B) {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// these should be unaffected
|
||||
this.x = 1;
|
||||
this.y = this.x;
|
||||
this.z = super.f();
|
||||
}
|
||||
}
|
||||
_b = C;
|
||||
C.x = undefined;
|
||||
C.y1 = _b.x;
|
||||
C.y2 = _b.x();
|
||||
C.y3 = _b === null || _b === void 0 ? void 0 : _b.x();
|
||||
C.y4 = _b[("x")]();
|
||||
C.y5 = _b === null || _b === void 0 ? void 0 : _b[("x")]();
|
||||
C.z1 = Reflect.get(_c, "a", _b);
|
||||
C.z2 = Reflect.get(_c, "a", _b);
|
||||
C.z3 = Reflect.get(_c, "f", _b).call(_b);
|
||||
C.z4 = Reflect.get(_c, "f", _b).call(_b);
|
||||
C.z5 = (Reflect.set(_c, "a", _d = 0, _b), _d);
|
||||
C.z6 = (Reflect.set(_c, "a", _e = Reflect.get(_c, "a", _b) + 1, _b), _e);
|
||||
C.z7 = (() => { Reflect.set(_c, "a", 0, _b); })();
|
||||
C.z8 = [({ set value(_a) { Reflect.set(_c, "a", _a, _b); } }).value] = [0];
|
||||
C.z9 = [({ set value(_a) { Reflect.set(_c, "a", _a, _b); } }).value = 0] = [0];
|
||||
C.z10 = [...({ set value(_a) { Reflect.set(_c, "a", _a, _b); } }).value] = [0];
|
||||
C.z11 = { x: ({ set value(_a) { Reflect.set(_c, "a", _a, _b); } }).value } = { x: 0 };
|
||||
C.z12 = { x: ({ set value(_a) { Reflect.set(_c, "a", _a, _b); } }).value = 0 } = { x: 0 };
|
||||
C.z13 = (_a = { x: 0 }, ({ set value(_a) { Reflect.set(_c, "a", _a, _b); } }).value = __rest(_a, []), _a);
|
||||
C.z14 = (Reflect.set(_c, "a", (_g = Reflect.get(_c, "a", _b), _f = ++_g), _b), _f);
|
||||
C.z15 = (Reflect.set(_c, "a", (_j = Reflect.get(_c, "a", _b), _h = --_j), _b), _h);
|
||||
C.z16 = (Reflect.set(_c, _k = ("a"), (_m = Reflect.get(_c, _k, _b), _l = ++_m), _b), _l);
|
||||
C.z17 = (Reflect.set(_c, "a", (_p = Reflect.get(_c, "a", _b), _o = _p++, _p), _b), _o);
|
||||
C.z18 = Reflect.get(_c, "a", _b).bind(_b) ``;
|
||||
@@ -0,0 +1,76 @@
|
||||
//// [thisAndSuperInStaticMembers2.ts]
|
||||
declare class B {
|
||||
static a: any;
|
||||
static f(): number;
|
||||
a: number;
|
||||
f(): number;
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
static x: any = undefined!;
|
||||
static y1 = this.x;
|
||||
static y2 = this.x();
|
||||
static y3 = this?.x();
|
||||
static y4 = this[("x")]();
|
||||
static y5 = this?.[("x")]();
|
||||
static z1 = super.a;
|
||||
static z2 = super["a"];
|
||||
static z3 = super.f();
|
||||
static z4 = super["f"]();
|
||||
static z5 = super.a = 0;
|
||||
static z6 = super.a += 1;
|
||||
static z7 = (() => { super.a = 0; })();
|
||||
static z8 = [super.a] = [0];
|
||||
static z9 = [super.a = 0] = [0];
|
||||
static z10 = [...super.a] = [0];
|
||||
static z11 = { x: super.a } = { x: 0 };
|
||||
static z12 = { x: super.a = 0 } = { x: 0 };
|
||||
static z13 = { ...super.a } = { x: 0 };
|
||||
static z14 = ++super.a;
|
||||
static z15 = --super.a;
|
||||
static z16 = ++super[("a")];
|
||||
static z17 = super.a++;
|
||||
static z18 = super.a``;
|
||||
|
||||
// these should be unaffected
|
||||
x = 1;
|
||||
y = this.x;
|
||||
z = super.f();
|
||||
}
|
||||
|
||||
//// [thisAndSuperInStaticMembers2.js]
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
||||
class C extends (_b = B) {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// these should be unaffected
|
||||
this.x = 1;
|
||||
this.y = this.x;
|
||||
this.z = super.f();
|
||||
}
|
||||
}
|
||||
_a = C;
|
||||
C.x = undefined;
|
||||
C.y1 = _a.x;
|
||||
C.y2 = _a.x();
|
||||
C.y3 = _a?.x();
|
||||
C.y4 = _a[("x")]();
|
||||
C.y5 = _a?.[("x")]();
|
||||
C.z1 = Reflect.get(_b, "a", _a);
|
||||
C.z2 = Reflect.get(_b, "a", _a);
|
||||
C.z3 = Reflect.get(_b, "f", _a).call(_a);
|
||||
C.z4 = Reflect.get(_b, "f", _a).call(_a);
|
||||
C.z5 = (Reflect.set(_b, "a", _c = 0, _a), _c);
|
||||
C.z6 = (Reflect.set(_b, "a", _d = Reflect.get(_b, "a", _a) + 1, _a), _d);
|
||||
C.z7 = (() => { Reflect.set(_b, "a", 0, _a); })();
|
||||
C.z8 = [({ set value(_c) { Reflect.set(_b, "a", _c, _a); } }).value] = [0];
|
||||
C.z9 = [({ set value(_c) { Reflect.set(_b, "a", _c, _a); } }).value = 0] = [0];
|
||||
C.z10 = [...({ set value(_c) { Reflect.set(_b, "a", _c, _a); } }).value] = [0];
|
||||
C.z11 = { x: ({ set value(_c) { Reflect.set(_b, "a", _c, _a); } }).value } = { x: 0 };
|
||||
C.z12 = { x: ({ set value(_c) { Reflect.set(_b, "a", _c, _a); } }).value = 0 } = { x: 0 };
|
||||
C.z13 = { ...({ set value(_c) { Reflect.set(_b, "a", _c, _a); } }).value } = { x: 0 };
|
||||
C.z14 = (Reflect.set(_b, "a", (_f = Reflect.get(_b, "a", _a), _e = ++_f), _a), _e);
|
||||
C.z15 = (Reflect.set(_b, "a", (_h = Reflect.get(_b, "a", _a), _g = --_h), _a), _g);
|
||||
C.z16 = (Reflect.set(_b, _j = ("a"), (_l = Reflect.get(_b, _j, _a), _k = ++_l), _a), _k);
|
||||
C.z17 = (Reflect.set(_b, "a", (_o = Reflect.get(_b, "a", _a), _m = _o++, _o), _a), _m);
|
||||
C.z18 = Reflect.get(_b, "a", _a).bind(_a) ``;
|
||||
@@ -0,0 +1,117 @@
|
||||
//// [thisAndSuperInStaticMembers3.ts]
|
||||
declare class B {
|
||||
static a: any;
|
||||
static f(): number;
|
||||
a: number;
|
||||
f(): number;
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
static x: any = undefined!;
|
||||
static y1 = this.x;
|
||||
static y2 = this.x();
|
||||
static y3 = this?.x();
|
||||
static y4 = this[("x")]();
|
||||
static y5 = this?.[("x")]();
|
||||
static z3 = super.f();
|
||||
static z4 = super["f"]();
|
||||
|
||||
// these should be unaffected
|
||||
x = 1;
|
||||
y = this.x;
|
||||
z = super.f();
|
||||
}
|
||||
|
||||
//// [thisAndSuperInStaticMembers3.js]
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var C = /** @class */ (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
// these should be unaffected
|
||||
Object.defineProperty(_this, "x", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 1
|
||||
});
|
||||
Object.defineProperty(_this, "y", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _this.x
|
||||
});
|
||||
Object.defineProperty(_this, "z", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _super.prototype.f.call(_this)
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
var _a;
|
||||
_a = C;
|
||||
Object.defineProperty(C, "x", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: undefined
|
||||
});
|
||||
Object.defineProperty(C, "y1", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _a.x
|
||||
});
|
||||
Object.defineProperty(C, "y2", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _a.x()
|
||||
});
|
||||
Object.defineProperty(C, "y3", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _a === null || _a === void 0 ? void 0 : _a.x()
|
||||
});
|
||||
Object.defineProperty(C, "y4", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _a[("x")]()
|
||||
});
|
||||
Object.defineProperty(C, "y5", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _a === null || _a === void 0 ? void 0 : _a[("x")]()
|
||||
});
|
||||
Object.defineProperty(C, "z3", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _super.f.call(_a)
|
||||
});
|
||||
Object.defineProperty(C, "z4", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _super["f"].call(_a)
|
||||
});
|
||||
return C;
|
||||
}(B));
|
||||
@@ -0,0 +1,62 @@
|
||||
//// [thisAndSuperInStaticMembers4.ts]
|
||||
declare class B {
|
||||
static a: any;
|
||||
static f(): number;
|
||||
a: number;
|
||||
f(): number;
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
static x: any = undefined!;
|
||||
static y1 = this.x;
|
||||
static y2 = this.x();
|
||||
static y3 = this?.x();
|
||||
static y4 = this[("x")]();
|
||||
static y5 = this?.[("x")]();
|
||||
static z3 = super.f();
|
||||
static z4 = super["f"]();
|
||||
|
||||
// these should be unaffected
|
||||
x = 1;
|
||||
y = this.x;
|
||||
z = super.f();
|
||||
}
|
||||
|
||||
//// [thisAndSuperInStaticMembers4.js]
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var C = /** @class */ (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
// these should be unaffected
|
||||
_this.x = 1;
|
||||
_this.y = _this.x;
|
||||
_this.z = _super.prototype.f.call(_this);
|
||||
return _this;
|
||||
}
|
||||
var _a;
|
||||
_a = C;
|
||||
C.x = undefined;
|
||||
C.y1 = _a.x;
|
||||
C.y2 = _a.x();
|
||||
C.y3 = _a === null || _a === void 0 ? void 0 : _a.x();
|
||||
C.y4 = _a[("x")]();
|
||||
C.y5 = _a === null || _a === void 0 ? void 0 : _a[("x")]();
|
||||
C.z3 = _super.f.call(_a);
|
||||
C.z4 = _super["f"].call(_a);
|
||||
return C;
|
||||
}(B));
|
||||
@@ -1,14 +0,0 @@
|
||||
tests/cases/compiler/thisInArrowFunctionInStaticInitializer1.ts(6,7): error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
|
||||
|
||||
==== tests/cases/compiler/thisInArrowFunctionInStaticInitializer1.ts (1 errors) ====
|
||||
function log(a) { }
|
||||
|
||||
class Vector {
|
||||
static foo = () => {
|
||||
// 'this' should not be available in a static initializer.
|
||||
log(this);
|
||||
~~~~
|
||||
!!! error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
}
|
||||
}
|
||||
@@ -3,20 +3,21 @@ function log(a) { }
|
||||
|
||||
class Vector {
|
||||
static foo = () => {
|
||||
// 'this' should not be available in a static initializer.
|
||||
// 'this' should be allowed in a static initializer.
|
||||
log(this);
|
||||
}
|
||||
}
|
||||
|
||||
//// [thisInArrowFunctionInStaticInitializer1.js]
|
||||
var _this = this;
|
||||
function log(a) { }
|
||||
var Vector = /** @class */ (function () {
|
||||
function Vector() {
|
||||
}
|
||||
var _a;
|
||||
_a = Vector;
|
||||
Vector.foo = function () {
|
||||
// 'this' should not be available in a static initializer.
|
||||
log(_this);
|
||||
// 'this' should be allowed in a static initializer.
|
||||
log(_a);
|
||||
};
|
||||
return Vector;
|
||||
}());
|
||||
|
||||
@@ -9,7 +9,7 @@ class Vector {
|
||||
static foo = () => {
|
||||
>foo : Symbol(Vector.foo, Decl(thisInArrowFunctionInStaticInitializer1.ts, 2, 14))
|
||||
|
||||
// 'this' should not be available in a static initializer.
|
||||
// 'this' should be allowed in a static initializer.
|
||||
log(this);
|
||||
>log : Symbol(log, Decl(thisInArrowFunctionInStaticInitializer1.ts, 0, 0))
|
||||
>this : Symbol(Vector, Decl(thisInArrowFunctionInStaticInitializer1.ts, 0, 19))
|
||||
|
||||
@@ -8,9 +8,9 @@ class Vector {
|
||||
|
||||
static foo = () => {
|
||||
>foo : () => void
|
||||
>() => { // 'this' should not be available in a static initializer. log(this); } : () => void
|
||||
>() => { // 'this' should be allowed in a static initializer. log(this); } : () => void
|
||||
|
||||
// 'this' should not be available in a static initializer.
|
||||
// 'this' should be allowed in a static initializer.
|
||||
log(this);
|
||||
>log(this) : void
|
||||
>log : (a: any) => void
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
tests/cases/compiler/thisInConstructorParameter2.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
tests/cases/compiler/thisInConstructorParameter2.ts(5,28): error TS2333: 'this' cannot be referenced in constructor arguments.
|
||||
tests/cases/compiler/thisInConstructorParameter2.ts(5,39): error TS2333: 'this' cannot be referenced in constructor arguments.
|
||||
|
||||
|
||||
==== tests/cases/compiler/thisInConstructorParameter2.ts (3 errors) ====
|
||||
==== tests/cases/compiler/thisInConstructorParameter2.ts (2 errors) ====
|
||||
class P {
|
||||
x = this;
|
||||
static y = this;
|
||||
~~~~
|
||||
!!! error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
|
||||
constructor(public z = this, zz = this, zzz = (p = this) => this) {
|
||||
~~~~
|
||||
|
||||
@@ -36,6 +36,8 @@ var P = /** @class */ (function () {
|
||||
if (zz === void 0) { zz = this; }
|
||||
zz.y;
|
||||
};
|
||||
P.y = this;
|
||||
var _a;
|
||||
_a = P;
|
||||
P.y = _a;
|
||||
return P;
|
||||
}());
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(14,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(22,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(36,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,25): error TS2507: Type 'typeof globalThis' is not a constructor function type.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(44,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(9,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(17,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(23,13): error TS2331: 'this' cannot be referenced in a module or namespace body.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(31,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(33,25): error TS2507: Type 'typeof globalThis' is not a constructor function type.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(39,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(40,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts (8 errors) ====
|
||||
//'this' in static member initializer
|
||||
class ErrClass1 {
|
||||
static t = this; // Error
|
||||
~~~~
|
||||
!!! error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
}
|
||||
|
||||
==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts (7 errors) ====
|
||||
class BaseErrClass {
|
||||
constructor(t: any) { }
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
//// [thisInInvalidContexts.ts]
|
||||
//'this' in static member initializer
|
||||
class ErrClass1 {
|
||||
static t = this; // Error
|
||||
}
|
||||
|
||||
class BaseErrClass {
|
||||
constructor(t: any) { }
|
||||
}
|
||||
@@ -64,13 +59,6 @@ var __extends = (this && this.__extends) || (function () {
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
//'this' in static member initializer
|
||||
var ErrClass1 = /** @class */ (function () {
|
||||
function ErrClass1() {
|
||||
}
|
||||
ErrClass1.t = this; // Error
|
||||
return ErrClass1;
|
||||
}());
|
||||
var BaseErrClass = /** @class */ (function () {
|
||||
function BaseErrClass(t) {
|
||||
}
|
||||
|
||||
@@ -1,56 +1,47 @@
|
||||
=== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts ===
|
||||
//'this' in static member initializer
|
||||
class ErrClass1 {
|
||||
>ErrClass1 : Symbol(ErrClass1, Decl(thisInInvalidContexts.ts, 0, 0))
|
||||
|
||||
static t = this; // Error
|
||||
>t : Symbol(ErrClass1.t, Decl(thisInInvalidContexts.ts, 1, 17))
|
||||
>this : Symbol(ErrClass1, Decl(thisInInvalidContexts.ts, 0, 0))
|
||||
}
|
||||
|
||||
class BaseErrClass {
|
||||
>BaseErrClass : Symbol(BaseErrClass, Decl(thisInInvalidContexts.ts, 3, 1))
|
||||
>BaseErrClass : Symbol(BaseErrClass, Decl(thisInInvalidContexts.ts, 0, 0))
|
||||
|
||||
constructor(t: any) { }
|
||||
>t : Symbol(t, Decl(thisInInvalidContexts.ts, 6, 16))
|
||||
>t : Symbol(t, Decl(thisInInvalidContexts.ts, 1, 16))
|
||||
}
|
||||
|
||||
class ClassWithNoInitializer extends BaseErrClass {
|
||||
>ClassWithNoInitializer : Symbol(ClassWithNoInitializer, Decl(thisInInvalidContexts.ts, 7, 1))
|
||||
>BaseErrClass : Symbol(BaseErrClass, Decl(thisInInvalidContexts.ts, 3, 1))
|
||||
>ClassWithNoInitializer : Symbol(ClassWithNoInitializer, Decl(thisInInvalidContexts.ts, 2, 1))
|
||||
>BaseErrClass : Symbol(BaseErrClass, Decl(thisInInvalidContexts.ts, 0, 0))
|
||||
|
||||
t;
|
||||
>t : Symbol(ClassWithNoInitializer.t, Decl(thisInInvalidContexts.ts, 9, 51))
|
||||
>t : Symbol(ClassWithNoInitializer.t, Decl(thisInInvalidContexts.ts, 4, 51))
|
||||
|
||||
//'this' in optional super call
|
||||
constructor() {
|
||||
super(this); // Error
|
||||
>super : Symbol(BaseErrClass, Decl(thisInInvalidContexts.ts, 3, 1))
|
||||
>this : Symbol(ClassWithNoInitializer, Decl(thisInInvalidContexts.ts, 7, 1))
|
||||
>super : Symbol(BaseErrClass, Decl(thisInInvalidContexts.ts, 0, 0))
|
||||
>this : Symbol(ClassWithNoInitializer, Decl(thisInInvalidContexts.ts, 2, 1))
|
||||
}
|
||||
}
|
||||
|
||||
class ClassWithInitializer extends BaseErrClass {
|
||||
>ClassWithInitializer : Symbol(ClassWithInitializer, Decl(thisInInvalidContexts.ts, 15, 1))
|
||||
>BaseErrClass : Symbol(BaseErrClass, Decl(thisInInvalidContexts.ts, 3, 1))
|
||||
>ClassWithInitializer : Symbol(ClassWithInitializer, Decl(thisInInvalidContexts.ts, 10, 1))
|
||||
>BaseErrClass : Symbol(BaseErrClass, Decl(thisInInvalidContexts.ts, 0, 0))
|
||||
|
||||
t = 4;
|
||||
>t : Symbol(ClassWithInitializer.t, Decl(thisInInvalidContexts.ts, 17, 49))
|
||||
>t : Symbol(ClassWithInitializer.t, Decl(thisInInvalidContexts.ts, 12, 49))
|
||||
|
||||
//'this' in required super call
|
||||
constructor() {
|
||||
super(this); // Error
|
||||
>super : Symbol(BaseErrClass, Decl(thisInInvalidContexts.ts, 3, 1))
|
||||
>this : Symbol(ClassWithInitializer, Decl(thisInInvalidContexts.ts, 15, 1))
|
||||
>super : Symbol(BaseErrClass, Decl(thisInInvalidContexts.ts, 0, 0))
|
||||
>this : Symbol(ClassWithInitializer, Decl(thisInInvalidContexts.ts, 10, 1))
|
||||
}
|
||||
}
|
||||
|
||||
module M {
|
||||
>M : Symbol(M, Decl(thisInInvalidContexts.ts, 23, 1))
|
||||
>M : Symbol(M, Decl(thisInInvalidContexts.ts, 18, 1))
|
||||
|
||||
//'this' in module variable
|
||||
var x = this; // Error
|
||||
>x : Symbol(x, Decl(thisInInvalidContexts.ts, 27, 7))
|
||||
>x : Symbol(x, Decl(thisInInvalidContexts.ts, 22, 7))
|
||||
}
|
||||
|
||||
//'this' as type parameter constraint
|
||||
@@ -58,30 +49,30 @@ module M {
|
||||
|
||||
//'this' as a type argument
|
||||
function genericFunc<T>(x: T) { }
|
||||
>genericFunc : Symbol(genericFunc, Decl(thisInInvalidContexts.ts, 28, 1))
|
||||
>T : Symbol(T, Decl(thisInInvalidContexts.ts, 34, 21))
|
||||
>x : Symbol(x, Decl(thisInInvalidContexts.ts, 34, 24))
|
||||
>T : Symbol(T, Decl(thisInInvalidContexts.ts, 34, 21))
|
||||
>genericFunc : Symbol(genericFunc, Decl(thisInInvalidContexts.ts, 23, 1))
|
||||
>T : Symbol(T, Decl(thisInInvalidContexts.ts, 29, 21))
|
||||
>x : Symbol(x, Decl(thisInInvalidContexts.ts, 29, 24))
|
||||
>T : Symbol(T, Decl(thisInInvalidContexts.ts, 29, 21))
|
||||
|
||||
genericFunc<this>(undefined); // Should be an error
|
||||
>genericFunc : Symbol(genericFunc, Decl(thisInInvalidContexts.ts, 28, 1))
|
||||
>genericFunc : Symbol(genericFunc, Decl(thisInInvalidContexts.ts, 23, 1))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
class ErrClass3 extends this {
|
||||
>ErrClass3 : Symbol(ErrClass3, Decl(thisInInvalidContexts.ts, 35, 29))
|
||||
>ErrClass3 : Symbol(ErrClass3, Decl(thisInInvalidContexts.ts, 30, 29))
|
||||
>this : Symbol(globalThis)
|
||||
|
||||
}
|
||||
|
||||
//'this' as a computed enum value
|
||||
enum SomeEnum {
|
||||
>SomeEnum : Symbol(SomeEnum, Decl(thisInInvalidContexts.ts, 39, 1))
|
||||
>SomeEnum : Symbol(SomeEnum, Decl(thisInInvalidContexts.ts, 34, 1))
|
||||
|
||||
A = this, // Should not be allowed
|
||||
>A : Symbol(SomeEnum.A, Decl(thisInInvalidContexts.ts, 42, 15))
|
||||
>A : Symbol(SomeEnum.A, Decl(thisInInvalidContexts.ts, 37, 15))
|
||||
|
||||
B = this.spaaaace // Also should not be allowed
|
||||
>B : Symbol(SomeEnum.B, Decl(thisInInvalidContexts.ts, 43, 13))
|
||||
>B : Symbol(SomeEnum.B, Decl(thisInInvalidContexts.ts, 38, 13))
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
=== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts ===
|
||||
//'this' in static member initializer
|
||||
class ErrClass1 {
|
||||
>ErrClass1 : ErrClass1
|
||||
|
||||
static t = this; // Error
|
||||
>t : typeof ErrClass1
|
||||
>this : typeof ErrClass1
|
||||
}
|
||||
|
||||
class BaseErrClass {
|
||||
>BaseErrClass : BaseErrClass
|
||||
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(14,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(22,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(36,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS2507: Type 'undefined' is not a constructor function type.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(44,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(45,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(9,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(17,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(23,13): error TS2331: 'this' cannot be referenced in a module or namespace body.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(31,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(33,25): error TS2507: Type 'undefined' is not a constructor function type.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(39,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(40,9): error TS2332: 'this' cannot be referenced in current location.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts (8 errors) ====
|
||||
//'this' in static member initializer
|
||||
class ErrClass1 {
|
||||
static t = this; // Error
|
||||
~~~~
|
||||
!!! error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
}
|
||||
|
||||
==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts (7 errors) ====
|
||||
class BaseErrClass {
|
||||
constructor(t: any) { }
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
//// [thisInInvalidContextsExternalModule.ts]
|
||||
//'this' in static member initializer
|
||||
class ErrClass1 {
|
||||
static t = this; // Error
|
||||
}
|
||||
|
||||
class BaseErrClass {
|
||||
constructor(t: any) { }
|
||||
}
|
||||
@@ -65,13 +60,6 @@ var __extends = (this && this.__extends) || (function () {
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
//'this' in static member initializer
|
||||
var ErrClass1 = /** @class */ (function () {
|
||||
function ErrClass1() {
|
||||
}
|
||||
ErrClass1.t = this; // Error
|
||||
return ErrClass1;
|
||||
}());
|
||||
var BaseErrClass = /** @class */ (function () {
|
||||
function BaseErrClass(t) {
|
||||
}
|
||||
|
||||
@@ -1,56 +1,47 @@
|
||||
=== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts ===
|
||||
//'this' in static member initializer
|
||||
class ErrClass1 {
|
||||
>ErrClass1 : Symbol(ErrClass1, Decl(thisInInvalidContextsExternalModule.ts, 0, 0))
|
||||
|
||||
static t = this; // Error
|
||||
>t : Symbol(ErrClass1.t, Decl(thisInInvalidContextsExternalModule.ts, 1, 17))
|
||||
>this : Symbol(ErrClass1, Decl(thisInInvalidContextsExternalModule.ts, 0, 0))
|
||||
}
|
||||
|
||||
class BaseErrClass {
|
||||
>BaseErrClass : Symbol(BaseErrClass, Decl(thisInInvalidContextsExternalModule.ts, 3, 1))
|
||||
>BaseErrClass : Symbol(BaseErrClass, Decl(thisInInvalidContextsExternalModule.ts, 0, 0))
|
||||
|
||||
constructor(t: any) { }
|
||||
>t : Symbol(t, Decl(thisInInvalidContextsExternalModule.ts, 6, 16))
|
||||
>t : Symbol(t, Decl(thisInInvalidContextsExternalModule.ts, 1, 16))
|
||||
}
|
||||
|
||||
class ClassWithNoInitializer extends BaseErrClass {
|
||||
>ClassWithNoInitializer : Symbol(ClassWithNoInitializer, Decl(thisInInvalidContextsExternalModule.ts, 7, 1))
|
||||
>BaseErrClass : Symbol(BaseErrClass, Decl(thisInInvalidContextsExternalModule.ts, 3, 1))
|
||||
>ClassWithNoInitializer : Symbol(ClassWithNoInitializer, Decl(thisInInvalidContextsExternalModule.ts, 2, 1))
|
||||
>BaseErrClass : Symbol(BaseErrClass, Decl(thisInInvalidContextsExternalModule.ts, 0, 0))
|
||||
|
||||
t;
|
||||
>t : Symbol(ClassWithNoInitializer.t, Decl(thisInInvalidContextsExternalModule.ts, 9, 51))
|
||||
>t : Symbol(ClassWithNoInitializer.t, Decl(thisInInvalidContextsExternalModule.ts, 4, 51))
|
||||
|
||||
//'this' in optional super call
|
||||
constructor() {
|
||||
super(this); // error: "super" has to be called before "this" accessing
|
||||
>super : Symbol(BaseErrClass, Decl(thisInInvalidContextsExternalModule.ts, 3, 1))
|
||||
>this : Symbol(ClassWithNoInitializer, Decl(thisInInvalidContextsExternalModule.ts, 7, 1))
|
||||
>super : Symbol(BaseErrClass, Decl(thisInInvalidContextsExternalModule.ts, 0, 0))
|
||||
>this : Symbol(ClassWithNoInitializer, Decl(thisInInvalidContextsExternalModule.ts, 2, 1))
|
||||
}
|
||||
}
|
||||
|
||||
class ClassWithInitializer extends BaseErrClass {
|
||||
>ClassWithInitializer : Symbol(ClassWithInitializer, Decl(thisInInvalidContextsExternalModule.ts, 15, 1))
|
||||
>BaseErrClass : Symbol(BaseErrClass, Decl(thisInInvalidContextsExternalModule.ts, 3, 1))
|
||||
>ClassWithInitializer : Symbol(ClassWithInitializer, Decl(thisInInvalidContextsExternalModule.ts, 10, 1))
|
||||
>BaseErrClass : Symbol(BaseErrClass, Decl(thisInInvalidContextsExternalModule.ts, 0, 0))
|
||||
|
||||
t = 4;
|
||||
>t : Symbol(ClassWithInitializer.t, Decl(thisInInvalidContextsExternalModule.ts, 17, 49))
|
||||
>t : Symbol(ClassWithInitializer.t, Decl(thisInInvalidContextsExternalModule.ts, 12, 49))
|
||||
|
||||
//'this' in required super call
|
||||
constructor() {
|
||||
super(this); // Error
|
||||
>super : Symbol(BaseErrClass, Decl(thisInInvalidContextsExternalModule.ts, 3, 1))
|
||||
>this : Symbol(ClassWithInitializer, Decl(thisInInvalidContextsExternalModule.ts, 15, 1))
|
||||
>super : Symbol(BaseErrClass, Decl(thisInInvalidContextsExternalModule.ts, 0, 0))
|
||||
>this : Symbol(ClassWithInitializer, Decl(thisInInvalidContextsExternalModule.ts, 10, 1))
|
||||
}
|
||||
}
|
||||
|
||||
module M {
|
||||
>M : Symbol(M, Decl(thisInInvalidContextsExternalModule.ts, 23, 1))
|
||||
>M : Symbol(M, Decl(thisInInvalidContextsExternalModule.ts, 18, 1))
|
||||
|
||||
//'this' in module variable
|
||||
var x = this; // Error
|
||||
>x : Symbol(x, Decl(thisInInvalidContextsExternalModule.ts, 27, 7))
|
||||
>x : Symbol(x, Decl(thisInInvalidContextsExternalModule.ts, 22, 7))
|
||||
}
|
||||
|
||||
//'this' as type parameter constraint
|
||||
@@ -58,29 +49,29 @@ module M {
|
||||
|
||||
//'this' as a type argument
|
||||
function genericFunc<T>(x: T) { }
|
||||
>genericFunc : Symbol(genericFunc, Decl(thisInInvalidContextsExternalModule.ts, 28, 1))
|
||||
>T : Symbol(T, Decl(thisInInvalidContextsExternalModule.ts, 34, 21))
|
||||
>x : Symbol(x, Decl(thisInInvalidContextsExternalModule.ts, 34, 24))
|
||||
>T : Symbol(T, Decl(thisInInvalidContextsExternalModule.ts, 34, 21))
|
||||
>genericFunc : Symbol(genericFunc, Decl(thisInInvalidContextsExternalModule.ts, 23, 1))
|
||||
>T : Symbol(T, Decl(thisInInvalidContextsExternalModule.ts, 29, 21))
|
||||
>x : Symbol(x, Decl(thisInInvalidContextsExternalModule.ts, 29, 24))
|
||||
>T : Symbol(T, Decl(thisInInvalidContextsExternalModule.ts, 29, 21))
|
||||
|
||||
genericFunc<this>(undefined); // Should be an error
|
||||
>genericFunc : Symbol(genericFunc, Decl(thisInInvalidContextsExternalModule.ts, 28, 1))
|
||||
>genericFunc : Symbol(genericFunc, Decl(thisInInvalidContextsExternalModule.ts, 23, 1))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
class ErrClass3 extends this {
|
||||
>ErrClass3 : Symbol(ErrClass3, Decl(thisInInvalidContextsExternalModule.ts, 35, 29))
|
||||
>ErrClass3 : Symbol(ErrClass3, Decl(thisInInvalidContextsExternalModule.ts, 30, 29))
|
||||
|
||||
}
|
||||
|
||||
//'this' as a computed enum value
|
||||
enum SomeEnum {
|
||||
>SomeEnum : Symbol(SomeEnum, Decl(thisInInvalidContextsExternalModule.ts, 39, 1))
|
||||
>SomeEnum : Symbol(SomeEnum, Decl(thisInInvalidContextsExternalModule.ts, 34, 1))
|
||||
|
||||
A = this, // Should not be allowed
|
||||
>A : Symbol(SomeEnum.A, Decl(thisInInvalidContextsExternalModule.ts, 42, 15))
|
||||
>A : Symbol(SomeEnum.A, Decl(thisInInvalidContextsExternalModule.ts, 37, 15))
|
||||
|
||||
B = this.spaaaace // Also should not be allowed
|
||||
>B : Symbol(SomeEnum.B, Decl(thisInInvalidContextsExternalModule.ts, 43, 13))
|
||||
>B : Symbol(SomeEnum.B, Decl(thisInInvalidContextsExternalModule.ts, 38, 13))
|
||||
}
|
||||
|
||||
export = this; // Should be an error
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
=== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts ===
|
||||
//'this' in static member initializer
|
||||
class ErrClass1 {
|
||||
>ErrClass1 : ErrClass1
|
||||
|
||||
static t = this; // Error
|
||||
>t : typeof ErrClass1
|
||||
>this : typeof ErrClass1
|
||||
}
|
||||
|
||||
class BaseErrClass {
|
||||
>BaseErrClass : BaseErrClass
|
||||
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
tests/cases/compiler/thisInOuterClassBody.ts(5,16): error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
tests/cases/compiler/thisInOuterClassBody.ts(12,22): error TS2576: Property 'y' does not exist on type 'Foo'. Did you mean to access the static member 'Foo.y' instead?
|
||||
tests/cases/compiler/thisInOuterClassBody.ts(18,22): error TS2339: Property 'x' does not exist on type 'typeof Foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/thisInOuterClassBody.ts (3 errors) ====
|
||||
==== tests/cases/compiler/thisInOuterClassBody.ts (2 errors) ====
|
||||
class Foo {
|
||||
|
||||
x = this;
|
||||
|
||||
static y = this;
|
||||
~~~~
|
||||
!!! error TS2334: 'this' cannot be referenced in a static property initializer.
|
||||
|
||||
bar() {
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ var Foo = /** @class */ (function () {
|
||||
var a = this.y;
|
||||
var b = this.x;
|
||||
};
|
||||
Foo.y = this;
|
||||
var _a;
|
||||
_a = Foo;
|
||||
Foo.y = _a;
|
||||
return Foo;
|
||||
}());
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(6,16): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(12,16): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(13,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(13,26): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(14,22): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(35,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts (6 errors) ====
|
||||
declare const foo: any;
|
||||
|
||||
@foo
|
||||
class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
}
|
||||
|
||||
@foo
|
||||
class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static e = super.a + this.c + 1;
|
||||
~
|
||||
!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static f = () => this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
~
|
||||
!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
//// [typeOfThisInStaticMembers10.ts]
|
||||
declare const foo: any;
|
||||
|
||||
@foo
|
||||
class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
@foo
|
||||
class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [typeOfThisInStaticMembers10.js]
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var C = /** @class */ (function () {
|
||||
function C() {
|
||||
}
|
||||
C.a = 1;
|
||||
C.b = (void 0).a + 1;
|
||||
C = __decorate([
|
||||
foo
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
var D = /** @class */ (function (_super) {
|
||||
__extends(D, _super);
|
||||
function D() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
D.foo = function () {
|
||||
return this.c + 1;
|
||||
};
|
||||
Object.defineProperty(D, "fa", {
|
||||
get: function () {
|
||||
return this.c + 1;
|
||||
},
|
||||
set: function (v) {
|
||||
this.c = v + 1;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
D.c = 2;
|
||||
D.d = (void 0).c + 1;
|
||||
D.e = _super.a + (void 0).c + 1;
|
||||
D.f = function () { return (void 0).c + 1; };
|
||||
D.ff = function () { this.c + 1; };
|
||||
D = __decorate([
|
||||
foo
|
||||
], D);
|
||||
return D;
|
||||
}(C));
|
||||
var CC = /** @class */ (function () {
|
||||
function CC() {
|
||||
}
|
||||
var _a;
|
||||
_a = CC;
|
||||
CC.a = 1;
|
||||
CC.b = _a.a + 1;
|
||||
return CC;
|
||||
}());
|
||||
var DD = /** @class */ (function (_super) {
|
||||
__extends(DD, _super);
|
||||
function DD() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
DD.foo = function () {
|
||||
return this.c + 1;
|
||||
};
|
||||
Object.defineProperty(DD, "fa", {
|
||||
get: function () {
|
||||
return this.c + 1;
|
||||
},
|
||||
set: function (v) {
|
||||
this.c = v + 1;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
var _b;
|
||||
_b = DD;
|
||||
DD.c = 2;
|
||||
DD.d = _b.c + 1;
|
||||
DD.e = _super.a + _b.c + 1;
|
||||
DD.f = function () { return _b.c + 1; };
|
||||
DD.ff = function () { this.c + 1; };
|
||||
return DD;
|
||||
}(CC));
|
||||
@@ -0,0 +1,154 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts ===
|
||||
declare const foo: any;
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers10.ts, 0, 13))
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers10.ts, 0, 13))
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers10.ts, 0, 23))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : Symbol(C.b, Decl(typeOfThisInStaticMembers10.ts, 4, 17))
|
||||
>this.a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
>this : Symbol(C, Decl(typeOfThisInStaticMembers10.ts, 0, 23))
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
}
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers10.ts, 0, 13))
|
||||
|
||||
class D extends C {
|
||||
>D : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers10.ts, 0, 23))
|
||||
|
||||
static c = 2;
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : Symbol(D.d, Decl(typeOfThisInStaticMembers10.ts, 10, 17))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : Symbol(D.e, Decl(typeOfThisInStaticMembers10.ts, 11, 26))
|
||||
>super.a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
>super : Symbol(C, Decl(typeOfThisInStaticMembers10.ts, 0, 23))
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : Symbol(D.f, Decl(typeOfThisInStaticMembers10.ts, 12, 36))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : Symbol(D.ff, Decl(typeOfThisInStaticMembers10.ts, 13, 32))
|
||||
|
||||
static foo () {
|
||||
>foo : Symbol(D.foo, Decl(typeOfThisInStaticMembers10.ts, 14, 42))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
}
|
||||
static get fa () {
|
||||
>fa : Symbol(D.fa, Decl(typeOfThisInStaticMembers10.ts, 17, 5), Decl(typeOfThisInStaticMembers10.ts, 20, 5))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : Symbol(D.fa, Decl(typeOfThisInStaticMembers10.ts, 17, 5), Decl(typeOfThisInStaticMembers10.ts, 20, 5))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers10.ts, 21, 19))
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers10.ts, 21, 19))
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
>CC : Symbol(CC, Decl(typeOfThisInStaticMembers10.ts, 24, 1))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : Symbol(CC.b, Decl(typeOfThisInStaticMembers10.ts, 27, 17))
|
||||
>this.a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
>this : Symbol(CC, Decl(typeOfThisInStaticMembers10.ts, 24, 1))
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
>DD : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>CC : Symbol(CC, Decl(typeOfThisInStaticMembers10.ts, 24, 1))
|
||||
|
||||
static c = 2;
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : Symbol(DD.d, Decl(typeOfThisInStaticMembers10.ts, 32, 17))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : Symbol(DD.e, Decl(typeOfThisInStaticMembers10.ts, 33, 26))
|
||||
>super.a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
>super : Symbol(CC, Decl(typeOfThisInStaticMembers10.ts, 24, 1))
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : Symbol(DD.f, Decl(typeOfThisInStaticMembers10.ts, 34, 36))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : Symbol(DD.ff, Decl(typeOfThisInStaticMembers10.ts, 35, 32))
|
||||
|
||||
static foo () {
|
||||
>foo : Symbol(DD.foo, Decl(typeOfThisInStaticMembers10.ts, 36, 42))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
}
|
||||
static get fa () {
|
||||
>fa : Symbol(DD.fa, Decl(typeOfThisInStaticMembers10.ts, 39, 5), Decl(typeOfThisInStaticMembers10.ts, 42, 5))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : Symbol(DD.fa, Decl(typeOfThisInStaticMembers10.ts, 39, 5), Decl(typeOfThisInStaticMembers10.ts, 42, 5))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers10.ts, 43, 19))
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers10.ts, 43, 19))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts ===
|
||||
declare const foo: any;
|
||||
>foo : any
|
||||
|
||||
@foo
|
||||
>foo : any
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : number
|
||||
>this.a + 1 : number
|
||||
>this.a : number
|
||||
>this : typeof C
|
||||
>a : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
@foo
|
||||
>foo : any
|
||||
|
||||
class D extends C {
|
||||
>D : D
|
||||
>C : C
|
||||
|
||||
static c = 2;
|
||||
>c : number
|
||||
>2 : 2
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : number
|
||||
>super.a + this.c + 1 : number
|
||||
>super.a + this.c : number
|
||||
>super.a : number
|
||||
>super : typeof C
|
||||
>a : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : () => number
|
||||
>() => this.c + 1 : () => number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : () => void
|
||||
>function () { this.c + 1 } : () => void
|
||||
>this.c + 1 : any
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>1 : 1
|
||||
|
||||
static foo () {
|
||||
>foo : () => number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static get fa () {
|
||||
>fa : number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : number
|
||||
>v : number
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c = v + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>v + 1 : number
|
||||
>v : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
>CC : CC
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : number
|
||||
>this.a + 1 : number
|
||||
>this.a : number
|
||||
>this : typeof CC
|
||||
>a : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
>DD : DD
|
||||
>CC : CC
|
||||
|
||||
static c = 2;
|
||||
>c : number
|
||||
>2 : 2
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : number
|
||||
>super.a + this.c + 1 : number
|
||||
>super.a + this.c : number
|
||||
>super.a : number
|
||||
>super : typeof CC
|
||||
>a : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : () => number
|
||||
>() => this.c + 1 : () => number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : () => void
|
||||
>function () { this.c + 1 } : () => void
|
||||
>this.c + 1 : any
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>1 : 1
|
||||
|
||||
static foo () {
|
||||
>foo : () => number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static get fa () {
|
||||
>fa : number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : number
|
||||
>v : number
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c = v + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>v + 1 : number
|
||||
>v : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(6,16): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(12,16): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(13,26): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(14,22): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts (4 errors) ====
|
||||
declare const foo: any;
|
||||
|
||||
@foo
|
||||
class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
}
|
||||
|
||||
@foo
|
||||
class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static e = super.a + this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static f = () => this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
//// [typeOfThisInStaticMembers10.ts]
|
||||
declare const foo: any;
|
||||
|
||||
@foo
|
||||
class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
@foo
|
||||
class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [typeOfThisInStaticMembers10.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var _a, _b, _c;
|
||||
let C = class C {
|
||||
};
|
||||
C.a = 1;
|
||||
C.b = (void 0).a + 1;
|
||||
C = __decorate([
|
||||
foo
|
||||
], C);
|
||||
let D = class D extends C {
|
||||
static foo() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa(v) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
};
|
||||
D.c = 2;
|
||||
D.d = (void 0).c + 1;
|
||||
D.e = (void 0).a + (void 0).c + 1;
|
||||
D.f = () => (void 0).c + 1;
|
||||
D.ff = function () { this.c + 1; };
|
||||
D = __decorate([
|
||||
foo
|
||||
], D);
|
||||
class CC {
|
||||
}
|
||||
_a = CC;
|
||||
CC.a = 1;
|
||||
CC.b = _a.a + 1;
|
||||
class DD extends (_c = CC) {
|
||||
static foo() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa(v) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
_b = DD;
|
||||
DD.c = 2;
|
||||
DD.d = _b.c + 1;
|
||||
DD.e = Reflect.get(_c, "a", _b) + _b.c + 1;
|
||||
DD.f = () => _b.c + 1;
|
||||
DD.ff = function () { this.c + 1; };
|
||||
@@ -0,0 +1,154 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts ===
|
||||
declare const foo: any;
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers10.ts, 0, 13))
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers10.ts, 0, 13))
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers10.ts, 0, 23))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : Symbol(C.b, Decl(typeOfThisInStaticMembers10.ts, 4, 17))
|
||||
>this.a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
>this : Symbol(C, Decl(typeOfThisInStaticMembers10.ts, 0, 23))
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
}
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers10.ts, 0, 13))
|
||||
|
||||
class D extends C {
|
||||
>D : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers10.ts, 0, 23))
|
||||
|
||||
static c = 2;
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : Symbol(D.d, Decl(typeOfThisInStaticMembers10.ts, 10, 17))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : Symbol(D.e, Decl(typeOfThisInStaticMembers10.ts, 11, 26))
|
||||
>super.a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
>super : Symbol(C, Decl(typeOfThisInStaticMembers10.ts, 0, 23))
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : Symbol(D.f, Decl(typeOfThisInStaticMembers10.ts, 12, 36))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : Symbol(D.ff, Decl(typeOfThisInStaticMembers10.ts, 13, 32))
|
||||
|
||||
static foo () {
|
||||
>foo : Symbol(D.foo, Decl(typeOfThisInStaticMembers10.ts, 14, 42))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
}
|
||||
static get fa () {
|
||||
>fa : Symbol(D.fa, Decl(typeOfThisInStaticMembers10.ts, 17, 5), Decl(typeOfThisInStaticMembers10.ts, 20, 5))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : Symbol(D.fa, Decl(typeOfThisInStaticMembers10.ts, 17, 5), Decl(typeOfThisInStaticMembers10.ts, 20, 5))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers10.ts, 21, 19))
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers10.ts, 21, 19))
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
>CC : Symbol(CC, Decl(typeOfThisInStaticMembers10.ts, 24, 1))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : Symbol(CC.b, Decl(typeOfThisInStaticMembers10.ts, 27, 17))
|
||||
>this.a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
>this : Symbol(CC, Decl(typeOfThisInStaticMembers10.ts, 24, 1))
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
>DD : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>CC : Symbol(CC, Decl(typeOfThisInStaticMembers10.ts, 24, 1))
|
||||
|
||||
static c = 2;
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : Symbol(DD.d, Decl(typeOfThisInStaticMembers10.ts, 32, 17))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : Symbol(DD.e, Decl(typeOfThisInStaticMembers10.ts, 33, 26))
|
||||
>super.a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
>super : Symbol(CC, Decl(typeOfThisInStaticMembers10.ts, 24, 1))
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : Symbol(DD.f, Decl(typeOfThisInStaticMembers10.ts, 34, 36))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : Symbol(DD.ff, Decl(typeOfThisInStaticMembers10.ts, 35, 32))
|
||||
|
||||
static foo () {
|
||||
>foo : Symbol(DD.foo, Decl(typeOfThisInStaticMembers10.ts, 36, 42))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
}
|
||||
static get fa () {
|
||||
>fa : Symbol(DD.fa, Decl(typeOfThisInStaticMembers10.ts, 39, 5), Decl(typeOfThisInStaticMembers10.ts, 42, 5))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : Symbol(DD.fa, Decl(typeOfThisInStaticMembers10.ts, 39, 5), Decl(typeOfThisInStaticMembers10.ts, 42, 5))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers10.ts, 43, 19))
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers10.ts, 43, 19))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts ===
|
||||
declare const foo: any;
|
||||
>foo : any
|
||||
|
||||
@foo
|
||||
>foo : any
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : number
|
||||
>this.a + 1 : number
|
||||
>this.a : number
|
||||
>this : typeof C
|
||||
>a : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
@foo
|
||||
>foo : any
|
||||
|
||||
class D extends C {
|
||||
>D : D
|
||||
>C : C
|
||||
|
||||
static c = 2;
|
||||
>c : number
|
||||
>2 : 2
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : number
|
||||
>super.a + this.c + 1 : number
|
||||
>super.a + this.c : number
|
||||
>super.a : number
|
||||
>super : typeof C
|
||||
>a : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : () => number
|
||||
>() => this.c + 1 : () => number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : () => void
|
||||
>function () { this.c + 1 } : () => void
|
||||
>this.c + 1 : any
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>1 : 1
|
||||
|
||||
static foo () {
|
||||
>foo : () => number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static get fa () {
|
||||
>fa : number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : number
|
||||
>v : number
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c = v + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>v + 1 : number
|
||||
>v : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
>CC : CC
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : number
|
||||
>this.a + 1 : number
|
||||
>this.a : number
|
||||
>this : typeof CC
|
||||
>a : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
>DD : DD
|
||||
>CC : CC
|
||||
|
||||
static c = 2;
|
||||
>c : number
|
||||
>2 : 2
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : number
|
||||
>super.a + this.c + 1 : number
|
||||
>super.a + this.c : number
|
||||
>super.a : number
|
||||
>super : typeof CC
|
||||
>a : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : () => number
|
||||
>() => this.c + 1 : () => number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : () => void
|
||||
>function () { this.c + 1 } : () => void
|
||||
>this.c + 1 : any
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>1 : 1
|
||||
|
||||
static foo () {
|
||||
>foo : () => number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static get fa () {
|
||||
>fa : number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : number
|
||||
>v : number
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c = v + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>v + 1 : number
|
||||
>v : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(6,16): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(12,16): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(13,26): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts(14,22): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts (4 errors) ====
|
||||
declare const foo: any;
|
||||
|
||||
@foo
|
||||
class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
}
|
||||
|
||||
@foo
|
||||
class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static e = super.a + this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static f = () => this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
//// [typeOfThisInStaticMembers10.ts]
|
||||
declare const foo: any;
|
||||
|
||||
@foo
|
||||
class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
@foo
|
||||
class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [typeOfThisInStaticMembers10.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var _a, _b, _c;
|
||||
let C = class C {
|
||||
};
|
||||
C.a = 1;
|
||||
C.b = (void 0).a + 1;
|
||||
C = __decorate([
|
||||
foo
|
||||
], C);
|
||||
let D = class D extends C {
|
||||
static foo() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa(v) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
};
|
||||
D.c = 2;
|
||||
D.d = (void 0).c + 1;
|
||||
D.e = (void 0).a + (void 0).c + 1;
|
||||
D.f = () => (void 0).c + 1;
|
||||
D.ff = function () { this.c + 1; };
|
||||
D = __decorate([
|
||||
foo
|
||||
], D);
|
||||
class CC {
|
||||
}
|
||||
_a = CC;
|
||||
CC.a = 1;
|
||||
CC.b = _a.a + 1;
|
||||
class DD extends (_c = CC) {
|
||||
static foo() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa(v) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
_b = DD;
|
||||
DD.c = 2;
|
||||
DD.d = _b.c + 1;
|
||||
DD.e = Reflect.get(_c, "a", _b) + _b.c + 1;
|
||||
DD.f = () => _b.c + 1;
|
||||
DD.ff = function () { this.c + 1; };
|
||||
@@ -0,0 +1,154 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts ===
|
||||
declare const foo: any;
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers10.ts, 0, 13))
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers10.ts, 0, 13))
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers10.ts, 0, 23))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : Symbol(C.b, Decl(typeOfThisInStaticMembers10.ts, 4, 17))
|
||||
>this.a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
>this : Symbol(C, Decl(typeOfThisInStaticMembers10.ts, 0, 23))
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
}
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers10.ts, 0, 13))
|
||||
|
||||
class D extends C {
|
||||
>D : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers10.ts, 0, 23))
|
||||
|
||||
static c = 2;
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : Symbol(D.d, Decl(typeOfThisInStaticMembers10.ts, 10, 17))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : Symbol(D.e, Decl(typeOfThisInStaticMembers10.ts, 11, 26))
|
||||
>super.a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
>super : Symbol(C, Decl(typeOfThisInStaticMembers10.ts, 0, 23))
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers10.ts, 3, 9))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : Symbol(D.f, Decl(typeOfThisInStaticMembers10.ts, 12, 36))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : Symbol(D.ff, Decl(typeOfThisInStaticMembers10.ts, 13, 32))
|
||||
|
||||
static foo () {
|
||||
>foo : Symbol(D.foo, Decl(typeOfThisInStaticMembers10.ts, 14, 42))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
}
|
||||
static get fa () {
|
||||
>fa : Symbol(D.fa, Decl(typeOfThisInStaticMembers10.ts, 17, 5), Decl(typeOfThisInStaticMembers10.ts, 20, 5))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : Symbol(D.fa, Decl(typeOfThisInStaticMembers10.ts, 17, 5), Decl(typeOfThisInStaticMembers10.ts, 20, 5))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers10.ts, 21, 19))
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers10.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers10.ts, 9, 19))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers10.ts, 21, 19))
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
>CC : Symbol(CC, Decl(typeOfThisInStaticMembers10.ts, 24, 1))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : Symbol(CC.b, Decl(typeOfThisInStaticMembers10.ts, 27, 17))
|
||||
>this.a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
>this : Symbol(CC, Decl(typeOfThisInStaticMembers10.ts, 24, 1))
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
>DD : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>CC : Symbol(CC, Decl(typeOfThisInStaticMembers10.ts, 24, 1))
|
||||
|
||||
static c = 2;
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : Symbol(DD.d, Decl(typeOfThisInStaticMembers10.ts, 32, 17))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : Symbol(DD.e, Decl(typeOfThisInStaticMembers10.ts, 33, 26))
|
||||
>super.a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
>super : Symbol(CC, Decl(typeOfThisInStaticMembers10.ts, 24, 1))
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers10.ts, 26, 10))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : Symbol(DD.f, Decl(typeOfThisInStaticMembers10.ts, 34, 36))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : Symbol(DD.ff, Decl(typeOfThisInStaticMembers10.ts, 35, 32))
|
||||
|
||||
static foo () {
|
||||
>foo : Symbol(DD.foo, Decl(typeOfThisInStaticMembers10.ts, 36, 42))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
}
|
||||
static get fa () {
|
||||
>fa : Symbol(DD.fa, Decl(typeOfThisInStaticMembers10.ts, 39, 5), Decl(typeOfThisInStaticMembers10.ts, 42, 5))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : Symbol(DD.fa, Decl(typeOfThisInStaticMembers10.ts, 39, 5), Decl(typeOfThisInStaticMembers10.ts, 42, 5))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers10.ts, 43, 19))
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers10.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers10.ts, 31, 21))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers10.ts, 43, 19))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts ===
|
||||
declare const foo: any;
|
||||
>foo : any
|
||||
|
||||
@foo
|
||||
>foo : any
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : number
|
||||
>this.a + 1 : number
|
||||
>this.a : number
|
||||
>this : typeof C
|
||||
>a : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
@foo
|
||||
>foo : any
|
||||
|
||||
class D extends C {
|
||||
>D : D
|
||||
>C : C
|
||||
|
||||
static c = 2;
|
||||
>c : number
|
||||
>2 : 2
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : number
|
||||
>super.a + this.c + 1 : number
|
||||
>super.a + this.c : number
|
||||
>super.a : number
|
||||
>super : typeof C
|
||||
>a : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : () => number
|
||||
>() => this.c + 1 : () => number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : () => void
|
||||
>function () { this.c + 1 } : () => void
|
||||
>this.c + 1 : any
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>1 : 1
|
||||
|
||||
static foo () {
|
||||
>foo : () => number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static get fa () {
|
||||
>fa : number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : number
|
||||
>v : number
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c = v + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>v + 1 : number
|
||||
>v : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
>CC : CC
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : number
|
||||
>this.a + 1 : number
|
||||
>this.a : number
|
||||
>this : typeof CC
|
||||
>a : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
>DD : DD
|
||||
>CC : CC
|
||||
|
||||
static c = 2;
|
||||
>c : number
|
||||
>2 : 2
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : number
|
||||
>super.a + this.c + 1 : number
|
||||
>super.a + this.c : number
|
||||
>super.a : number
|
||||
>super : typeof CC
|
||||
>a : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : () => number
|
||||
>() => this.c + 1 : () => number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : () => void
|
||||
>function () { this.c + 1 } : () => void
|
||||
>this.c + 1 : any
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>1 : 1
|
||||
|
||||
static foo () {
|
||||
>foo : () => number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static get fa () {
|
||||
>fa : number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : number
|
||||
>v : number
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c = v + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>v + 1 : number
|
||||
>v : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(6,16): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(12,16): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(13,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(13,26): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(14,22): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(35,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts (6 errors) ====
|
||||
declare const foo: any;
|
||||
|
||||
@foo
|
||||
class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
}
|
||||
|
||||
@foo
|
||||
class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static e = super.a + this.c + 1;
|
||||
~
|
||||
!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static f = () => this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
~
|
||||
!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
//// [typeOfThisInStaticMembers11.ts]
|
||||
declare const foo: any;
|
||||
|
||||
@foo
|
||||
class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
@foo
|
||||
class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [typeOfThisInStaticMembers11.js]
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var C = /** @class */ (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C, "a", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 1
|
||||
});
|
||||
Object.defineProperty(C, "b", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (void 0).a + 1
|
||||
});
|
||||
C = __decorate([
|
||||
foo
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
var D = /** @class */ (function (_super) {
|
||||
__extends(D, _super);
|
||||
function D() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
Object.defineProperty(D, "foo", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: function () {
|
||||
return this.c + 1;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(D, "fa", {
|
||||
get: function () {
|
||||
return this.c + 1;
|
||||
},
|
||||
set: function (v) {
|
||||
this.c = v + 1;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(D, "c", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 2
|
||||
});
|
||||
Object.defineProperty(D, "d", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (void 0).c + 1
|
||||
});
|
||||
Object.defineProperty(D, "e", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _super.a + (void 0).c + 1
|
||||
});
|
||||
Object.defineProperty(D, "f", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: function () { return (void 0).c + 1; }
|
||||
});
|
||||
Object.defineProperty(D, "ff", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: function () { this.c + 1; }
|
||||
});
|
||||
D = __decorate([
|
||||
foo
|
||||
], D);
|
||||
return D;
|
||||
}(C));
|
||||
var CC = /** @class */ (function () {
|
||||
function CC() {
|
||||
}
|
||||
var _a;
|
||||
_a = CC;
|
||||
Object.defineProperty(CC, "a", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 1
|
||||
});
|
||||
Object.defineProperty(CC, "b", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _a.a + 1
|
||||
});
|
||||
return CC;
|
||||
}());
|
||||
var DD = /** @class */ (function (_super) {
|
||||
__extends(DD, _super);
|
||||
function DD() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
Object.defineProperty(DD, "foo", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: function () {
|
||||
return this.c + 1;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(DD, "fa", {
|
||||
get: function () {
|
||||
return this.c + 1;
|
||||
},
|
||||
set: function (v) {
|
||||
this.c = v + 1;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
var _b;
|
||||
_b = DD;
|
||||
Object.defineProperty(DD, "c", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 2
|
||||
});
|
||||
Object.defineProperty(DD, "d", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _b.c + 1
|
||||
});
|
||||
Object.defineProperty(DD, "e", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _super.a + _b.c + 1
|
||||
});
|
||||
Object.defineProperty(DD, "f", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: function () { return _b.c + 1; }
|
||||
});
|
||||
Object.defineProperty(DD, "ff", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: function () { this.c + 1; }
|
||||
});
|
||||
return DD;
|
||||
}(CC));
|
||||
@@ -0,0 +1,154 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts ===
|
||||
declare const foo: any;
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers11.ts, 0, 13))
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers11.ts, 0, 13))
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers11.ts, 0, 23))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : Symbol(C.b, Decl(typeOfThisInStaticMembers11.ts, 4, 17))
|
||||
>this.a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
>this : Symbol(C, Decl(typeOfThisInStaticMembers11.ts, 0, 23))
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
}
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers11.ts, 0, 13))
|
||||
|
||||
class D extends C {
|
||||
>D : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers11.ts, 0, 23))
|
||||
|
||||
static c = 2;
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : Symbol(D.d, Decl(typeOfThisInStaticMembers11.ts, 10, 17))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : Symbol(D.e, Decl(typeOfThisInStaticMembers11.ts, 11, 26))
|
||||
>super.a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
>super : Symbol(C, Decl(typeOfThisInStaticMembers11.ts, 0, 23))
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : Symbol(D.f, Decl(typeOfThisInStaticMembers11.ts, 12, 36))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : Symbol(D.ff, Decl(typeOfThisInStaticMembers11.ts, 13, 32))
|
||||
|
||||
static foo () {
|
||||
>foo : Symbol(D.foo, Decl(typeOfThisInStaticMembers11.ts, 14, 42))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
}
|
||||
static get fa () {
|
||||
>fa : Symbol(D.fa, Decl(typeOfThisInStaticMembers11.ts, 17, 5), Decl(typeOfThisInStaticMembers11.ts, 20, 5))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : Symbol(D.fa, Decl(typeOfThisInStaticMembers11.ts, 17, 5), Decl(typeOfThisInStaticMembers11.ts, 20, 5))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers11.ts, 21, 19))
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers11.ts, 21, 19))
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
>CC : Symbol(CC, Decl(typeOfThisInStaticMembers11.ts, 24, 1))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : Symbol(CC.b, Decl(typeOfThisInStaticMembers11.ts, 27, 17))
|
||||
>this.a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
>this : Symbol(CC, Decl(typeOfThisInStaticMembers11.ts, 24, 1))
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
>DD : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>CC : Symbol(CC, Decl(typeOfThisInStaticMembers11.ts, 24, 1))
|
||||
|
||||
static c = 2;
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : Symbol(DD.d, Decl(typeOfThisInStaticMembers11.ts, 32, 17))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : Symbol(DD.e, Decl(typeOfThisInStaticMembers11.ts, 33, 26))
|
||||
>super.a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
>super : Symbol(CC, Decl(typeOfThisInStaticMembers11.ts, 24, 1))
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : Symbol(DD.f, Decl(typeOfThisInStaticMembers11.ts, 34, 36))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : Symbol(DD.ff, Decl(typeOfThisInStaticMembers11.ts, 35, 32))
|
||||
|
||||
static foo () {
|
||||
>foo : Symbol(DD.foo, Decl(typeOfThisInStaticMembers11.ts, 36, 42))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
}
|
||||
static get fa () {
|
||||
>fa : Symbol(DD.fa, Decl(typeOfThisInStaticMembers11.ts, 39, 5), Decl(typeOfThisInStaticMembers11.ts, 42, 5))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : Symbol(DD.fa, Decl(typeOfThisInStaticMembers11.ts, 39, 5), Decl(typeOfThisInStaticMembers11.ts, 42, 5))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers11.ts, 43, 19))
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers11.ts, 43, 19))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts ===
|
||||
declare const foo: any;
|
||||
>foo : any
|
||||
|
||||
@foo
|
||||
>foo : any
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : number
|
||||
>this.a + 1 : number
|
||||
>this.a : number
|
||||
>this : typeof C
|
||||
>a : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
@foo
|
||||
>foo : any
|
||||
|
||||
class D extends C {
|
||||
>D : D
|
||||
>C : C
|
||||
|
||||
static c = 2;
|
||||
>c : number
|
||||
>2 : 2
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : number
|
||||
>super.a + this.c + 1 : number
|
||||
>super.a + this.c : number
|
||||
>super.a : number
|
||||
>super : typeof C
|
||||
>a : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : () => number
|
||||
>() => this.c + 1 : () => number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : () => void
|
||||
>function () { this.c + 1 } : () => void
|
||||
>this.c + 1 : any
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>1 : 1
|
||||
|
||||
static foo () {
|
||||
>foo : () => number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static get fa () {
|
||||
>fa : number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : number
|
||||
>v : number
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c = v + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>v + 1 : number
|
||||
>v : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
>CC : CC
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : number
|
||||
>this.a + 1 : number
|
||||
>this.a : number
|
||||
>this : typeof CC
|
||||
>a : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
>DD : DD
|
||||
>CC : CC
|
||||
|
||||
static c = 2;
|
||||
>c : number
|
||||
>2 : 2
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : number
|
||||
>super.a + this.c + 1 : number
|
||||
>super.a + this.c : number
|
||||
>super.a : number
|
||||
>super : typeof CC
|
||||
>a : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : () => number
|
||||
>() => this.c + 1 : () => number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : () => void
|
||||
>function () { this.c + 1 } : () => void
|
||||
>this.c + 1 : any
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>1 : 1
|
||||
|
||||
static foo () {
|
||||
>foo : () => number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static get fa () {
|
||||
>fa : number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : number
|
||||
>v : number
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c = v + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>v + 1 : number
|
||||
>v : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(6,16): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(12,16): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(13,26): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(14,22): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts (4 errors) ====
|
||||
declare const foo: any;
|
||||
|
||||
@foo
|
||||
class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
}
|
||||
|
||||
@foo
|
||||
class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static e = super.a + this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static f = () => this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
//// [typeOfThisInStaticMembers11.ts]
|
||||
declare const foo: any;
|
||||
|
||||
@foo
|
||||
class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
@foo
|
||||
class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [typeOfThisInStaticMembers11.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var _a, _b, _c;
|
||||
let C = class C {
|
||||
};
|
||||
Object.defineProperty(C, "a", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 1
|
||||
});
|
||||
Object.defineProperty(C, "b", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (void 0).a + 1
|
||||
});
|
||||
C = __decorate([
|
||||
foo
|
||||
], C);
|
||||
let D = class D extends C {
|
||||
static foo() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa(v) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
};
|
||||
Object.defineProperty(D, "c", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 2
|
||||
});
|
||||
Object.defineProperty(D, "d", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (void 0).c + 1
|
||||
});
|
||||
Object.defineProperty(D, "e", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (void 0).a + (void 0).c + 1
|
||||
});
|
||||
Object.defineProperty(D, "f", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: () => (void 0).c + 1
|
||||
});
|
||||
Object.defineProperty(D, "ff", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: function () { this.c + 1; }
|
||||
});
|
||||
D = __decorate([
|
||||
foo
|
||||
], D);
|
||||
class CC {
|
||||
}
|
||||
_a = CC;
|
||||
Object.defineProperty(CC, "a", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 1
|
||||
});
|
||||
Object.defineProperty(CC, "b", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _a.a + 1
|
||||
});
|
||||
class DD extends (_c = CC) {
|
||||
static foo() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa(v) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
_b = DD;
|
||||
Object.defineProperty(DD, "c", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 2
|
||||
});
|
||||
Object.defineProperty(DD, "d", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _b.c + 1
|
||||
});
|
||||
Object.defineProperty(DD, "e", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: Reflect.get(_c, "a", _b) + _b.c + 1
|
||||
});
|
||||
Object.defineProperty(DD, "f", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: () => _b.c + 1
|
||||
});
|
||||
Object.defineProperty(DD, "ff", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: function () { this.c + 1; }
|
||||
});
|
||||
@@ -0,0 +1,154 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts ===
|
||||
declare const foo: any;
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers11.ts, 0, 13))
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers11.ts, 0, 13))
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers11.ts, 0, 23))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : Symbol(C.b, Decl(typeOfThisInStaticMembers11.ts, 4, 17))
|
||||
>this.a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
>this : Symbol(C, Decl(typeOfThisInStaticMembers11.ts, 0, 23))
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
}
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers11.ts, 0, 13))
|
||||
|
||||
class D extends C {
|
||||
>D : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers11.ts, 0, 23))
|
||||
|
||||
static c = 2;
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : Symbol(D.d, Decl(typeOfThisInStaticMembers11.ts, 10, 17))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : Symbol(D.e, Decl(typeOfThisInStaticMembers11.ts, 11, 26))
|
||||
>super.a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
>super : Symbol(C, Decl(typeOfThisInStaticMembers11.ts, 0, 23))
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : Symbol(D.f, Decl(typeOfThisInStaticMembers11.ts, 12, 36))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : Symbol(D.ff, Decl(typeOfThisInStaticMembers11.ts, 13, 32))
|
||||
|
||||
static foo () {
|
||||
>foo : Symbol(D.foo, Decl(typeOfThisInStaticMembers11.ts, 14, 42))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
}
|
||||
static get fa () {
|
||||
>fa : Symbol(D.fa, Decl(typeOfThisInStaticMembers11.ts, 17, 5), Decl(typeOfThisInStaticMembers11.ts, 20, 5))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : Symbol(D.fa, Decl(typeOfThisInStaticMembers11.ts, 17, 5), Decl(typeOfThisInStaticMembers11.ts, 20, 5))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers11.ts, 21, 19))
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers11.ts, 21, 19))
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
>CC : Symbol(CC, Decl(typeOfThisInStaticMembers11.ts, 24, 1))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : Symbol(CC.b, Decl(typeOfThisInStaticMembers11.ts, 27, 17))
|
||||
>this.a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
>this : Symbol(CC, Decl(typeOfThisInStaticMembers11.ts, 24, 1))
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
>DD : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>CC : Symbol(CC, Decl(typeOfThisInStaticMembers11.ts, 24, 1))
|
||||
|
||||
static c = 2;
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : Symbol(DD.d, Decl(typeOfThisInStaticMembers11.ts, 32, 17))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : Symbol(DD.e, Decl(typeOfThisInStaticMembers11.ts, 33, 26))
|
||||
>super.a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
>super : Symbol(CC, Decl(typeOfThisInStaticMembers11.ts, 24, 1))
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : Symbol(DD.f, Decl(typeOfThisInStaticMembers11.ts, 34, 36))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : Symbol(DD.ff, Decl(typeOfThisInStaticMembers11.ts, 35, 32))
|
||||
|
||||
static foo () {
|
||||
>foo : Symbol(DD.foo, Decl(typeOfThisInStaticMembers11.ts, 36, 42))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
}
|
||||
static get fa () {
|
||||
>fa : Symbol(DD.fa, Decl(typeOfThisInStaticMembers11.ts, 39, 5), Decl(typeOfThisInStaticMembers11.ts, 42, 5))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : Symbol(DD.fa, Decl(typeOfThisInStaticMembers11.ts, 39, 5), Decl(typeOfThisInStaticMembers11.ts, 42, 5))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers11.ts, 43, 19))
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers11.ts, 43, 19))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts ===
|
||||
declare const foo: any;
|
||||
>foo : any
|
||||
|
||||
@foo
|
||||
>foo : any
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : number
|
||||
>this.a + 1 : number
|
||||
>this.a : number
|
||||
>this : typeof C
|
||||
>a : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
@foo
|
||||
>foo : any
|
||||
|
||||
class D extends C {
|
||||
>D : D
|
||||
>C : C
|
||||
|
||||
static c = 2;
|
||||
>c : number
|
||||
>2 : 2
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : number
|
||||
>super.a + this.c + 1 : number
|
||||
>super.a + this.c : number
|
||||
>super.a : number
|
||||
>super : typeof C
|
||||
>a : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : () => number
|
||||
>() => this.c + 1 : () => number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : () => void
|
||||
>function () { this.c + 1 } : () => void
|
||||
>this.c + 1 : any
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>1 : 1
|
||||
|
||||
static foo () {
|
||||
>foo : () => number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static get fa () {
|
||||
>fa : number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : number
|
||||
>v : number
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c = v + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>v + 1 : number
|
||||
>v : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
>CC : CC
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : number
|
||||
>this.a + 1 : number
|
||||
>this.a : number
|
||||
>this : typeof CC
|
||||
>a : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
>DD : DD
|
||||
>CC : CC
|
||||
|
||||
static c = 2;
|
||||
>c : number
|
||||
>2 : 2
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : number
|
||||
>super.a + this.c + 1 : number
|
||||
>super.a + this.c : number
|
||||
>super.a : number
|
||||
>super : typeof CC
|
||||
>a : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : () => number
|
||||
>() => this.c + 1 : () => number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : () => void
|
||||
>function () { this.c + 1 } : () => void
|
||||
>this.c + 1 : any
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>1 : 1
|
||||
|
||||
static foo () {
|
||||
>foo : () => number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static get fa () {
|
||||
>fa : number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : number
|
||||
>v : number
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c = v + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>v + 1 : number
|
||||
>v : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(6,16): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(12,16): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(13,26): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts(14,22): error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts (4 errors) ====
|
||||
declare const foo: any;
|
||||
|
||||
@foo
|
||||
class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
}
|
||||
|
||||
@foo
|
||||
class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static e = super.a + this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static f = () => this.c + 1;
|
||||
~~~~
|
||||
!!! error TS2816: Cannot use 'this' in a static property initializer of a decorated class.
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
//// [typeOfThisInStaticMembers11.ts]
|
||||
declare const foo: any;
|
||||
|
||||
@foo
|
||||
class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
@foo
|
||||
class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1 }
|
||||
static foo () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa () {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa (v: number) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [typeOfThisInStaticMembers11.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
let C = class C {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
};
|
||||
C = __decorate([
|
||||
foo
|
||||
], C);
|
||||
let D = class D extends C {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1; };
|
||||
static foo() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa(v) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
};
|
||||
D = __decorate([
|
||||
foo
|
||||
], D);
|
||||
class CC {
|
||||
static a = 1;
|
||||
static b = this.a + 1;
|
||||
}
|
||||
class DD extends CC {
|
||||
static c = 2;
|
||||
static d = this.c + 1;
|
||||
static e = super.a + this.c + 1;
|
||||
static f = () => this.c + 1;
|
||||
static ff = function () { this.c + 1; };
|
||||
static foo() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static get fa() {
|
||||
return this.c + 1;
|
||||
}
|
||||
static set fa(v) {
|
||||
this.c = v + 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts ===
|
||||
declare const foo: any;
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers11.ts, 0, 13))
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers11.ts, 0, 13))
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers11.ts, 0, 23))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : Symbol(C.b, Decl(typeOfThisInStaticMembers11.ts, 4, 17))
|
||||
>this.a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
>this : Symbol(C, Decl(typeOfThisInStaticMembers11.ts, 0, 23))
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
}
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(typeOfThisInStaticMembers11.ts, 0, 13))
|
||||
|
||||
class D extends C {
|
||||
>D : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers11.ts, 0, 23))
|
||||
|
||||
static c = 2;
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : Symbol(D.d, Decl(typeOfThisInStaticMembers11.ts, 10, 17))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : Symbol(D.e, Decl(typeOfThisInStaticMembers11.ts, 11, 26))
|
||||
>super.a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
>super : Symbol(C, Decl(typeOfThisInStaticMembers11.ts, 0, 23))
|
||||
>a : Symbol(C.a, Decl(typeOfThisInStaticMembers11.ts, 3, 9))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : Symbol(D.f, Decl(typeOfThisInStaticMembers11.ts, 12, 36))
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : Symbol(D.ff, Decl(typeOfThisInStaticMembers11.ts, 13, 32))
|
||||
|
||||
static foo () {
|
||||
>foo : Symbol(D.foo, Decl(typeOfThisInStaticMembers11.ts, 14, 42))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
}
|
||||
static get fa () {
|
||||
>fa : Symbol(D.fa, Decl(typeOfThisInStaticMembers11.ts, 17, 5), Decl(typeOfThisInStaticMembers11.ts, 20, 5))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : Symbol(D.fa, Decl(typeOfThisInStaticMembers11.ts, 17, 5), Decl(typeOfThisInStaticMembers11.ts, 20, 5))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers11.ts, 21, 19))
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>this : Symbol(D, Decl(typeOfThisInStaticMembers11.ts, 6, 1))
|
||||
>c : Symbol(D.c, Decl(typeOfThisInStaticMembers11.ts, 9, 19))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers11.ts, 21, 19))
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
>CC : Symbol(CC, Decl(typeOfThisInStaticMembers11.ts, 24, 1))
|
||||
|
||||
static a = 1;
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : Symbol(CC.b, Decl(typeOfThisInStaticMembers11.ts, 27, 17))
|
||||
>this.a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
>this : Symbol(CC, Decl(typeOfThisInStaticMembers11.ts, 24, 1))
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
>DD : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>CC : Symbol(CC, Decl(typeOfThisInStaticMembers11.ts, 24, 1))
|
||||
|
||||
static c = 2;
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : Symbol(DD.d, Decl(typeOfThisInStaticMembers11.ts, 32, 17))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : Symbol(DD.e, Decl(typeOfThisInStaticMembers11.ts, 33, 26))
|
||||
>super.a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
>super : Symbol(CC, Decl(typeOfThisInStaticMembers11.ts, 24, 1))
|
||||
>a : Symbol(CC.a, Decl(typeOfThisInStaticMembers11.ts, 26, 10))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : Symbol(DD.f, Decl(typeOfThisInStaticMembers11.ts, 34, 36))
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : Symbol(DD.ff, Decl(typeOfThisInStaticMembers11.ts, 35, 32))
|
||||
|
||||
static foo () {
|
||||
>foo : Symbol(DD.foo, Decl(typeOfThisInStaticMembers11.ts, 36, 42))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
}
|
||||
static get fa () {
|
||||
>fa : Symbol(DD.fa, Decl(typeOfThisInStaticMembers11.ts, 39, 5), Decl(typeOfThisInStaticMembers11.ts, 42, 5))
|
||||
|
||||
return this.c + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : Symbol(DD.fa, Decl(typeOfThisInStaticMembers11.ts, 39, 5), Decl(typeOfThisInStaticMembers11.ts, 42, 5))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers11.ts, 43, 19))
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>this : Symbol(DD, Decl(typeOfThisInStaticMembers11.ts, 29, 1))
|
||||
>c : Symbol(DD.c, Decl(typeOfThisInStaticMembers11.ts, 31, 21))
|
||||
>v : Symbol(v, Decl(typeOfThisInStaticMembers11.ts, 43, 19))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts ===
|
||||
declare const foo: any;
|
||||
>foo : any
|
||||
|
||||
@foo
|
||||
>foo : any
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : number
|
||||
>this.a + 1 : number
|
||||
>this.a : number
|
||||
>this : typeof C
|
||||
>a : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
@foo
|
||||
>foo : any
|
||||
|
||||
class D extends C {
|
||||
>D : D
|
||||
>C : C
|
||||
|
||||
static c = 2;
|
||||
>c : number
|
||||
>2 : 2
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : number
|
||||
>super.a + this.c + 1 : number
|
||||
>super.a + this.c : number
|
||||
>super.a : number
|
||||
>super : typeof C
|
||||
>a : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : () => number
|
||||
>() => this.c + 1 : () => number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : () => void
|
||||
>function () { this.c + 1 } : () => void
|
||||
>this.c + 1 : any
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>1 : 1
|
||||
|
||||
static foo () {
|
||||
>foo : () => number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static get fa () {
|
||||
>fa : number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : number
|
||||
>v : number
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c = v + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof D
|
||||
>c : number
|
||||
>v + 1 : number
|
||||
>v : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
class CC {
|
||||
>CC : CC
|
||||
|
||||
static a = 1;
|
||||
>a : number
|
||||
>1 : 1
|
||||
|
||||
static b = this.a + 1;
|
||||
>b : number
|
||||
>this.a + 1 : number
|
||||
>this.a : number
|
||||
>this : typeof CC
|
||||
>a : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
class DD extends CC {
|
||||
>DD : DD
|
||||
>CC : CC
|
||||
|
||||
static c = 2;
|
||||
>c : number
|
||||
>2 : 2
|
||||
|
||||
static d = this.c + 1;
|
||||
>d : number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static e = super.a + this.c + 1;
|
||||
>e : number
|
||||
>super.a + this.c + 1 : number
|
||||
>super.a + this.c : number
|
||||
>super.a : number
|
||||
>super : typeof CC
|
||||
>a : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static f = () => this.c + 1;
|
||||
>f : () => number
|
||||
>() => this.c + 1 : () => number
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
|
||||
static ff = function () { this.c + 1 }
|
||||
>ff : () => void
|
||||
>function () { this.c + 1 } : () => void
|
||||
>this.c + 1 : any
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>1 : 1
|
||||
|
||||
static foo () {
|
||||
>foo : () => number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static get fa () {
|
||||
>fa : number
|
||||
|
||||
return this.c + 1;
|
||||
>this.c + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>1 : 1
|
||||
}
|
||||
static set fa (v: number) {
|
||||
>fa : number
|
||||
>v : number
|
||||
|
||||
this.c = v + 1;
|
||||
>this.c = v + 1 : number
|
||||
>this.c : number
|
||||
>this : typeof DD
|
||||
>c : number
|
||||
>v + 1 : number
|
||||
>v : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,16): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,17): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,9): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,10): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts (4 errors) ====
|
||||
class C {
|
||||
static readonly c: "foo" = "foo"
|
||||
static bar = class Inner {
|
||||
static [this.c] = 123;
|
||||
~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
[this.c] = 123;
|
||||
~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
//// [typeOfThisInStaticMembers12.ts]
|
||||
class C {
|
||||
static readonly c: "foo" = "foo"
|
||||
static bar = class Inner {
|
||||
static [this.c] = 123;
|
||||
[this.c] = 123;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [typeOfThisInStaticMembers12.js]
|
||||
var C = /** @class */ (function () {
|
||||
function C() {
|
||||
}
|
||||
var _a, _b, _c, _d;
|
||||
_a = C;
|
||||
C.c = "foo";
|
||||
C.bar = (_b = /** @class */ (function () {
|
||||
function Inner() {
|
||||
this[_d] = 123;
|
||||
}
|
||||
return Inner;
|
||||
}()),
|
||||
_c = _a.c,
|
||||
_d = _a.c,
|
||||
_b[_c] = 123,
|
||||
_b);
|
||||
return C;
|
||||
}());
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts ===
|
||||
class C {
|
||||
>C : Symbol(C, Decl(typeOfThisInStaticMembers12.ts, 0, 0))
|
||||
|
||||
static readonly c: "foo" = "foo"
|
||||
>c : Symbol(C.c, Decl(typeOfThisInStaticMembers12.ts, 0, 9))
|
||||
|
||||
static bar = class Inner {
|
||||
>bar : Symbol(C.bar, Decl(typeOfThisInStaticMembers12.ts, 1, 36))
|
||||
>Inner : Symbol(Inner, Decl(typeOfThisInStaticMembers12.ts, 2, 16))
|
||||
|
||||
static [this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers12.ts, 2, 31))
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers12.ts, 3, 30))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
=== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
static readonly c: "foo" = "foo"
|
||||
>c : "foo"
|
||||
>"foo" : "foo"
|
||||
|
||||
static bar = class Inner {
|
||||
>bar : typeof Inner
|
||||
>class Inner { static [this.c] = 123; [this.c] = 123; } : typeof Inner
|
||||
>Inner : typeof Inner
|
||||
|
||||
static [this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>123 : 123
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>c : any
|
||||
>123 : 123
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,16): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,17): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,9): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,10): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts (4 errors) ====
|
||||
class C {
|
||||
static readonly c: "foo" = "foo"
|
||||
static bar = class Inner {
|
||||
static [this.c] = 123;
|
||||
~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
[this.c] = 123;
|
||||
~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [typeOfThisInStaticMembers12.ts]
|
||||
class C {
|
||||
static readonly c: "foo" = "foo"
|
||||
static bar = class Inner {
|
||||
static [this.c] = 123;
|
||||
[this.c] = 123;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [typeOfThisInStaticMembers12.js]
|
||||
var _a, _b, _c, _d;
|
||||
class C {
|
||||
}
|
||||
_a = C;
|
||||
C.c = "foo";
|
||||
C.bar = (_b = class Inner {
|
||||
constructor() {
|
||||
this[_d] = 123;
|
||||
}
|
||||
},
|
||||
_c = _a.c,
|
||||
_d = _a.c,
|
||||
_b[_c] = 123,
|
||||
_b);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user