mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Use 'static {}' for static fields when available and useDefineForClassFields is false (#47707)
This commit is contained in:
+1
-26
@@ -28425,29 +28425,6 @@ namespace ts {
|
||||
grammarErrorOnNode(right, Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, idText(right));
|
||||
}
|
||||
|
||||
if (lexicallyScopedSymbol?.valueDeclaration && (getEmitScriptTarget(compilerOptions) === ScriptTarget.ESNext && !useDefineForClassFields)) {
|
||||
const lexicalClass = getContainingClass(lexicallyScopedSymbol.valueDeclaration);
|
||||
const parentStaticFieldInitializer = findAncestor(node, (n) => {
|
||||
if (n === lexicalClass) return "quit";
|
||||
if (isPropertyDeclaration(n.parent) && hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (parentStaticFieldInitializer) {
|
||||
const parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent);
|
||||
Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol");
|
||||
const diagnostic = error(node,
|
||||
Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false,
|
||||
symbolName(lexicallyScopedSymbol));
|
||||
addRelatedInfo(diagnostic,
|
||||
createDiagnosticForNode(parentStaticFieldInitializer.parent,
|
||||
Diagnostics.Initializer_for_property_0,
|
||||
symbolName(parentStaticFieldInitializerSymbol))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isAnyLike) {
|
||||
if (lexicallyScopedSymbol) {
|
||||
return isErrorType(apparentType) ? errorType : apparentType;
|
||||
@@ -34656,9 +34633,7 @@ namespace ts {
|
||||
checkVariableLikeDeclaration(node);
|
||||
|
||||
setNodeLinksForPrivateIdentifierScope(node);
|
||||
if (isPrivateIdentifier(node.name) && hasStaticModifier(node) && node.initializer && languageVersion === ScriptTarget.ESNext && !compilerOptions.useDefineForClassFields) {
|
||||
error(node.initializer, Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag);
|
||||
}
|
||||
|
||||
// property signatures already report "initializer not allowed in ambient context" elsewhere
|
||||
if (hasSyntacticModifier(node, ModifierFlags.Abstract) && node.kind === SyntaxKind.PropertyDeclaration && node.initializer) {
|
||||
error(node, Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, declarationNameToString(node.name));
|
||||
|
||||
@@ -3281,10 +3281,6 @@
|
||||
"category": "Error",
|
||||
"code": 2804
|
||||
},
|
||||
"Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.": {
|
||||
"category": "Error",
|
||||
"code": 2805
|
||||
},
|
||||
"Private accessor was defined without a getter.": {
|
||||
"category": "Error",
|
||||
"code": 2806
|
||||
@@ -3301,10 +3297,6 @@
|
||||
"category": "Error",
|
||||
"code": 2809
|
||||
},
|
||||
"Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'.": {
|
||||
"category": "Error",
|
||||
"code": 2810
|
||||
},
|
||||
"Initializer for property '{0}'": {
|
||||
"category": "Error",
|
||||
"code": 2811
|
||||
|
||||
@@ -135,10 +135,13 @@ namespace ts {
|
||||
|
||||
const shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < ScriptTarget.ES2022;
|
||||
|
||||
// We need to transform `this` in a static initializer into a reference to the class
|
||||
// when targeting < ES2022 since the assignment will be moved outside of the class body.
|
||||
const shouldTransformThisInStaticInitializers = languageVersion < ScriptTarget.ES2022;
|
||||
|
||||
// We don't need to transform `super` property access when targeting ES5, ES3 because
|
||||
// the es2015 transformation handles those.
|
||||
const shouldTransformSuperInStaticInitializers = (languageVersion <= ScriptTarget.ES2021 || !useDefineForClassFields) && languageVersion >= ScriptTarget.ES2015;
|
||||
const shouldTransformThisInStaticInitializers = languageVersion <= ScriptTarget.ES2021 || !useDefineForClassFields;
|
||||
const shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= ScriptTarget.ES2015;
|
||||
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
context.onSubstituteNode = onSubstituteNode;
|
||||
@@ -422,6 +425,11 @@ namespace ts {
|
||||
|
||||
if (isPrivateIdentifier(node.name)) {
|
||||
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
|
||||
if (isStatic(node)) {
|
||||
// static fields are left as is
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
// Initializer is elided as the field is initialized in transformConstructor.
|
||||
return factory.updatePropertyDeclaration(
|
||||
node,
|
||||
@@ -448,6 +456,28 @@ namespace ts {
|
||||
if (expr && !isSimpleInlineableExpression(expr)) {
|
||||
getPendingExpressions().push(expr);
|
||||
}
|
||||
|
||||
if (isStatic(node) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
|
||||
const initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis());
|
||||
if (initializerStatement) {
|
||||
const staticBlock = factory.createClassStaticBlockDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
factory.createBlock([initializerStatement])
|
||||
);
|
||||
|
||||
setOriginalNode(staticBlock, node);
|
||||
setCommentRange(staticBlock, node);
|
||||
|
||||
// Set the comment range for the statement to an empty synthetic range
|
||||
// and drop synthetic comments from the statement to avoid printing them twice.
|
||||
setCommentRange(initializerStatement, { pos: -1, end: -1 });
|
||||
setSyntheticLeadingComments(initializerStatement, undefined);
|
||||
setSyntheticTrailingComments(initializerStatement, undefined);
|
||||
return staticBlock;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -1006,8 +1036,6 @@ namespace ts {
|
||||
enableSubstitutionForClassStaticThisOrSuperReference();
|
||||
}
|
||||
|
||||
const staticProperties = getStaticPropertiesAndClassStaticBlock(node);
|
||||
|
||||
// If a class has private static fields, or a static field has a `this` or `super` reference,
|
||||
// then we need to allocate a temp variable to hold on to that reference.
|
||||
let pendingClassReferenceAssignment: BinaryExpression | undefined;
|
||||
@@ -1047,6 +1075,7 @@ namespace ts {
|
||||
// HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
|
||||
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
|
||||
|
||||
const staticProperties = getStaticPropertiesAndClassStaticBlock(node);
|
||||
if (some(staticProperties)) {
|
||||
addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
|
||||
}
|
||||
@@ -1102,7 +1131,7 @@ namespace ts {
|
||||
transformClassMembers(node, isDerivedClass)
|
||||
);
|
||||
|
||||
const hasTransformableStatics = some(staticPropertiesOrClassStaticBlocks, p => isClassStaticBlockDeclaration(p) || !!p.initializer || (shouldTransformPrivateElementsOrClassStaticBlocks && isPrivateIdentifier(p.name)));
|
||||
const hasTransformableStatics = shouldTransformPrivateElementsOrClassStaticBlocks && some(staticPropertiesOrClassStaticBlocks, p => isClassStaticBlockDeclaration(p) || !!p.initializer || isPrivateIdentifier(p.name));
|
||||
if (hasTransformableStatics || some(pendingExpressions)) {
|
||||
if (isDecoratedClassDeclaration) {
|
||||
Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
|
||||
@@ -1156,6 +1185,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function transformClassMembers(node: ClassDeclaration | ClassExpression, isDerivedClass: boolean) {
|
||||
const members: ClassElement[] = [];
|
||||
if (shouldTransformPrivateElementsOrClassStaticBlocks) {
|
||||
// Declare private names.
|
||||
for (const member of node.members) {
|
||||
@@ -1169,12 +1199,26 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
const members: ClassElement[] = [];
|
||||
const constructor = transformConstructor(node, isDerivedClass);
|
||||
const visitedMembers = visitNodes(node.members, classElementVisitor, isClassElement);
|
||||
|
||||
if (constructor) {
|
||||
members.push(constructor);
|
||||
}
|
||||
addRange(members, visitNodes(node.members, classElementVisitor, isClassElement));
|
||||
|
||||
if (!shouldTransformPrivateElementsOrClassStaticBlocks && some(pendingExpressions)) {
|
||||
members.push(factory.createClassStaticBlockDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
factory.createBlock([
|
||||
factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))
|
||||
])
|
||||
));
|
||||
pendingExpressions = undefined;
|
||||
}
|
||||
|
||||
addRange(members, visitedMembers);
|
||||
|
||||
return setTextRange(factory.createNodeArray(members), /*location*/ node.members);
|
||||
}
|
||||
|
||||
@@ -1374,27 +1418,41 @@ namespace ts {
|
||||
*/
|
||||
function addPropertyOrClassStaticBlockStatements(statements: Statement[], properties: readonly (PropertyDeclaration | ClassStaticBlockDeclaration)[], receiver: LeftHandSideExpression) {
|
||||
for (const property of properties) {
|
||||
const expression = isClassStaticBlockDeclaration(property) ?
|
||||
transformClassStaticBlockDeclaration(property) :
|
||||
transformProperty(property, receiver);
|
||||
if (!expression) {
|
||||
if (isStatic(property) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
|
||||
continue;
|
||||
}
|
||||
const statement = factory.createExpressionStatement(expression);
|
||||
setSourceMapRange(statement, moveRangePastModifiers(property));
|
||||
setCommentRange(statement, property);
|
||||
setOriginalNode(statement, property);
|
||||
|
||||
// `setOriginalNode` *copies* the `emitNode` from `property`, so now both
|
||||
// `statement` and `expression` have a copy of the synthesized comments.
|
||||
// Drop the comments from expression to avoid printing them twice.
|
||||
setSyntheticLeadingComments(expression, undefined);
|
||||
setSyntheticTrailingComments(expression, undefined);
|
||||
const statement = transformPropertyOrClassStaticBlock(property, receiver);
|
||||
if (!statement) {
|
||||
continue;
|
||||
}
|
||||
|
||||
statements.push(statement);
|
||||
}
|
||||
}
|
||||
|
||||
function transformPropertyOrClassStaticBlock(property: PropertyDeclaration | ClassStaticBlockDeclaration, receiver: LeftHandSideExpression) {
|
||||
const expression = isClassStaticBlockDeclaration(property) ?
|
||||
transformClassStaticBlockDeclaration(property) :
|
||||
transformProperty(property, receiver);
|
||||
if (!expression) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const statement = factory.createExpressionStatement(expression);
|
||||
setSourceMapRange(statement, moveRangePastModifiers(property));
|
||||
setCommentRange(statement, property);
|
||||
setOriginalNode(statement, property);
|
||||
|
||||
// `setOriginalNode` *copies* the `emitNode` from `property`, so now both
|
||||
// `statement` and `expression` have a copy of the synthesized comments.
|
||||
// Drop the comments from expression to avoid printing them twice.
|
||||
setSyntheticLeadingComments(expression, undefined);
|
||||
setSyntheticTrailingComments(expression, undefined);
|
||||
|
||||
return statement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates assignment expressions for property initializers.
|
||||
*
|
||||
|
||||
@@ -56,8 +56,8 @@ class D {
|
||||
constructor() {
|
||||
this[_a] = 0; // Error
|
||||
}
|
||||
static { _a = onInit; }
|
||||
}
|
||||
_a = onInit;
|
||||
class E {
|
||||
[onInit]() { } // Error
|
||||
}
|
||||
|
||||
-126
@@ -1,126 +0,0 @@
|
||||
=== tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts ===
|
||||
class TestWithErrors {
|
||||
>TestWithErrors : Symbol(TestWithErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
#prop = 0
|
||||
>#prop : Symbol(TestWithErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 22))
|
||||
|
||||
static dd = new TestWithErrors().#prop; // Err
|
||||
>dd : Symbol(TestWithErrors.dd, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 1, 13))
|
||||
>new TestWithErrors().#prop : Symbol(TestWithErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 22))
|
||||
>TestWithErrors : Symbol(TestWithErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
static ["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : Symbol(TestWithErrors["X_ z_ zz"], Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 2, 43))
|
||||
>"X_ z_ zz" : Symbol(TestWithErrors["X_ z_ zz"], Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 2, 43))
|
||||
>Inner : Symbol(Inner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 3, 25))
|
||||
|
||||
#foo = 10
|
||||
>#foo : Symbol(Inner.#foo, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 3, 39))
|
||||
|
||||
m() {
|
||||
>m : Symbol(Inner.m, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 4, 18))
|
||||
|
||||
new TestWithErrors().#prop // Err
|
||||
>new TestWithErrors().#prop : Symbol(TestWithErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 22))
|
||||
>TestWithErrors : Symbol(TestWithErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
}
|
||||
static C = class InnerInner {
|
||||
>C : Symbol(Inner.C, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 7, 9))
|
||||
>InnerInner : Symbol(InnerInner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 8, 18))
|
||||
|
||||
m() {
|
||||
>m : Symbol(InnerInner.m, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 8, 37))
|
||||
|
||||
new TestWithErrors().#prop // Err
|
||||
>new TestWithErrors().#prop : Symbol(TestWithErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 22))
|
||||
>TestWithErrors : Symbol(TestWithErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
new Inner().#foo; // Err
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 3, 39))
|
||||
>Inner : Symbol(Inner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 3, 25))
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : Symbol(Inner.M, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 13, 9))
|
||||
|
||||
return class {
|
||||
m() {
|
||||
>m : Symbol((Anonymous class).m, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 16, 26))
|
||||
|
||||
new TestWithErrors().#prop // Err
|
||||
>new TestWithErrors().#prop : Symbol(TestWithErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 22))
|
||||
>TestWithErrors : Symbol(TestWithErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 3, 39))
|
||||
>Inner : Symbol(Inner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 3, 25))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNoErrors {
|
||||
>TestNoErrors : Symbol(TestNoErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
#prop = 0
|
||||
>#prop : Symbol(TestNoErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 26, 20))
|
||||
|
||||
dd = new TestNoErrors().#prop; // OK
|
||||
>dd : Symbol(TestNoErrors.dd, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 27, 13))
|
||||
>new TestNoErrors().#prop : Symbol(TestNoErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 26, 20))
|
||||
>TestNoErrors : Symbol(TestNoErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : Symbol(TestNoErrors["X_ z_ zz"], Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 28, 34))
|
||||
>"X_ z_ zz" : Symbol(TestNoErrors["X_ z_ zz"], Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 28, 34))
|
||||
>Inner : Symbol(Inner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 29, 18))
|
||||
|
||||
#foo = 10
|
||||
>#foo : Symbol(Inner.#foo, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 29, 32))
|
||||
|
||||
m() {
|
||||
>m : Symbol(Inner.m, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 30, 18))
|
||||
|
||||
new TestNoErrors().#prop // Ok
|
||||
>new TestNoErrors().#prop : Symbol(TestNoErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 26, 20))
|
||||
>TestNoErrors : Symbol(TestNoErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
}
|
||||
C = class InnerInner {
|
||||
>C : Symbol(Inner.C, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 33, 9))
|
||||
>InnerInner : Symbol(InnerInner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 34, 11))
|
||||
|
||||
m() {
|
||||
>m : Symbol(InnerInner.m, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 34, 30))
|
||||
|
||||
new TestNoErrors().#prop // Ok
|
||||
>new TestNoErrors().#prop : Symbol(TestNoErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 26, 20))
|
||||
>TestNoErrors : Symbol(TestNoErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
new Inner().#foo; // Ok
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 29, 32))
|
||||
>Inner : Symbol(Inner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 29, 18))
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : Symbol(Inner.M, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 39, 9))
|
||||
|
||||
return class {
|
||||
m() {
|
||||
>m : Symbol((Anonymous class).m, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 42, 26))
|
||||
|
||||
new TestNoErrors().#prop // OK
|
||||
>new TestNoErrors().#prop : Symbol(TestNoErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 26, 20))
|
||||
>TestNoErrors : Symbol(TestNoErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 29, 32))
|
||||
>Inner : Symbol(Inner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 29, 18))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-150
@@ -1,150 +0,0 @@
|
||||
=== tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts ===
|
||||
class TestWithErrors {
|
||||
>TestWithErrors : TestWithErrors
|
||||
|
||||
#prop = 0
|
||||
>#prop : number
|
||||
>0 : 0
|
||||
|
||||
static dd = new TestWithErrors().#prop; // Err
|
||||
>dd : number
|
||||
>new TestWithErrors().#prop : number
|
||||
>new TestWithErrors() : TestWithErrors
|
||||
>TestWithErrors : typeof TestWithErrors
|
||||
|
||||
static ["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : typeof Inner
|
||||
>"X_ z_ zz" : "X_ z_ zz"
|
||||
>class Inner { #foo = 10 m() { new TestWithErrors().#prop // Err } static C = class InnerInner { m() { new TestWithErrors().#prop // Err new Inner().#foo; // Err } } static M(){ return class { m() { new TestWithErrors().#prop // Err new Inner().#foo; // OK } } } } : typeof Inner
|
||||
>Inner : typeof Inner
|
||||
|
||||
#foo = 10
|
||||
>#foo : number
|
||||
>10 : 10
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestWithErrors().#prop // Err
|
||||
>new TestWithErrors().#prop : number
|
||||
>new TestWithErrors() : TestWithErrors
|
||||
>TestWithErrors : typeof TestWithErrors
|
||||
}
|
||||
static C = class InnerInner {
|
||||
>C : typeof InnerInner
|
||||
>class InnerInner { m() { new TestWithErrors().#prop // Err new Inner().#foo; // Err } } : typeof InnerInner
|
||||
>InnerInner : typeof InnerInner
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestWithErrors().#prop // Err
|
||||
>new TestWithErrors().#prop : number
|
||||
>new TestWithErrors() : TestWithErrors
|
||||
>TestWithErrors : typeof TestWithErrors
|
||||
|
||||
new Inner().#foo; // Err
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : () => typeof (Anonymous class)
|
||||
|
||||
return class {
|
||||
>class { m() { new TestWithErrors().#prop // Err new Inner().#foo; // OK } } : typeof (Anonymous class)
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestWithErrors().#prop // Err
|
||||
>new TestWithErrors().#prop : number
|
||||
>new TestWithErrors() : TestWithErrors
|
||||
>TestWithErrors : typeof TestWithErrors
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNoErrors {
|
||||
>TestNoErrors : TestNoErrors
|
||||
|
||||
#prop = 0
|
||||
>#prop : number
|
||||
>0 : 0
|
||||
|
||||
dd = new TestNoErrors().#prop; // OK
|
||||
>dd : number
|
||||
>new TestNoErrors().#prop : number
|
||||
>new TestNoErrors() : TestNoErrors
|
||||
>TestNoErrors : typeof TestNoErrors
|
||||
|
||||
["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : typeof Inner
|
||||
>"X_ z_ zz" : "X_ z_ zz"
|
||||
>class Inner { #foo = 10 m() { new TestNoErrors().#prop // Ok } C = class InnerInner { m() { new TestNoErrors().#prop // Ok new Inner().#foo; // Ok } } static M(){ return class { m() { new TestNoErrors().#prop // OK new Inner().#foo; // OK } } } } : typeof Inner
|
||||
>Inner : typeof Inner
|
||||
|
||||
#foo = 10
|
||||
>#foo : number
|
||||
>10 : 10
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestNoErrors().#prop // Ok
|
||||
>new TestNoErrors().#prop : number
|
||||
>new TestNoErrors() : TestNoErrors
|
||||
>TestNoErrors : typeof TestNoErrors
|
||||
}
|
||||
C = class InnerInner {
|
||||
>C : typeof InnerInner
|
||||
>class InnerInner { m() { new TestNoErrors().#prop // Ok new Inner().#foo; // Ok } } : typeof InnerInner
|
||||
>InnerInner : typeof InnerInner
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestNoErrors().#prop // Ok
|
||||
>new TestNoErrors().#prop : number
|
||||
>new TestNoErrors() : TestNoErrors
|
||||
>TestNoErrors : typeof TestNoErrors
|
||||
|
||||
new Inner().#foo; // Ok
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : () => typeof (Anonymous class)
|
||||
|
||||
return class {
|
||||
>class { m() { new TestNoErrors().#prop // OK new Inner().#foo; // OK } } : typeof (Anonymous class)
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestNoErrors().#prop // OK
|
||||
>new TestNoErrors().#prop : number
|
||||
>new TestNoErrors() : TestNoErrors
|
||||
>TestNoErrors : typeof TestNoErrors
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts(3,17): error TS2810: Property '#prop' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'.
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts(7,13): error TS2810: Property '#prop' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'.
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts(11,17): error TS2810: Property '#prop' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'.
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts(12,17): error TS2810: Property '#foo' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'.
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts(19,21): error TS2810: Property '#prop' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts (5 errors) ====
|
||||
class TestWithErrors {
|
||||
#prop = 0
|
||||
static dd = new TestWithErrors().#prop; // Err
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2810: Property '#prop' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'.
|
||||
!!! related TS2811 tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts:3:12: Initializer for property 'dd'
|
||||
static ["X_ z_ zz"] = class Inner {
|
||||
#foo = 10
|
||||
m() {
|
||||
new TestWithErrors().#prop // Err
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2810: Property '#prop' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'.
|
||||
!!! related TS2811 tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts:4:12: Initializer for property 'X_ z_ zz'
|
||||
}
|
||||
static C = class InnerInner {
|
||||
m() {
|
||||
new TestWithErrors().#prop // Err
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2810: Property '#prop' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'.
|
||||
!!! related TS2811 tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts:4:12: Initializer for property 'X_ z_ zz'
|
||||
new Inner().#foo; // Err
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2810: Property '#foo' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'.
|
||||
!!! related TS2811 tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts:9:16: Initializer for property 'C'
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
return class {
|
||||
m() {
|
||||
new TestWithErrors().#prop // Err
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2810: Property '#prop' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'.
|
||||
!!! related TS2811 tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts:4:12: Initializer for property 'X_ z_ zz'
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNoErrors {
|
||||
#prop = 0
|
||||
dd = new TestNoErrors().#prop; // OK
|
||||
["X_ z_ zz"] = class Inner {
|
||||
#foo = 10
|
||||
m() {
|
||||
new TestNoErrors().#prop // Ok
|
||||
}
|
||||
C = class InnerInner {
|
||||
m() {
|
||||
new TestNoErrors().#prop // Ok
|
||||
new Inner().#foo; // Ok
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
return class {
|
||||
m() {
|
||||
new TestNoErrors().#prop // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-126
@@ -1,126 +0,0 @@
|
||||
=== tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts ===
|
||||
class TestWithErrors {
|
||||
>TestWithErrors : Symbol(TestWithErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
#prop = 0
|
||||
>#prop : Symbol(TestWithErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 22))
|
||||
|
||||
static dd = new TestWithErrors().#prop; // Err
|
||||
>dd : Symbol(TestWithErrors.dd, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 1, 13))
|
||||
>new TestWithErrors().#prop : Symbol(TestWithErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 22))
|
||||
>TestWithErrors : Symbol(TestWithErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
static ["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : Symbol(TestWithErrors["X_ z_ zz"], Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 2, 43))
|
||||
>"X_ z_ zz" : Symbol(TestWithErrors["X_ z_ zz"], Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 2, 43))
|
||||
>Inner : Symbol(Inner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 3, 25))
|
||||
|
||||
#foo = 10
|
||||
>#foo : Symbol(Inner.#foo, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 3, 39))
|
||||
|
||||
m() {
|
||||
>m : Symbol(Inner.m, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 4, 18))
|
||||
|
||||
new TestWithErrors().#prop // Err
|
||||
>new TestWithErrors().#prop : Symbol(TestWithErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 22))
|
||||
>TestWithErrors : Symbol(TestWithErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
}
|
||||
static C = class InnerInner {
|
||||
>C : Symbol(Inner.C, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 7, 9))
|
||||
>InnerInner : Symbol(InnerInner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 8, 18))
|
||||
|
||||
m() {
|
||||
>m : Symbol(InnerInner.m, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 8, 37))
|
||||
|
||||
new TestWithErrors().#prop // Err
|
||||
>new TestWithErrors().#prop : Symbol(TestWithErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 22))
|
||||
>TestWithErrors : Symbol(TestWithErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
new Inner().#foo; // Err
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 3, 39))
|
||||
>Inner : Symbol(Inner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 3, 25))
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : Symbol(Inner.M, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 13, 9))
|
||||
|
||||
return class {
|
||||
m() {
|
||||
>m : Symbol((Anonymous class).m, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 16, 26))
|
||||
|
||||
new TestWithErrors().#prop // Err
|
||||
>new TestWithErrors().#prop : Symbol(TestWithErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 22))
|
||||
>TestWithErrors : Symbol(TestWithErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 3, 39))
|
||||
>Inner : Symbol(Inner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 3, 25))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNoErrors {
|
||||
>TestNoErrors : Symbol(TestNoErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
#prop = 0
|
||||
>#prop : Symbol(TestNoErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 26, 20))
|
||||
|
||||
dd = new TestNoErrors().#prop; // OK
|
||||
>dd : Symbol(TestNoErrors.dd, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 27, 13))
|
||||
>new TestNoErrors().#prop : Symbol(TestNoErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 26, 20))
|
||||
>TestNoErrors : Symbol(TestNoErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : Symbol(TestNoErrors["X_ z_ zz"], Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 28, 34))
|
||||
>"X_ z_ zz" : Symbol(TestNoErrors["X_ z_ zz"], Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 28, 34))
|
||||
>Inner : Symbol(Inner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 29, 18))
|
||||
|
||||
#foo = 10
|
||||
>#foo : Symbol(Inner.#foo, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 29, 32))
|
||||
|
||||
m() {
|
||||
>m : Symbol(Inner.m, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 30, 18))
|
||||
|
||||
new TestNoErrors().#prop // Ok
|
||||
>new TestNoErrors().#prop : Symbol(TestNoErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 26, 20))
|
||||
>TestNoErrors : Symbol(TestNoErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
}
|
||||
C = class InnerInner {
|
||||
>C : Symbol(Inner.C, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 33, 9))
|
||||
>InnerInner : Symbol(InnerInner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 34, 11))
|
||||
|
||||
m() {
|
||||
>m : Symbol(InnerInner.m, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 34, 30))
|
||||
|
||||
new TestNoErrors().#prop // Ok
|
||||
>new TestNoErrors().#prop : Symbol(TestNoErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 26, 20))
|
||||
>TestNoErrors : Symbol(TestNoErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
new Inner().#foo; // Ok
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 29, 32))
|
||||
>Inner : Symbol(Inner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 29, 18))
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : Symbol(Inner.M, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 39, 9))
|
||||
|
||||
return class {
|
||||
m() {
|
||||
>m : Symbol((Anonymous class).m, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 42, 26))
|
||||
|
||||
new TestNoErrors().#prop // OK
|
||||
>new TestNoErrors().#prop : Symbol(TestNoErrors.#prop, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 26, 20))
|
||||
>TestNoErrors : Symbol(TestNoErrors, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 29, 32))
|
||||
>Inner : Symbol(Inner, Decl(privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts, 29, 18))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-150
@@ -1,150 +0,0 @@
|
||||
=== tests/cases/conformance/classes/members/privateNames/privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts ===
|
||||
class TestWithErrors {
|
||||
>TestWithErrors : TestWithErrors
|
||||
|
||||
#prop = 0
|
||||
>#prop : number
|
||||
>0 : 0
|
||||
|
||||
static dd = new TestWithErrors().#prop; // Err
|
||||
>dd : number
|
||||
>new TestWithErrors().#prop : number
|
||||
>new TestWithErrors() : TestWithErrors
|
||||
>TestWithErrors : typeof TestWithErrors
|
||||
|
||||
static ["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : typeof Inner
|
||||
>"X_ z_ zz" : "X_ z_ zz"
|
||||
>class Inner { #foo = 10 m() { new TestWithErrors().#prop // Err } static C = class InnerInner { m() { new TestWithErrors().#prop // Err new Inner().#foo; // Err } } static M(){ return class { m() { new TestWithErrors().#prop // Err new Inner().#foo; // OK } } } } : typeof Inner
|
||||
>Inner : typeof Inner
|
||||
|
||||
#foo = 10
|
||||
>#foo : number
|
||||
>10 : 10
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestWithErrors().#prop // Err
|
||||
>new TestWithErrors().#prop : number
|
||||
>new TestWithErrors() : TestWithErrors
|
||||
>TestWithErrors : typeof TestWithErrors
|
||||
}
|
||||
static C = class InnerInner {
|
||||
>C : typeof InnerInner
|
||||
>class InnerInner { m() { new TestWithErrors().#prop // Err new Inner().#foo; // Err } } : typeof InnerInner
|
||||
>InnerInner : typeof InnerInner
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestWithErrors().#prop // Err
|
||||
>new TestWithErrors().#prop : number
|
||||
>new TestWithErrors() : TestWithErrors
|
||||
>TestWithErrors : typeof TestWithErrors
|
||||
|
||||
new Inner().#foo; // Err
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : () => typeof (Anonymous class)
|
||||
|
||||
return class {
|
||||
>class { m() { new TestWithErrors().#prop // Err new Inner().#foo; // OK } } : typeof (Anonymous class)
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestWithErrors().#prop // Err
|
||||
>new TestWithErrors().#prop : number
|
||||
>new TestWithErrors() : TestWithErrors
|
||||
>TestWithErrors : typeof TestWithErrors
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNoErrors {
|
||||
>TestNoErrors : TestNoErrors
|
||||
|
||||
#prop = 0
|
||||
>#prop : number
|
||||
>0 : 0
|
||||
|
||||
dd = new TestNoErrors().#prop; // OK
|
||||
>dd : number
|
||||
>new TestNoErrors().#prop : number
|
||||
>new TestNoErrors() : TestNoErrors
|
||||
>TestNoErrors : typeof TestNoErrors
|
||||
|
||||
["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : typeof Inner
|
||||
>"X_ z_ zz" : "X_ z_ zz"
|
||||
>class Inner { #foo = 10 m() { new TestNoErrors().#prop // Ok } C = class InnerInner { m() { new TestNoErrors().#prop // Ok new Inner().#foo; // Ok } } static M(){ return class { m() { new TestNoErrors().#prop // OK new Inner().#foo; // OK } } } } : typeof Inner
|
||||
>Inner : typeof Inner
|
||||
|
||||
#foo = 10
|
||||
>#foo : number
|
||||
>10 : 10
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestNoErrors().#prop // Ok
|
||||
>new TestNoErrors().#prop : number
|
||||
>new TestNoErrors() : TestNoErrors
|
||||
>TestNoErrors : typeof TestNoErrors
|
||||
}
|
||||
C = class InnerInner {
|
||||
>C : typeof InnerInner
|
||||
>class InnerInner { m() { new TestNoErrors().#prop // Ok new Inner().#foo; // Ok } } : typeof InnerInner
|
||||
>InnerInner : typeof InnerInner
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestNoErrors().#prop // Ok
|
||||
>new TestNoErrors().#prop : number
|
||||
>new TestNoErrors() : TestNoErrors
|
||||
>TestNoErrors : typeof TestNoErrors
|
||||
|
||||
new Inner().#foo; // Ok
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : () => typeof (Anonymous class)
|
||||
|
||||
return class {
|
||||
>class { m() { new TestNoErrors().#prop // OK new Inner().#foo; // OK } } : typeof (Anonymous class)
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestNoErrors().#prop // OK
|
||||
>new TestNoErrors().#prop : number
|
||||
>new TestNoErrors() : TestNoErrors
|
||||
>TestNoErrors : typeof TestNoErrors
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class C {
|
||||
this.#a = "hello";
|
||||
console.log(this.#b);
|
||||
}
|
||||
static #m;
|
||||
static #m = "test";
|
||||
static #x;
|
||||
static test() {
|
||||
console.log(this.#m);
|
||||
@@ -43,4 +43,3 @@ class C {
|
||||
}
|
||||
#something;
|
||||
}
|
||||
C.#m = "test";
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameFieldsESNext.ts(8,9): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameFieldsESNext.ts(11,17): error TS2805: Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/privateNames/privateNameFieldsESNext.ts (2 errors) ====
|
||||
==== tests/cases/conformance/classes/members/privateNames/privateNameFieldsESNext.ts (1 errors) ====
|
||||
class C {
|
||||
a = 123;
|
||||
#a = 10;
|
||||
@@ -16,8 +15,6 @@ tests/cases/conformance/classes/members/privateNames/privateNameFieldsESNext.ts(
|
||||
console.log(this.#b);
|
||||
}
|
||||
static #m = "test";
|
||||
~~~~~~
|
||||
!!! error TS2805: Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.
|
||||
static #x;
|
||||
static test() {
|
||||
console.log(this.#m);
|
||||
|
||||
@@ -35,7 +35,7 @@ class C {
|
||||
this.#a = "hello";
|
||||
console.log(this.#b);
|
||||
}
|
||||
static #m;
|
||||
static #m = "test";
|
||||
static #x;
|
||||
static test() {
|
||||
console.log(this.#m);
|
||||
@@ -43,4 +43,3 @@ class C {
|
||||
}
|
||||
#something;
|
||||
}
|
||||
C.#m = "test";
|
||||
|
||||
+1
-4
@@ -1,17 +1,14 @@
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameInInExpressionTransform.ts(4,26): error TS2805: Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameInInExpressionTransform.ts(20,24): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameInInExpressionTransform.ts(24,14): error TS2360: The left-hand side of an 'in' expression must be a private identifier or of type 'any', 'string', 'number', or 'symbol'.
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameInInExpressionTransform.ts(29,21): error TS1005: ';' expected.
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameInInExpressionTransform.ts(30,21): error TS1005: ';' expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/privateNames/privateNameInInExpressionTransform.ts (5 errors) ====
|
||||
==== tests/cases/conformance/classes/members/privateNames/privateNameInInExpressionTransform.ts (4 errors) ====
|
||||
class Foo {
|
||||
#field = 1;
|
||||
#method() {}
|
||||
static #staticField= 2;
|
||||
~
|
||||
!!! error TS2805: Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.
|
||||
static #staticMethod() {}
|
||||
|
||||
check(v: any) {
|
||||
|
||||
@@ -8,8 +8,6 @@ class A {
|
||||
|
||||
//// [privateNameStaticAndStaticInitializer.js]
|
||||
class A {
|
||||
static #foo;
|
||||
static #prop;
|
||||
static #foo = 1;
|
||||
static #prop = 2;
|
||||
}
|
||||
A.#foo = 1;
|
||||
A.#prop = 2;
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameStaticAndStaticInitializer.ts(2,17): error TS2805: Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameStaticAndStaticInitializer.ts(3,18): error TS2805: Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/privateNames/privateNameStaticAndStaticInitializer.ts (2 errors) ====
|
||||
class A {
|
||||
static #foo = 1;
|
||||
~
|
||||
!!! error TS2805: Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.
|
||||
static #prop = 2;
|
||||
~
|
||||
!!! error TS2805: Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@ class A {
|
||||
|
||||
//// [privateNameStaticAndStaticInitializer.js]
|
||||
class A {
|
||||
static #foo;
|
||||
static #prop;
|
||||
static #foo = 1;
|
||||
static #prop = 2;
|
||||
}
|
||||
A.#foo = 1;
|
||||
A.#prop = 2;
|
||||
|
||||
+1
-2
@@ -37,7 +37,7 @@ class A {
|
||||
[A.#field = 2] = [];
|
||||
[this.otherClass.#field = 2] = [];
|
||||
}
|
||||
static #field;
|
||||
static #field = 1;
|
||||
testObject() {
|
||||
return { x: 10, y: 6 };
|
||||
}
|
||||
@@ -48,4 +48,3 @@ class A {
|
||||
[_a.#field] = [2];
|
||||
}
|
||||
}
|
||||
A.#field = 1;
|
||||
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameStaticFieldDestructuredBinding.ts(2,21): error TS2805: Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/privateNames/privateNameStaticFieldDestructuredBinding.ts (1 errors) ====
|
||||
class A {
|
||||
static #field = 1;
|
||||
~
|
||||
!!! error TS2805: Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.
|
||||
otherClass = A;
|
||||
testObject() {
|
||||
return { x: 10, y: 6 };
|
||||
}
|
||||
testArray() {
|
||||
return [10, 11];
|
||||
}
|
||||
constructor() {
|
||||
let y: number;
|
||||
({ x: A.#field, y } = this.testObject());
|
||||
([A.#field, y] = this.testArray());
|
||||
({ a: A.#field, b: [A.#field] } = { a: 1, b: [2] });
|
||||
[A.#field, [A.#field]] = [1, [2]];
|
||||
({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] });
|
||||
[A.#field = 2] = [];
|
||||
[this.otherClass.#field = 2] = [];
|
||||
}
|
||||
static test(_a: typeof A) {
|
||||
[_a.#field] = [2];
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -37,7 +37,7 @@ class A {
|
||||
[A.#field = 2] = [];
|
||||
[this.otherClass.#field = 2] = [];
|
||||
}
|
||||
static #field;
|
||||
static #field = 1;
|
||||
testObject() {
|
||||
return { x: 10, y: 6 };
|
||||
}
|
||||
@@ -48,4 +48,3 @@ class A {
|
||||
[_a.#field] = [2];
|
||||
}
|
||||
}
|
||||
A.#field = 1;
|
||||
|
||||
@@ -7,7 +7,6 @@ class A {
|
||||
|
||||
//// [privateNameStaticFieldInitializer.js]
|
||||
class A {
|
||||
static #field;
|
||||
static #field = 10;
|
||||
static #uninitialized;
|
||||
}
|
||||
A.#field = 10;
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
tests/cases/conformance/classes/members/privateNames/privateNameStaticFieldInitializer.ts(2,21): error TS2805: Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/privateNames/privateNameStaticFieldInitializer.ts (1 errors) ====
|
||||
class A {
|
||||
static #field = 10;
|
||||
~~
|
||||
!!! error TS2805: Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag.
|
||||
static #uninitialized;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ class A {
|
||||
|
||||
//// [privateNameStaticFieldInitializer.js]
|
||||
class A {
|
||||
static #field;
|
||||
static #field = 10;
|
||||
static #uninitialized;
|
||||
}
|
||||
A.#field = 10;
|
||||
|
||||
+38
-38
@@ -1,82 +1,82 @@
|
||||
//// [privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts]
|
||||
class TestWithErrors {
|
||||
#prop = 0
|
||||
static dd = new TestWithErrors().#prop; // Err
|
||||
//// [privateNameWhenNotUseDefineForClassFieldsInEsNext.ts]
|
||||
class TestWithStatics {
|
||||
#prop = 0
|
||||
static dd = new TestWithStatics().#prop; // OK
|
||||
static ["X_ z_ zz"] = class Inner {
|
||||
#foo = 10
|
||||
#foo = 10
|
||||
m() {
|
||||
new TestWithErrors().#prop // Err
|
||||
new TestWithStatics().#prop // OK
|
||||
}
|
||||
static C = class InnerInner {
|
||||
m() {
|
||||
new TestWithErrors().#prop // Err
|
||||
new Inner().#foo; // Err
|
||||
new TestWithStatics().#prop // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
return class {
|
||||
m() {
|
||||
new TestWithErrors().#prop // Err
|
||||
new TestWithStatics().#prop // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNoErrors {
|
||||
#prop = 0
|
||||
dd = new TestNoErrors().#prop; // OK
|
||||
class TestNonStatics {
|
||||
#prop = 0
|
||||
dd = new TestNonStatics().#prop; // OK
|
||||
["X_ z_ zz"] = class Inner {
|
||||
#foo = 10
|
||||
#foo = 10
|
||||
m() {
|
||||
new TestNoErrors().#prop // Ok
|
||||
new TestNonStatics().#prop // Ok
|
||||
}
|
||||
C = class InnerInner {
|
||||
m() {
|
||||
new TestNoErrors().#prop // Ok
|
||||
new TestNonStatics().#prop // Ok
|
||||
new Inner().#foo; // Ok
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static M(){
|
||||
return class {
|
||||
m() {
|
||||
new TestNoErrors().#prop // OK
|
||||
new TestNonStatics().#prop // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.js]
|
||||
//// [privateNameWhenNotUseDefineForClassFieldsInEsNext.js]
|
||||
"use strict";
|
||||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||
};
|
||||
var _TestWithErrors_prop, _Inner_foo, _a, _TestNoErrors_prop;
|
||||
class TestWithErrors {
|
||||
var _TestWithStatics_prop, _Inner_foo, _a, _TestNonStatics_prop;
|
||||
class TestWithStatics {
|
||||
constructor() {
|
||||
_TestWithErrors_prop.set(this, 0);
|
||||
_TestWithStatics_prop.set(this, 0);
|
||||
}
|
||||
}
|
||||
_TestWithErrors_prop = new WeakMap();
|
||||
TestWithErrors.dd = __classPrivateFieldGet(new TestWithErrors(), _TestWithErrors_prop, "f"); // Err
|
||||
TestWithErrors["X_ z_ zz"] = (_a = class Inner {
|
||||
_TestWithStatics_prop = new WeakMap();
|
||||
TestWithStatics.dd = __classPrivateFieldGet(new TestWithStatics(), _TestWithStatics_prop, "f"); // OK
|
||||
TestWithStatics["X_ z_ zz"] = (_a = class Inner {
|
||||
constructor() {
|
||||
_Inner_foo.set(this, 10);
|
||||
}
|
||||
m() {
|
||||
__classPrivateFieldGet(new TestWithErrors(), _TestWithErrors_prop, "f"); // Err
|
||||
__classPrivateFieldGet(new TestWithStatics(), _TestWithStatics_prop, "f"); // OK
|
||||
}
|
||||
static M() {
|
||||
return class {
|
||||
m() {
|
||||
__classPrivateFieldGet(new TestWithErrors(), _TestWithErrors_prop, "f"); // Err
|
||||
__classPrivateFieldGet(new TestWithStatics(), _TestWithStatics_prop, "f"); // OK
|
||||
__classPrivateFieldGet(new Inner(), _Inner_foo, "f"); // OK
|
||||
}
|
||||
};
|
||||
@@ -85,33 +85,33 @@ TestWithErrors["X_ z_ zz"] = (_a = class Inner {
|
||||
_Inner_foo = new WeakMap(),
|
||||
_a.C = class InnerInner {
|
||||
m() {
|
||||
__classPrivateFieldGet(new TestWithErrors(), _TestWithErrors_prop, "f"); // Err
|
||||
__classPrivateFieldGet(new _a(), _Inner_foo, "f"); // Err
|
||||
__classPrivateFieldGet(new TestWithStatics(), _TestWithStatics_prop, "f"); // OK
|
||||
__classPrivateFieldGet(new _a(), _Inner_foo, "f"); // OK
|
||||
}
|
||||
},
|
||||
_a);
|
||||
class TestNoErrors {
|
||||
class TestNonStatics {
|
||||
constructor() {
|
||||
var _Inner_foo_1, _b;
|
||||
_TestNoErrors_prop.set(this, 0);
|
||||
this.dd = __classPrivateFieldGet(new TestNoErrors(), _TestNoErrors_prop, "f"); // OK
|
||||
_TestNonStatics_prop.set(this, 0);
|
||||
this.dd = __classPrivateFieldGet(new TestNonStatics(), _TestNonStatics_prop, "f"); // OK
|
||||
this["X_ z_ zz"] = (_b = class Inner {
|
||||
constructor() {
|
||||
_Inner_foo_1.set(this, 10);
|
||||
this.C = class InnerInner {
|
||||
m() {
|
||||
__classPrivateFieldGet(new TestNoErrors(), _TestNoErrors_prop, "f"); // Ok
|
||||
__classPrivateFieldGet(new TestNonStatics(), _TestNonStatics_prop, "f"); // Ok
|
||||
__classPrivateFieldGet(new Inner(), _Inner_foo_1, "f"); // Ok
|
||||
}
|
||||
};
|
||||
}
|
||||
m() {
|
||||
__classPrivateFieldGet(new TestNoErrors(), _TestNoErrors_prop, "f"); // Ok
|
||||
__classPrivateFieldGet(new TestNonStatics(), _TestNonStatics_prop, "f"); // Ok
|
||||
}
|
||||
static M() {
|
||||
return class {
|
||||
m() {
|
||||
__classPrivateFieldGet(new TestNoErrors(), _TestNoErrors_prop, "f"); // OK
|
||||
__classPrivateFieldGet(new TestNonStatics(), _TestNonStatics_prop, "f"); // OK
|
||||
__classPrivateFieldGet(new Inner(), _Inner_foo_1, "f"); // OK
|
||||
}
|
||||
};
|
||||
@@ -121,4 +121,4 @@ class TestNoErrors {
|
||||
_b);
|
||||
}
|
||||
}
|
||||
_TestNoErrors_prop = new WeakMap();
|
||||
_TestNonStatics_prop = new WeakMap();
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
=== tests/cases/conformance/classes/members/privateNames/privateNameWhenNotUseDefineForClassFieldsInEsNext.ts ===
|
||||
class TestWithStatics {
|
||||
>TestWithStatics : Symbol(TestWithStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
#prop = 0
|
||||
>#prop : Symbol(TestWithStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 23))
|
||||
|
||||
static dd = new TestWithStatics().#prop; // OK
|
||||
>dd : Symbol(TestWithStatics.dd, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 1, 13))
|
||||
>new TestWithStatics().#prop : Symbol(TestWithStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 23))
|
||||
>TestWithStatics : Symbol(TestWithStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
static ["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : Symbol(TestWithStatics["X_ z_ zz"], Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 2, 44))
|
||||
>"X_ z_ zz" : Symbol(TestWithStatics["X_ z_ zz"], Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 2, 44))
|
||||
>Inner : Symbol(Inner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 3, 25))
|
||||
|
||||
#foo = 10
|
||||
>#foo : Symbol(Inner.#foo, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 3, 39))
|
||||
|
||||
m() {
|
||||
>m : Symbol(Inner.m, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 4, 18))
|
||||
|
||||
new TestWithStatics().#prop // OK
|
||||
>new TestWithStatics().#prop : Symbol(TestWithStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 23))
|
||||
>TestWithStatics : Symbol(TestWithStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
}
|
||||
static C = class InnerInner {
|
||||
>C : Symbol(Inner.C, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 7, 9))
|
||||
>InnerInner : Symbol(InnerInner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 8, 18))
|
||||
|
||||
m() {
|
||||
>m : Symbol(InnerInner.m, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 8, 37))
|
||||
|
||||
new TestWithStatics().#prop // OK
|
||||
>new TestWithStatics().#prop : Symbol(TestWithStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 23))
|
||||
>TestWithStatics : Symbol(TestWithStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 3, 39))
|
||||
>Inner : Symbol(Inner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 3, 25))
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : Symbol(Inner.M, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 13, 9))
|
||||
|
||||
return class {
|
||||
m() {
|
||||
>m : Symbol((Anonymous class).m, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 16, 26))
|
||||
|
||||
new TestWithStatics().#prop // OK
|
||||
>new TestWithStatics().#prop : Symbol(TestWithStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 23))
|
||||
>TestWithStatics : Symbol(TestWithStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 3, 39))
|
||||
>Inner : Symbol(Inner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 3, 25))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNonStatics {
|
||||
>TestNonStatics : Symbol(TestNonStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
#prop = 0
|
||||
>#prop : Symbol(TestNonStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 26, 22))
|
||||
|
||||
dd = new TestNonStatics().#prop; // OK
|
||||
>dd : Symbol(TestNonStatics.dd, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 27, 13))
|
||||
>new TestNonStatics().#prop : Symbol(TestNonStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 26, 22))
|
||||
>TestNonStatics : Symbol(TestNonStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : Symbol(TestNonStatics["X_ z_ zz"], Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 28, 36))
|
||||
>"X_ z_ zz" : Symbol(TestNonStatics["X_ z_ zz"], Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 28, 36))
|
||||
>Inner : Symbol(Inner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 29, 18))
|
||||
|
||||
#foo = 10
|
||||
>#foo : Symbol(Inner.#foo, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 29, 32))
|
||||
|
||||
m() {
|
||||
>m : Symbol(Inner.m, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 30, 18))
|
||||
|
||||
new TestNonStatics().#prop // Ok
|
||||
>new TestNonStatics().#prop : Symbol(TestNonStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 26, 22))
|
||||
>TestNonStatics : Symbol(TestNonStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
}
|
||||
C = class InnerInner {
|
||||
>C : Symbol(Inner.C, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 33, 9))
|
||||
>InnerInner : Symbol(InnerInner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 34, 11))
|
||||
|
||||
m() {
|
||||
>m : Symbol(InnerInner.m, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 34, 30))
|
||||
|
||||
new TestNonStatics().#prop // Ok
|
||||
>new TestNonStatics().#prop : Symbol(TestNonStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 26, 22))
|
||||
>TestNonStatics : Symbol(TestNonStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
new Inner().#foo; // Ok
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 29, 32))
|
||||
>Inner : Symbol(Inner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 29, 18))
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : Symbol(Inner.M, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 39, 9))
|
||||
|
||||
return class {
|
||||
m() {
|
||||
>m : Symbol((Anonymous class).m, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 42, 26))
|
||||
|
||||
new TestNonStatics().#prop // OK
|
||||
>new TestNonStatics().#prop : Symbol(TestNonStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 26, 22))
|
||||
>TestNonStatics : Symbol(TestNonStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 29, 32))
|
||||
>Inner : Symbol(Inner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 29, 18))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
=== tests/cases/conformance/classes/members/privateNames/privateNameWhenNotUseDefineForClassFieldsInEsNext.ts ===
|
||||
class TestWithStatics {
|
||||
>TestWithStatics : TestWithStatics
|
||||
|
||||
#prop = 0
|
||||
>#prop : number
|
||||
>0 : 0
|
||||
|
||||
static dd = new TestWithStatics().#prop; // OK
|
||||
>dd : number
|
||||
>new TestWithStatics().#prop : number
|
||||
>new TestWithStatics() : TestWithStatics
|
||||
>TestWithStatics : typeof TestWithStatics
|
||||
|
||||
static ["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : typeof Inner
|
||||
>"X_ z_ zz" : "X_ z_ zz"
|
||||
>class Inner { #foo = 10 m() { new TestWithStatics().#prop // OK } static C = class InnerInner { m() { new TestWithStatics().#prop // OK new Inner().#foo; // OK } } static M(){ return class { m() { new TestWithStatics().#prop // OK new Inner().#foo; // OK } } } } : typeof Inner
|
||||
>Inner : typeof Inner
|
||||
|
||||
#foo = 10
|
||||
>#foo : number
|
||||
>10 : 10
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestWithStatics().#prop // OK
|
||||
>new TestWithStatics().#prop : number
|
||||
>new TestWithStatics() : TestWithStatics
|
||||
>TestWithStatics : typeof TestWithStatics
|
||||
}
|
||||
static C = class InnerInner {
|
||||
>C : typeof InnerInner
|
||||
>class InnerInner { m() { new TestWithStatics().#prop // OK new Inner().#foo; // OK } } : typeof InnerInner
|
||||
>InnerInner : typeof InnerInner
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestWithStatics().#prop // OK
|
||||
>new TestWithStatics().#prop : number
|
||||
>new TestWithStatics() : TestWithStatics
|
||||
>TestWithStatics : typeof TestWithStatics
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : () => typeof (Anonymous class)
|
||||
|
||||
return class {
|
||||
>class { m() { new TestWithStatics().#prop // OK new Inner().#foo; // OK } } : typeof (Anonymous class)
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestWithStatics().#prop // OK
|
||||
>new TestWithStatics().#prop : number
|
||||
>new TestWithStatics() : TestWithStatics
|
||||
>TestWithStatics : typeof TestWithStatics
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNonStatics {
|
||||
>TestNonStatics : TestNonStatics
|
||||
|
||||
#prop = 0
|
||||
>#prop : number
|
||||
>0 : 0
|
||||
|
||||
dd = new TestNonStatics().#prop; // OK
|
||||
>dd : number
|
||||
>new TestNonStatics().#prop : number
|
||||
>new TestNonStatics() : TestNonStatics
|
||||
>TestNonStatics : typeof TestNonStatics
|
||||
|
||||
["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : typeof Inner
|
||||
>"X_ z_ zz" : "X_ z_ zz"
|
||||
>class Inner { #foo = 10 m() { new TestNonStatics().#prop // Ok } C = class InnerInner { m() { new TestNonStatics().#prop // Ok new Inner().#foo; // Ok } } static M(){ return class { m() { new TestNonStatics().#prop // OK new Inner().#foo; // OK } } } } : typeof Inner
|
||||
>Inner : typeof Inner
|
||||
|
||||
#foo = 10
|
||||
>#foo : number
|
||||
>10 : 10
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestNonStatics().#prop // Ok
|
||||
>new TestNonStatics().#prop : number
|
||||
>new TestNonStatics() : TestNonStatics
|
||||
>TestNonStatics : typeof TestNonStatics
|
||||
}
|
||||
C = class InnerInner {
|
||||
>C : typeof InnerInner
|
||||
>class InnerInner { m() { new TestNonStatics().#prop // Ok new Inner().#foo; // Ok } } : typeof InnerInner
|
||||
>InnerInner : typeof InnerInner
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestNonStatics().#prop // Ok
|
||||
>new TestNonStatics().#prop : number
|
||||
>new TestNonStatics() : TestNonStatics
|
||||
>TestNonStatics : typeof TestNonStatics
|
||||
|
||||
new Inner().#foo; // Ok
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : () => typeof (Anonymous class)
|
||||
|
||||
return class {
|
||||
>class { m() { new TestNonStatics().#prop // OK new Inner().#foo; // OK } } : typeof (Anonymous class)
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestNonStatics().#prop // OK
|
||||
>new TestNonStatics().#prop : number
|
||||
>new TestNonStatics() : TestNonStatics
|
||||
>TestNonStatics : typeof TestNonStatics
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
-41
@@ -1,112 +1,110 @@
|
||||
//// [privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts]
|
||||
class TestWithErrors {
|
||||
#prop = 0
|
||||
static dd = new TestWithErrors().#prop; // Err
|
||||
//// [privateNameWhenNotUseDefineForClassFieldsInEsNext.ts]
|
||||
class TestWithStatics {
|
||||
#prop = 0
|
||||
static dd = new TestWithStatics().#prop; // OK
|
||||
static ["X_ z_ zz"] = class Inner {
|
||||
#foo = 10
|
||||
#foo = 10
|
||||
m() {
|
||||
new TestWithErrors().#prop // Err
|
||||
new TestWithStatics().#prop // OK
|
||||
}
|
||||
static C = class InnerInner {
|
||||
m() {
|
||||
new TestWithErrors().#prop // Err
|
||||
new Inner().#foo; // Err
|
||||
new TestWithStatics().#prop // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
return class {
|
||||
m() {
|
||||
new TestWithErrors().#prop // Err
|
||||
new TestWithStatics().#prop // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNoErrors {
|
||||
#prop = 0
|
||||
dd = new TestNoErrors().#prop; // OK
|
||||
class TestNonStatics {
|
||||
#prop = 0
|
||||
dd = new TestNonStatics().#prop; // OK
|
||||
["X_ z_ zz"] = class Inner {
|
||||
#foo = 10
|
||||
#foo = 10
|
||||
m() {
|
||||
new TestNoErrors().#prop // Ok
|
||||
new TestNonStatics().#prop // Ok
|
||||
}
|
||||
C = class InnerInner {
|
||||
m() {
|
||||
new TestNoErrors().#prop // Ok
|
||||
new TestNonStatics().#prop // Ok
|
||||
new Inner().#foo; // Ok
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static M(){
|
||||
return class {
|
||||
m() {
|
||||
new TestNoErrors().#prop // OK
|
||||
new TestNonStatics().#prop // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.js]
|
||||
//// [privateNameWhenNotUseDefineForClassFieldsInEsNext.js]
|
||||
"use strict";
|
||||
var _a;
|
||||
class TestWithErrors {
|
||||
class TestWithStatics {
|
||||
constructor() {
|
||||
this.#prop = 0;
|
||||
}
|
||||
#prop;
|
||||
}
|
||||
TestWithErrors.dd = new TestWithErrors().#prop; // Err
|
||||
TestWithErrors["X_ z_ zz"] = (_a = class Inner {
|
||||
static { this.dd = new TestWithStatics().#prop; } // OK
|
||||
static { this["X_ z_ zz"] = class Inner {
|
||||
constructor() {
|
||||
this.#foo = 10;
|
||||
}
|
||||
#foo;
|
||||
m() {
|
||||
new TestWithErrors().#prop; // Err
|
||||
new TestWithStatics().#prop; // OK
|
||||
}
|
||||
static { this.C = class InnerInner {
|
||||
m() {
|
||||
new TestWithStatics().#prop; // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
}; }
|
||||
static M() {
|
||||
return class {
|
||||
m() {
|
||||
new TestWithErrors().#prop; // Err
|
||||
new TestWithStatics().#prop; // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
_a.C = class InnerInner {
|
||||
m() {
|
||||
new TestWithErrors().#prop; // Err
|
||||
new _a().#foo; // Err
|
||||
}
|
||||
},
|
||||
_a);
|
||||
class TestNoErrors {
|
||||
}; }
|
||||
}
|
||||
class TestNonStatics {
|
||||
constructor() {
|
||||
this.#prop = 0;
|
||||
this.dd = new TestNoErrors().#prop; // OK
|
||||
this.dd = new TestNonStatics().#prop; // OK
|
||||
this["X_ z_ zz"] = class Inner {
|
||||
constructor() {
|
||||
this.#foo = 10;
|
||||
this.C = class InnerInner {
|
||||
m() {
|
||||
new TestNoErrors().#prop; // Ok
|
||||
new TestNonStatics().#prop; // Ok
|
||||
new Inner().#foo; // Ok
|
||||
}
|
||||
};
|
||||
}
|
||||
#foo;
|
||||
m() {
|
||||
new TestNoErrors().#prop; // Ok
|
||||
new TestNonStatics().#prop; // Ok
|
||||
}
|
||||
static M() {
|
||||
return class {
|
||||
m() {
|
||||
new TestNoErrors().#prop; // OK
|
||||
new TestNonStatics().#prop; // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
};
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
=== tests/cases/conformance/classes/members/privateNames/privateNameWhenNotUseDefineForClassFieldsInEsNext.ts ===
|
||||
class TestWithStatics {
|
||||
>TestWithStatics : Symbol(TestWithStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
#prop = 0
|
||||
>#prop : Symbol(TestWithStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 23))
|
||||
|
||||
static dd = new TestWithStatics().#prop; // OK
|
||||
>dd : Symbol(TestWithStatics.dd, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 1, 13))
|
||||
>new TestWithStatics().#prop : Symbol(TestWithStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 23))
|
||||
>TestWithStatics : Symbol(TestWithStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
static ["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : Symbol(TestWithStatics["X_ z_ zz"], Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 2, 44))
|
||||
>"X_ z_ zz" : Symbol(TestWithStatics["X_ z_ zz"], Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 2, 44))
|
||||
>Inner : Symbol(Inner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 3, 25))
|
||||
|
||||
#foo = 10
|
||||
>#foo : Symbol(Inner.#foo, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 3, 39))
|
||||
|
||||
m() {
|
||||
>m : Symbol(Inner.m, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 4, 18))
|
||||
|
||||
new TestWithStatics().#prop // OK
|
||||
>new TestWithStatics().#prop : Symbol(TestWithStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 23))
|
||||
>TestWithStatics : Symbol(TestWithStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
}
|
||||
static C = class InnerInner {
|
||||
>C : Symbol(Inner.C, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 7, 9))
|
||||
>InnerInner : Symbol(InnerInner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 8, 18))
|
||||
|
||||
m() {
|
||||
>m : Symbol(InnerInner.m, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 8, 37))
|
||||
|
||||
new TestWithStatics().#prop // OK
|
||||
>new TestWithStatics().#prop : Symbol(TestWithStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 23))
|
||||
>TestWithStatics : Symbol(TestWithStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 3, 39))
|
||||
>Inner : Symbol(Inner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 3, 25))
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : Symbol(Inner.M, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 13, 9))
|
||||
|
||||
return class {
|
||||
m() {
|
||||
>m : Symbol((Anonymous class).m, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 16, 26))
|
||||
|
||||
new TestWithStatics().#prop // OK
|
||||
>new TestWithStatics().#prop : Symbol(TestWithStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 23))
|
||||
>TestWithStatics : Symbol(TestWithStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 0, 0))
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 3, 39))
|
||||
>Inner : Symbol(Inner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 3, 25))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNonStatics {
|
||||
>TestNonStatics : Symbol(TestNonStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
#prop = 0
|
||||
>#prop : Symbol(TestNonStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 26, 22))
|
||||
|
||||
dd = new TestNonStatics().#prop; // OK
|
||||
>dd : Symbol(TestNonStatics.dd, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 27, 13))
|
||||
>new TestNonStatics().#prop : Symbol(TestNonStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 26, 22))
|
||||
>TestNonStatics : Symbol(TestNonStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : Symbol(TestNonStatics["X_ z_ zz"], Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 28, 36))
|
||||
>"X_ z_ zz" : Symbol(TestNonStatics["X_ z_ zz"], Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 28, 36))
|
||||
>Inner : Symbol(Inner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 29, 18))
|
||||
|
||||
#foo = 10
|
||||
>#foo : Symbol(Inner.#foo, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 29, 32))
|
||||
|
||||
m() {
|
||||
>m : Symbol(Inner.m, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 30, 18))
|
||||
|
||||
new TestNonStatics().#prop // Ok
|
||||
>new TestNonStatics().#prop : Symbol(TestNonStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 26, 22))
|
||||
>TestNonStatics : Symbol(TestNonStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
}
|
||||
C = class InnerInner {
|
||||
>C : Symbol(Inner.C, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 33, 9))
|
||||
>InnerInner : Symbol(InnerInner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 34, 11))
|
||||
|
||||
m() {
|
||||
>m : Symbol(InnerInner.m, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 34, 30))
|
||||
|
||||
new TestNonStatics().#prop // Ok
|
||||
>new TestNonStatics().#prop : Symbol(TestNonStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 26, 22))
|
||||
>TestNonStatics : Symbol(TestNonStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
new Inner().#foo; // Ok
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 29, 32))
|
||||
>Inner : Symbol(Inner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 29, 18))
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : Symbol(Inner.M, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 39, 9))
|
||||
|
||||
return class {
|
||||
m() {
|
||||
>m : Symbol((Anonymous class).m, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 42, 26))
|
||||
|
||||
new TestNonStatics().#prop // OK
|
||||
>new TestNonStatics().#prop : Symbol(TestNonStatics.#prop, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 26, 22))
|
||||
>TestNonStatics : Symbol(TestNonStatics, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 24, 1))
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : Symbol(Inner.#foo, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 29, 32))
|
||||
>Inner : Symbol(Inner, Decl(privateNameWhenNotUseDefineForClassFieldsInEsNext.ts, 29, 18))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
=== tests/cases/conformance/classes/members/privateNames/privateNameWhenNotUseDefineForClassFieldsInEsNext.ts ===
|
||||
class TestWithStatics {
|
||||
>TestWithStatics : TestWithStatics
|
||||
|
||||
#prop = 0
|
||||
>#prop : number
|
||||
>0 : 0
|
||||
|
||||
static dd = new TestWithStatics().#prop; // OK
|
||||
>dd : number
|
||||
>new TestWithStatics().#prop : number
|
||||
>new TestWithStatics() : TestWithStatics
|
||||
>TestWithStatics : typeof TestWithStatics
|
||||
|
||||
static ["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : typeof Inner
|
||||
>"X_ z_ zz" : "X_ z_ zz"
|
||||
>class Inner { #foo = 10 m() { new TestWithStatics().#prop // OK } static C = class InnerInner { m() { new TestWithStatics().#prop // OK new Inner().#foo; // OK } } static M(){ return class { m() { new TestWithStatics().#prop // OK new Inner().#foo; // OK } } } } : typeof Inner
|
||||
>Inner : typeof Inner
|
||||
|
||||
#foo = 10
|
||||
>#foo : number
|
||||
>10 : 10
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestWithStatics().#prop // OK
|
||||
>new TestWithStatics().#prop : number
|
||||
>new TestWithStatics() : TestWithStatics
|
||||
>TestWithStatics : typeof TestWithStatics
|
||||
}
|
||||
static C = class InnerInner {
|
||||
>C : typeof InnerInner
|
||||
>class InnerInner { m() { new TestWithStatics().#prop // OK new Inner().#foo; // OK } } : typeof InnerInner
|
||||
>InnerInner : typeof InnerInner
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestWithStatics().#prop // OK
|
||||
>new TestWithStatics().#prop : number
|
||||
>new TestWithStatics() : TestWithStatics
|
||||
>TestWithStatics : typeof TestWithStatics
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : () => typeof (Anonymous class)
|
||||
|
||||
return class {
|
||||
>class { m() { new TestWithStatics().#prop // OK new Inner().#foo; // OK } } : typeof (Anonymous class)
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestWithStatics().#prop // OK
|
||||
>new TestWithStatics().#prop : number
|
||||
>new TestWithStatics() : TestWithStatics
|
||||
>TestWithStatics : typeof TestWithStatics
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNonStatics {
|
||||
>TestNonStatics : TestNonStatics
|
||||
|
||||
#prop = 0
|
||||
>#prop : number
|
||||
>0 : 0
|
||||
|
||||
dd = new TestNonStatics().#prop; // OK
|
||||
>dd : number
|
||||
>new TestNonStatics().#prop : number
|
||||
>new TestNonStatics() : TestNonStatics
|
||||
>TestNonStatics : typeof TestNonStatics
|
||||
|
||||
["X_ z_ zz"] = class Inner {
|
||||
>["X_ z_ zz"] : typeof Inner
|
||||
>"X_ z_ zz" : "X_ z_ zz"
|
||||
>class Inner { #foo = 10 m() { new TestNonStatics().#prop // Ok } C = class InnerInner { m() { new TestNonStatics().#prop // Ok new Inner().#foo; // Ok } } static M(){ return class { m() { new TestNonStatics().#prop // OK new Inner().#foo; // OK } } } } : typeof Inner
|
||||
>Inner : typeof Inner
|
||||
|
||||
#foo = 10
|
||||
>#foo : number
|
||||
>10 : 10
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestNonStatics().#prop // Ok
|
||||
>new TestNonStatics().#prop : number
|
||||
>new TestNonStatics() : TestNonStatics
|
||||
>TestNonStatics : typeof TestNonStatics
|
||||
}
|
||||
C = class InnerInner {
|
||||
>C : typeof InnerInner
|
||||
>class InnerInner { m() { new TestNonStatics().#prop // Ok new Inner().#foo; // Ok } } : typeof InnerInner
|
||||
>InnerInner : typeof InnerInner
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestNonStatics().#prop // Ok
|
||||
>new TestNonStatics().#prop : number
|
||||
>new TestNonStatics() : TestNonStatics
|
||||
>TestNonStatics : typeof TestNonStatics
|
||||
|
||||
new Inner().#foo; // Ok
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
>M : () => typeof (Anonymous class)
|
||||
|
||||
return class {
|
||||
>class { m() { new TestNonStatics().#prop // OK new Inner().#foo; // OK } } : typeof (Anonymous class)
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
new TestNonStatics().#prop // OK
|
||||
>new TestNonStatics().#prop : number
|
||||
>new TestNonStatics() : TestNonStatics
|
||||
>TestNonStatics : typeof TestNonStatics
|
||||
|
||||
new Inner().#foo; // OK
|
||||
>new Inner().#foo : number
|
||||
>new Inner() : Inner
|
||||
>Inner : typeof Inner
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,8 +40,7 @@ class C extends B {
|
||||
|
||||
|
||||
//// [thisAndSuperInStaticMembers2.js]
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
||||
class C extends (_b = B) {
|
||||
class C extends B {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// these should be unaffected
|
||||
@@ -49,29 +48,28 @@ class C extends (_b = B) {
|
||||
this.y = this.x;
|
||||
this.z = super.f();
|
||||
}
|
||||
static { this.x = undefined; }
|
||||
static { this.y1 = this.x; }
|
||||
static { this.y2 = this.x(); }
|
||||
static { this.y3 = this?.x(); }
|
||||
static { this.y4 = this[("x")](); }
|
||||
static { this.y5 = this?.[("x")](); }
|
||||
static { this.z1 = super.a; }
|
||||
static { this.z2 = super["a"]; }
|
||||
static { this.z3 = super.f(); }
|
||||
static { this.z4 = super["f"](); }
|
||||
static { this.z5 = super.a = 0; }
|
||||
static { this.z6 = super.a += 1; }
|
||||
static { this.z7 = (() => { super.a = 0; })(); }
|
||||
static { this.z8 = [super.a] = [0]; }
|
||||
static { this.z9 = [super.a = 0] = [0]; }
|
||||
static { this.z10 = [...super.a] = [0]; }
|
||||
static { this.z11 = { x: super.a } = { x: 0 }; }
|
||||
static { this.z12 = { x: super.a = 0 } = { x: 0 }; }
|
||||
static { this.z13 = { ...super.a } = { x: 0 }; }
|
||||
static { this.z14 = ++super.a; }
|
||||
static { this.z15 = --super.a; }
|
||||
static { this.z16 = ++super[("a")]; }
|
||||
static { this.z17 = super.a++; }
|
||||
static { this.z18 = super.a ``; }
|
||||
}
|
||||
_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) ``;
|
||||
|
||||
@@ -40,8 +40,7 @@ class C extends B {
|
||||
|
||||
|
||||
//// [thisAndSuperInStaticMembers2.js]
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
||||
class C extends (_b = B) {
|
||||
class C extends B {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// these should be unaffected
|
||||
@@ -49,29 +48,28 @@ class C extends (_b = B) {
|
||||
this.y = this.x;
|
||||
this.z = super.f();
|
||||
}
|
||||
static { this.x = undefined; }
|
||||
static { this.y1 = this.x; }
|
||||
static { this.y2 = this.x(); }
|
||||
static { this.y3 = this?.x(); }
|
||||
static { this.y4 = this[("x")](); }
|
||||
static { this.y5 = this?.[("x")](); }
|
||||
static { this.z1 = super.a; }
|
||||
static { this.z2 = super["a"]; }
|
||||
static { this.z3 = super.f(); }
|
||||
static { this.z4 = super["f"](); }
|
||||
static { this.z5 = super.a = 0; }
|
||||
static { this.z6 = super.a += 1; }
|
||||
static { this.z7 = (() => { super.a = 0; })(); }
|
||||
static { this.z8 = [super.a] = [0]; }
|
||||
static { this.z9 = [super.a = 0] = [0]; }
|
||||
static { this.z10 = [...super.a] = [0]; }
|
||||
static { this.z11 = { x: super.a } = { x: 0 }; }
|
||||
static { this.z12 = { x: super.a = 0 } = { x: 0 }; }
|
||||
static { this.z13 = { ...super.a } = { x: 0 }; }
|
||||
static { this.z14 = ++super.a; }
|
||||
static { this.z15 = --super.a; }
|
||||
static { this.z16 = ++super[("a")]; }
|
||||
static { this.z17 = super.a++; }
|
||||
static { this.z18 = super.a ``; }
|
||||
}
|
||||
_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) ``;
|
||||
|
||||
+1
-1
@@ -2,8 +2,8 @@ class C {
|
||||
constructor() {
|
||||
this.foo = 10;
|
||||
}
|
||||
static { this.bar = 20; }
|
||||
}
|
||||
C.bar = 20;
|
||||
(function (C) {
|
||||
C.x = 10;
|
||||
})(C || (C = {}));
|
||||
|
||||
@@ -55,15 +55,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
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 {
|
||||
static { this.a = 1; }
|
||||
static { this.b = this.a + 1; }
|
||||
};
|
||||
C.a = 1;
|
||||
C.b = (void 0).a + 1;
|
||||
C = __decorate([
|
||||
foo
|
||||
], C);
|
||||
let D = class D extends C {
|
||||
static { this.c = 2; }
|
||||
static { this.d = this.c + 1; }
|
||||
static { this.e = super.a + this.c + 1; }
|
||||
static { this.f = () => this.c + 1; }
|
||||
static { this.ff = function () { this.c + 1; }; }
|
||||
static foo() {
|
||||
return this.c + 1;
|
||||
}
|
||||
@@ -74,20 +78,19 @@ let D = class D extends C {
|
||||
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 {
|
||||
static { this.a = 1; }
|
||||
static { this.b = this.a + 1; }
|
||||
}
|
||||
_a = CC;
|
||||
CC.a = 1;
|
||||
CC.b = _a.a + 1;
|
||||
class DD extends (_c = CC) {
|
||||
class DD extends CC {
|
||||
static { this.c = 2; }
|
||||
static { this.d = this.c + 1; }
|
||||
static { this.e = super.a + this.c + 1; }
|
||||
static { this.f = () => this.c + 1; }
|
||||
static { this.ff = function () { this.c + 1; }; }
|
||||
static foo() {
|
||||
return this.c + 1;
|
||||
}
|
||||
@@ -98,9 +101,3 @@ class DD extends (_c = CC) {
|
||||
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; };
|
||||
|
||||
@@ -55,15 +55,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
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 {
|
||||
static { this.a = 1; }
|
||||
static { this.b = this.a + 1; }
|
||||
};
|
||||
C.a = 1;
|
||||
C.b = (void 0).a + 1;
|
||||
C = __decorate([
|
||||
foo
|
||||
], C);
|
||||
let D = class D extends C {
|
||||
static { this.c = 2; }
|
||||
static { this.d = this.c + 1; }
|
||||
static { this.e = super.a + this.c + 1; }
|
||||
static { this.f = () => this.c + 1; }
|
||||
static { this.ff = function () { this.c + 1; }; }
|
||||
static foo() {
|
||||
return this.c + 1;
|
||||
}
|
||||
@@ -74,20 +78,19 @@ let D = class D extends C {
|
||||
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 {
|
||||
static { this.a = 1; }
|
||||
static { this.b = this.a + 1; }
|
||||
}
|
||||
_a = CC;
|
||||
CC.a = 1;
|
||||
CC.b = _a.a + 1;
|
||||
class DD extends (_c = CC) {
|
||||
class DD extends CC {
|
||||
static { this.c = 2; }
|
||||
static { this.d = this.c + 1; }
|
||||
static { this.e = super.a + this.c + 1; }
|
||||
static { this.f = () => this.c + 1; }
|
||||
static { this.ff = function () { this.c + 1; }; }
|
||||
static foo() {
|
||||
return this.c + 1;
|
||||
}
|
||||
@@ -98,9 +101,3 @@ class DD extends (_c = CC) {
|
||||
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; };
|
||||
|
||||
@@ -9,17 +9,14 @@ class C {
|
||||
|
||||
|
||||
//// [typeOfThisInStaticMembers12.js]
|
||||
var _a, _b, _c, _d;
|
||||
var _a, _b;
|
||||
class C {
|
||||
}
|
||||
_a = C;
|
||||
C.c = "foo";
|
||||
C.bar = (_b = class Inner {
|
||||
static { this.c = "foo"; }
|
||||
static { this.bar = class Inner {
|
||||
constructor() {
|
||||
this[_d] = 123;
|
||||
this[_b] = 123;
|
||||
}
|
||||
},
|
||||
_c = _a.c,
|
||||
_d = _a.c,
|
||||
_b[_c] = 123,
|
||||
_b);
|
||||
static { _a = this.c, _b = this.c; }
|
||||
static { this[_a] = 123; }
|
||||
}; }
|
||||
}
|
||||
|
||||
@@ -9,17 +9,14 @@ class C {
|
||||
|
||||
|
||||
//// [typeOfThisInStaticMembers12.js]
|
||||
var _a, _b, _c, _d;
|
||||
var _a, _b;
|
||||
class C {
|
||||
}
|
||||
_a = C;
|
||||
C.c = "foo";
|
||||
C.bar = (_b = class Inner {
|
||||
static { this.c = "foo"; }
|
||||
static { this.bar = class Inner {
|
||||
constructor() {
|
||||
this[_d] = 123;
|
||||
this[_b] = 123;
|
||||
}
|
||||
},
|
||||
_c = _a.c,
|
||||
_d = _a.c,
|
||||
_b[_c] = 123,
|
||||
_b);
|
||||
static { _a = this.c, _b = this.c; }
|
||||
static { this[_a] = 123; }
|
||||
}; }
|
||||
}
|
||||
|
||||
@@ -12,15 +12,12 @@ class D extends C {
|
||||
|
||||
|
||||
//// [typeOfThisInStaticMembers3.js]
|
||||
var _a, _b, _c;
|
||||
class C {
|
||||
static { this.a = 1; }
|
||||
static { this.b = this.a + 1; }
|
||||
}
|
||||
_a = C;
|
||||
C.a = 1;
|
||||
C.b = _a.a + 1;
|
||||
class D extends (_c = C) {
|
||||
class D extends C {
|
||||
static { this.c = 2; }
|
||||
static { this.d = this.c + 1; }
|
||||
static { this.e = super.a + this.c + 1; }
|
||||
}
|
||||
_b = D;
|
||||
D.c = 2;
|
||||
D.d = _b.c + 1;
|
||||
D.e = Reflect.get(_c, "a", _b) + _b.c + 1;
|
||||
|
||||
@@ -12,15 +12,12 @@ class D extends C {
|
||||
|
||||
|
||||
//// [typeOfThisInStaticMembers3.js]
|
||||
var _a, _b, _c;
|
||||
class C {
|
||||
static { this.a = 1; }
|
||||
static { this.b = this.a + 1; }
|
||||
}
|
||||
_a = C;
|
||||
C.a = 1;
|
||||
C.b = _a.a + 1;
|
||||
class D extends (_c = C) {
|
||||
class D extends C {
|
||||
static { this.c = 2; }
|
||||
static { this.d = this.c + 1; }
|
||||
static { this.e = super.a + this.c + 1; }
|
||||
}
|
||||
_b = D;
|
||||
D.c = 2;
|
||||
D.d = _b.c + 1;
|
||||
D.e = Reflect.get(_c, "a", _b) + _b.c + 1;
|
||||
|
||||
@@ -319,10 +319,10 @@ class C {
|
||||
this.readonlyCall = Symbol();
|
||||
this.readwriteCall = Symbol();
|
||||
}
|
||||
static { this.readonlyStaticCall = Symbol(); }
|
||||
static { this.readonlyStaticTypeAndCall = Symbol(); }
|
||||
static { this.readwriteStaticCall = Symbol(); }
|
||||
}
|
||||
C.readonlyStaticCall = Symbol();
|
||||
C.readonlyStaticTypeAndCall = Symbol();
|
||||
C.readwriteStaticCall = Symbol();
|
||||
const constInitToCReadonlyStaticCall = C.readonlyStaticCall;
|
||||
const constInitToCReadonlyStaticType = C.readonlyStaticType;
|
||||
const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall;
|
||||
@@ -379,18 +379,18 @@ class C0 {
|
||||
this.e = N.s;
|
||||
this.f = N["s"];
|
||||
}
|
||||
static { this.a = s; }
|
||||
static { this.b = N.s; }
|
||||
static { this.c = N["s"]; }
|
||||
static { this.d = s; }
|
||||
static { this.e = N.s; }
|
||||
static { this.f = N["s"]; }
|
||||
method1() { return s; }
|
||||
async method2() { return s; }
|
||||
async *method3() { yield s; }
|
||||
*method4() { yield s; }
|
||||
method5(p = s) { return p; }
|
||||
}
|
||||
C0.a = s;
|
||||
C0.b = N.s;
|
||||
C0.c = N["s"];
|
||||
C0.d = s;
|
||||
C0.e = N.s;
|
||||
C0.f = N["s"];
|
||||
// non-widening positions
|
||||
// element access
|
||||
o[s];
|
||||
@@ -417,8 +417,8 @@ Math.random() * 2 ? N["s"] : "a";
|
||||
[N.s]: "b",
|
||||
});
|
||||
class C1 {
|
||||
static { N.s, N.s; }
|
||||
}
|
||||
N.s, N.s;
|
||||
const o3 = {
|
||||
method1() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
|
||||
@@ -287,10 +287,10 @@ class C {
|
||||
this.readonlyCall = Symbol();
|
||||
this.readwriteCall = Symbol();
|
||||
}
|
||||
static { this.readonlyStaticCall = Symbol(); }
|
||||
static { this.readonlyStaticTypeAndCall = Symbol(); }
|
||||
static { this.readwriteStaticCall = Symbol(); }
|
||||
}
|
||||
C.readonlyStaticCall = Symbol();
|
||||
C.readonlyStaticTypeAndCall = Symbol();
|
||||
C.readwriteStaticCall = Symbol();
|
||||
const constInitToCReadonlyStaticCall = C.readonlyStaticCall;
|
||||
const constInitToCReadonlyStaticType = C.readonlyStaticType;
|
||||
const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall;
|
||||
@@ -347,18 +347,18 @@ class C0 {
|
||||
this.e = N.s;
|
||||
this.f = N["s"];
|
||||
}
|
||||
static { this.a = s; }
|
||||
static { this.b = N.s; }
|
||||
static { this.c = N["s"]; }
|
||||
static { this.d = s; }
|
||||
static { this.e = N.s; }
|
||||
static { this.f = N["s"]; }
|
||||
method1() { return s; }
|
||||
async method2() { return s; }
|
||||
async *method3() { yield s; }
|
||||
*method4() { yield s; }
|
||||
method5(p = s) { return p; }
|
||||
}
|
||||
C0.a = s;
|
||||
C0.b = N.s;
|
||||
C0.c = N["s"];
|
||||
C0.d = s;
|
||||
C0.e = N.s;
|
||||
C0.f = N["s"];
|
||||
// non-widening positions
|
||||
// element access
|
||||
o[s];
|
||||
@@ -385,8 +385,8 @@ Math.random() * 2 ? N["s"] : "a";
|
||||
[N.s]: "b",
|
||||
});
|
||||
class C1 {
|
||||
static { N.s, N.s; }
|
||||
}
|
||||
N.s, N.s;
|
||||
const o4 = {
|
||||
method1() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
|
||||
@@ -35,17 +35,17 @@ class C {
|
||||
this.readonlyCall = Symbol();
|
||||
this.readwriteCall = Symbol();
|
||||
}
|
||||
/**
|
||||
* @readonly
|
||||
*/
|
||||
static { this.readonlyStaticCall = Symbol(); }
|
||||
/**
|
||||
* @type {unique symbol}
|
||||
* @readonly
|
||||
*/
|
||||
static { this.readonlyStaticTypeAndCall = Symbol(); }
|
||||
static { this.readwriteStaticCall = Symbol(); }
|
||||
}
|
||||
/**
|
||||
* @readonly
|
||||
*/
|
||||
C.readonlyStaticCall = Symbol();
|
||||
/**
|
||||
* @type {unique symbol}
|
||||
* @readonly
|
||||
*/
|
||||
C.readonlyStaticTypeAndCall = Symbol();
|
||||
C.readwriteStaticCall = Symbol();
|
||||
|
||||
|
||||
//// [uniqueSymbolsDeclarationsInJs-out.d.ts]
|
||||
|
||||
@@ -51,15 +51,15 @@ class Test1 {
|
||||
}
|
||||
}
|
||||
class Test2 {
|
||||
static { this.p1 = 0; }
|
||||
static test() {
|
||||
Test2.p1;
|
||||
}
|
||||
}
|
||||
Test2.p1 = 0;
|
||||
class Test3 {
|
||||
static { this.p1 = 0; }
|
||||
static m1() { }
|
||||
}
|
||||
Test3.p1 = 0;
|
||||
class Test4 {
|
||||
static m1(n) {
|
||||
return (n === 0) ? 1 : (n * Test4.m1(n - 1));
|
||||
@@ -75,8 +75,8 @@ class Test5 {
|
||||
}
|
||||
}
|
||||
class Test6 {
|
||||
static { this.p1 = 0; }
|
||||
static test() {
|
||||
Test6["p1"];
|
||||
}
|
||||
}
|
||||
Test6.p1 = 0;
|
||||
|
||||
+19
-19
@@ -2,54 +2,54 @@
|
||||
// @target: esNext,es2020
|
||||
// @useDefineForClassFields: false
|
||||
|
||||
class TestWithErrors {
|
||||
#prop = 0
|
||||
static dd = new TestWithErrors().#prop; // Err
|
||||
class TestWithStatics {
|
||||
#prop = 0
|
||||
static dd = new TestWithStatics().#prop; // OK
|
||||
static ["X_ z_ zz"] = class Inner {
|
||||
#foo = 10
|
||||
#foo = 10
|
||||
m() {
|
||||
new TestWithErrors().#prop // Err
|
||||
new TestWithStatics().#prop // OK
|
||||
}
|
||||
static C = class InnerInner {
|
||||
m() {
|
||||
new TestWithErrors().#prop // Err
|
||||
new Inner().#foo; // Err
|
||||
new TestWithStatics().#prop // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
}
|
||||
|
||||
static M(){
|
||||
return class {
|
||||
m() {
|
||||
new TestWithErrors().#prop // Err
|
||||
new TestWithStatics().#prop // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestNoErrors {
|
||||
#prop = 0
|
||||
dd = new TestNoErrors().#prop; // OK
|
||||
class TestNonStatics {
|
||||
#prop = 0
|
||||
dd = new TestNonStatics().#prop; // OK
|
||||
["X_ z_ zz"] = class Inner {
|
||||
#foo = 10
|
||||
#foo = 10
|
||||
m() {
|
||||
new TestNoErrors().#prop // Ok
|
||||
new TestNonStatics().#prop // Ok
|
||||
}
|
||||
C = class InnerInner {
|
||||
m() {
|
||||
new TestNoErrors().#prop // Ok
|
||||
new TestNonStatics().#prop // Ok
|
||||
new Inner().#foo; // Ok
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static M(){
|
||||
return class {
|
||||
m() {
|
||||
new TestNoErrors().#prop // OK
|
||||
new TestNonStatics().#prop // OK
|
||||
new Inner().#foo; // OK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user