From d9bd52899cdf04335966077400567a6160ae820e Mon Sep 17 00:00:00 2001 From: Oleksandr Tarasiuk Date: Fri, 20 Nov 2026 16:08:23 +0200 Subject: [PATCH] fix(65598): preserve this binding in wrapped private member calls --- .../transformers/estransforms/classfields.go | 19 ++-- .../privateNameAccessorsCallExpression.js | 22 +++- ...privateNameAccessorsCallExpression.symbols | 40 ++++++- .../privateNameAccessorsCallExpression.types | 56 +++++++++ .../privateNameFieldCallExpression.js | 23 +++- .../privateNameFieldCallExpression.symbols | 40 ++++++- .../privateNameFieldCallExpression.types | 56 +++++++++ .../privateNameMethodCallExpression.js | 36 +++++- .../privateNameMethodCallExpression.symbols | 74 ++++++++++-- .../privateNameMethodCallExpression.types | 107 ++++++++++++++++++ .../privateNameStaticMethodCallExpression.js | 26 ++++- ...vateNameStaticMethodCallExpression.symbols | 53 +++++++-- ...rivateNameStaticMethodCallExpression.types | 60 ++++++++++ .../privateNameAccessorsCallExpression.ts | 9 ++ .../privateNameFieldCallExpression.ts | 9 ++ .../privateNameMethodCallExpression.ts | 14 +++ .../privateNameStaticMethodCallExpression.ts | 9 ++ 17 files changed, 608 insertions(+), 45 deletions(-) diff --git a/tsc/internal/transformers/estransforms/classfields.go b/tsc/internal/transformers/estransforms/classfields.go index 6a396d0573458..5513ec8111e84 100644 --- a/tsc/internal/transformers/estransforms/classfields.go +++ b/tsc/internal/transformers/estransforms/classfields.go @@ -1281,13 +1281,14 @@ func (tx *classFieldsTransformer) createCopiableReceiverExpr(receiver *ast.Expre } func (tx *classFieldsTransformer) visitCallExpression(node *ast.CallExpression) *ast.Node { - if ast.IsPropertyAccessExpression(node.Expression) && ast.IsPrivateIdentifier(node.Expression.AsPropertyAccessExpression().Name()) && - tx.accessPrivateIdentifier(node.Expression.AsPropertyAccessExpression().Name()) != nil { + expression := ast.SkipOuterExpressions(node.Expression, ast.OEKAll) + if ast.IsPropertyAccessExpression(expression) && ast.IsPrivateIdentifier(expression.AsPropertyAccessExpression().Name()) && + tx.accessPrivateIdentifier(expression.AsPropertyAccessExpression().Name()) != nil { // obj.#x() // Transform call expressions of private names to properly bind the `this` parameter. - thisArg, target := tx.createCallBinding(node.Expression) - visitedTarget := tx.Visitor().VisitNode(target) + thisArg, target := tx.createCallBinding(expression) + visitedTarget := tx.Factory().RestoreOuterExpressions(node.Expression, tx.Visitor().VisitNode(target), ast.OEKAll) visitedThisArg := tx.Visitor().VisitNode(thisArg) visitedArgs := tx.Visitor().VisitNodes(node.Arguments) allArgs := make([]*ast.Node, 0, 1+len(visitedArgs.Nodes)) @@ -1336,12 +1337,14 @@ func (tx *classFieldsTransformer) visitCallExpression(node *ast.CallExpression) } func (tx *classFieldsTransformer) visitTaggedTemplateExpression(node *ast.TaggedTemplateExpression) *ast.Node { - if ast.IsPropertyAccessExpression(node.Tag) && ast.IsPrivateIdentifier(node.Tag.AsPropertyAccessExpression().Name()) && - tx.accessPrivateIdentifier(node.Tag.AsPropertyAccessExpression().Name()) != nil { + tag := ast.SkipOuterExpressions(node.Tag, ast.OEKAll) + if ast.IsPropertyAccessExpression(tag) && ast.IsPrivateIdentifier(tag.AsPropertyAccessExpression().Name()) && + tx.accessPrivateIdentifier(tag.AsPropertyAccessExpression().Name()) != nil { // Bind the `this` correctly for tagged template literals when the tag is a private identifier property access. - thisArg, target := tx.createCallBinding(node.Tag) + thisArg, target := tx.createCallBinding(tag) + visitedTarget := tx.Factory().RestoreOuterExpressions(node.Tag, tx.Visitor().VisitNode(target), ast.OEKAll) bindExpr := tx.Factory().NewCallExpression( - tx.Factory().NewPropertyAccessExpression(tx.Visitor().VisitNode(target), nil, tx.Factory().NewIdentifier("bind"), ast.NodeFlagsNone), + tx.Factory().NewPropertyAccessExpression(visitedTarget, nil, tx.Factory().NewIdentifier("bind"), ast.NodeFlagsNone), nil, /*questionDotToken*/ nil, /*typeArguments*/ tx.Factory().NewNodeList([]*ast.Node{tx.Visitor().VisitNode(thisArg)}), diff --git a/tsc/testdata/baselines/reference/conformance/privateNameAccessorsCallExpression.js b/tsc/testdata/baselines/reference/conformance/privateNameAccessorsCallExpression.js index 114a87ec261c3..3fb60730e9309 100644 --- a/tsc/testdata/baselines/reference/conformance/privateNameAccessorsCallExpression.js +++ b/tsc/testdata/baselines/reference/conformance/privateNameAccessorsCallExpression.js @@ -16,6 +16,15 @@ class A { const b = new this.#fieldFunc2(0, ...arr, 3); const str = this.#fieldFunc2`head${1}middle${2}tail`; this.getInstance().#fieldFunc2`test${1}and${2}`; + + (this.#fieldFunc)(); + this.#fieldFunc!(); + (this.#fieldFunc as () => void)(); + (this.#fieldFunc satisfies () => void)(); + (this.#fieldFunc)?.(); + this.#fieldFunc!?.(); + (this.getInstance().#fieldFunc)(); + (this.#fieldFunc2)`test${1}and${2}`; } getInstance() { return new A(); } } @@ -34,7 +43,8 @@ class A { this.x = 1; } test() { - var _a; + var _a, _b; + var _c, _d; __classPrivateFieldGet(this, _A_instances, "a", _A_fieldFunc_get).call(this); const func = __classPrivateFieldGet(this, _A_instances, "a", _A_fieldFunc_get); func(); @@ -43,7 +53,15 @@ class A { __classPrivateFieldGet(this, _A_instances, "a", _A_fieldFunc2_get).call(this, 0, ...arr, 3); const b = new (__classPrivateFieldGet(this, _A_instances, "a", _A_fieldFunc2_get))(0, ...arr, 3); const str = __classPrivateFieldGet(this, _A_instances, "a", _A_fieldFunc2_get).bind(this) `head${1}middle${2}tail`; - __classPrivateFieldGet((_a = this.getInstance()), _A_instances, "a", _A_fieldFunc2_get).bind(_a) `test${1}and${2}`; + __classPrivateFieldGet((_c = this.getInstance()), _A_instances, "a", _A_fieldFunc2_get).bind(_c) `test${1}and${2}`; + (__classPrivateFieldGet(this, _A_instances, "a", _A_fieldFunc_get)).call(this); + __classPrivateFieldGet(this, _A_instances, "a", _A_fieldFunc_get).call(this); + __classPrivateFieldGet(this, _A_instances, "a", _A_fieldFunc_get).call(this); + __classPrivateFieldGet(this, _A_instances, "a", _A_fieldFunc_get).call(this); + (_a = (__classPrivateFieldGet(this, _A_instances, "a", _A_fieldFunc_get))) === null || _a === void 0 ? void 0 : _a.call(this); + (_b = __classPrivateFieldGet(this, _A_instances, "a", _A_fieldFunc_get)) === null || _b === void 0 ? void 0 : _b.call(this); + (__classPrivateFieldGet((_d = this.getInstance()), _A_instances, "a", _A_fieldFunc_get)).call(_d); + (__classPrivateFieldGet(this, _A_instances, "a", _A_fieldFunc2_get)).bind(this) `test${1}and${2}`; } getInstance() { return new A(); } } diff --git a/tsc/testdata/baselines/reference/conformance/privateNameAccessorsCallExpression.symbols b/tsc/testdata/baselines/reference/conformance/privateNameAccessorsCallExpression.symbols index 655e170412532..1785f5cb61309 100644 --- a/tsc/testdata/baselines/reference/conformance/privateNameAccessorsCallExpression.symbols +++ b/tsc/testdata/baselines/reference/conformance/privateNameAccessorsCallExpression.symbols @@ -55,11 +55,45 @@ class A { this.getInstance().#fieldFunc2`test${1}and${2}`; >this.getInstance().#fieldFunc2 : Symbol(A.#fieldFunc2, Decl(privateNameAccessorsCallExpression.ts, 1, 60)) ->this.getInstance : Symbol(A.getInstance, Decl(privateNameAccessorsCallExpression.ts, 15, 5)) +>this.getInstance : Symbol(A.getInstance, Decl(privateNameAccessorsCallExpression.ts, 24, 5)) +>this : Symbol(A, Decl(privateNameAccessorsCallExpression.ts, 0, 0)) +>getInstance : Symbol(A.getInstance, Decl(privateNameAccessorsCallExpression.ts, 24, 5)) + + (this.#fieldFunc)(); +>this.#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameAccessorsCallExpression.ts, 0, 9)) +>this : Symbol(A, Decl(privateNameAccessorsCallExpression.ts, 0, 0)) + + this.#fieldFunc!(); +>this.#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameAccessorsCallExpression.ts, 0, 9)) +>this : Symbol(A, Decl(privateNameAccessorsCallExpression.ts, 0, 0)) + + (this.#fieldFunc as () => void)(); +>this.#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameAccessorsCallExpression.ts, 0, 9)) +>this : Symbol(A, Decl(privateNameAccessorsCallExpression.ts, 0, 0)) + + (this.#fieldFunc satisfies () => void)(); +>this.#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameAccessorsCallExpression.ts, 0, 9)) +>this : Symbol(A, Decl(privateNameAccessorsCallExpression.ts, 0, 0)) + + (this.#fieldFunc)?.(); +>this.#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameAccessorsCallExpression.ts, 0, 9)) +>this : Symbol(A, Decl(privateNameAccessorsCallExpression.ts, 0, 0)) + + this.#fieldFunc!?.(); +>this.#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameAccessorsCallExpression.ts, 0, 9)) +>this : Symbol(A, Decl(privateNameAccessorsCallExpression.ts, 0, 0)) + + (this.getInstance().#fieldFunc)(); +>this.getInstance().#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameAccessorsCallExpression.ts, 0, 9)) +>this.getInstance : Symbol(A.getInstance, Decl(privateNameAccessorsCallExpression.ts, 24, 5)) +>this : Symbol(A, Decl(privateNameAccessorsCallExpression.ts, 0, 0)) +>getInstance : Symbol(A.getInstance, Decl(privateNameAccessorsCallExpression.ts, 24, 5)) + + (this.#fieldFunc2)`test${1}and${2}`; +>this.#fieldFunc2 : Symbol(A.#fieldFunc2, Decl(privateNameAccessorsCallExpression.ts, 1, 60)) >this : Symbol(A, Decl(privateNameAccessorsCallExpression.ts, 0, 0)) ->getInstance : Symbol(A.getInstance, Decl(privateNameAccessorsCallExpression.ts, 15, 5)) } getInstance() { return new A(); } ->getInstance : Symbol(A.getInstance, Decl(privateNameAccessorsCallExpression.ts, 15, 5)) +>getInstance : Symbol(A.getInstance, Decl(privateNameAccessorsCallExpression.ts, 24, 5)) >A : Symbol(A, Decl(privateNameAccessorsCallExpression.ts, 0, 0)) } diff --git a/tsc/testdata/baselines/reference/conformance/privateNameAccessorsCallExpression.types b/tsc/testdata/baselines/reference/conformance/privateNameAccessorsCallExpression.types index 837fab3051747..60e4f2e4fd0ad 100644 --- a/tsc/testdata/baselines/reference/conformance/privateNameAccessorsCallExpression.types +++ b/tsc/testdata/baselines/reference/conformance/privateNameAccessorsCallExpression.types @@ -88,6 +88,62 @@ class A { >getInstance : () => A >`test${1}and${2}` : string >1 : 1 +>2 : 2 + + (this.#fieldFunc)(); +>(this.#fieldFunc)() : void +>(this.#fieldFunc) : () => void +>this.#fieldFunc : () => void +>this : this + + this.#fieldFunc!(); +>this.#fieldFunc!() : void +>this.#fieldFunc! : () => void +>this.#fieldFunc : () => void +>this : this + + (this.#fieldFunc as () => void)(); +>(this.#fieldFunc as () => void)() : void +>(this.#fieldFunc as () => void) : () => void +>this.#fieldFunc as () => void : () => void +>this.#fieldFunc : () => void +>this : this + + (this.#fieldFunc satisfies () => void)(); +>(this.#fieldFunc satisfies () => void)() : void +>(this.#fieldFunc satisfies () => void) : () => void +>this.#fieldFunc satisfies () => void : () => void +>this.#fieldFunc : () => void +>this : this + + (this.#fieldFunc)?.(); +>(this.#fieldFunc)?.() : void +>(this.#fieldFunc) : () => void +>this.#fieldFunc : () => void +>this : this + + this.#fieldFunc!?.(); +>this.#fieldFunc!?.() : void +>this.#fieldFunc! : () => void +>this.#fieldFunc : () => void +>this : this + + (this.getInstance().#fieldFunc)(); +>(this.getInstance().#fieldFunc)() : void +>(this.getInstance().#fieldFunc) : () => void +>this.getInstance().#fieldFunc : () => void +>this.getInstance() : A +>this.getInstance : () => A +>this : this +>getInstance : () => A + + (this.#fieldFunc2)`test${1}and${2}`; +>(this.#fieldFunc2)`test${1}and${2}` : void +>(this.#fieldFunc2) : (a: any, ...b: any[]) => void +>this.#fieldFunc2 : (a: any, ...b: any[]) => void +>this : this +>`test${1}and${2}` : string +>1 : 1 >2 : 2 } getInstance() { return new A(); } diff --git a/tsc/testdata/baselines/reference/conformance/privateNameFieldCallExpression.js b/tsc/testdata/baselines/reference/conformance/privateNameFieldCallExpression.js index 5cc18ebef2e52..e8dd3a3a3a928 100644 --- a/tsc/testdata/baselines/reference/conformance/privateNameFieldCallExpression.js +++ b/tsc/testdata/baselines/reference/conformance/privateNameFieldCallExpression.js @@ -17,6 +17,15 @@ class A { const b = new this.#fieldFunc2(0, ...arr, 3); const str = this.#fieldFunc2`head${1}middle${2}tail`; this.getInstance().#fieldFunc2`test${1}and${2}`; + + (this.#fieldFunc)(); + this.#fieldFunc!(); + (this.#fieldFunc as () => void)(); + (this.#fieldFunc satisfies () => void)(); + (this.#fieldFunc)?.(); + this.#fieldFunc!?.(); + (this.getInstance().#fieldFunc)(); + (this.#fieldFunc2)`test${1}and${2}`; } getInstance() { return new A(); } } @@ -37,8 +46,8 @@ class A { this.x = 1; } test() { - var _a; - var _b; + var _a, _b, _c; + var _d, _e; __classPrivateFieldGet(this, _A_fieldFunc, "f").call(this); (_a = __classPrivateFieldGet(this, _A_fieldFunc, "f")) === null || _a === void 0 ? void 0 : _a.call(this); const func = __classPrivateFieldGet(this, _A_fieldFunc, "f"); @@ -48,7 +57,15 @@ class A { __classPrivateFieldGet(this, _A_fieldFunc2, "f").call(this, 0, ...arr, 3); const b = new (__classPrivateFieldGet(this, _A_fieldFunc2, "f"))(0, ...arr, 3); const str = __classPrivateFieldGet(this, _A_fieldFunc2, "f").bind(this) `head${1}middle${2}tail`; - __classPrivateFieldGet((_b = this.getInstance()), _A_fieldFunc2, "f").bind(_b) `test${1}and${2}`; + __classPrivateFieldGet((_d = this.getInstance()), _A_fieldFunc2, "f").bind(_d) `test${1}and${2}`; + (__classPrivateFieldGet(this, _A_fieldFunc, "f")).call(this); + __classPrivateFieldGet(this, _A_fieldFunc, "f").call(this); + __classPrivateFieldGet(this, _A_fieldFunc, "f").call(this); + __classPrivateFieldGet(this, _A_fieldFunc, "f").call(this); + (_b = (__classPrivateFieldGet(this, _A_fieldFunc, "f"))) === null || _b === void 0 ? void 0 : _b.call(this); + (_c = __classPrivateFieldGet(this, _A_fieldFunc, "f")) === null || _c === void 0 ? void 0 : _c.call(this); + (__classPrivateFieldGet((_e = this.getInstance()), _A_fieldFunc, "f")).call(_e); + (__classPrivateFieldGet(this, _A_fieldFunc2, "f")).bind(this) `test${1}and${2}`; } getInstance() { return new A(); } } diff --git a/tsc/testdata/baselines/reference/conformance/privateNameFieldCallExpression.symbols b/tsc/testdata/baselines/reference/conformance/privateNameFieldCallExpression.symbols index 37287286c42ec..9de10ee74bbc2 100644 --- a/tsc/testdata/baselines/reference/conformance/privateNameFieldCallExpression.symbols +++ b/tsc/testdata/baselines/reference/conformance/privateNameFieldCallExpression.symbols @@ -59,12 +59,46 @@ class A { this.getInstance().#fieldFunc2`test${1}and${2}`; >this.getInstance().#fieldFunc2 : Symbol(A.#fieldFunc2, Decl(privateNameFieldCallExpression.ts, 1, 45)) ->this.getInstance : Symbol(A.getInstance, Decl(privateNameFieldCallExpression.ts, 16, 5)) +>this.getInstance : Symbol(A.getInstance, Decl(privateNameFieldCallExpression.ts, 25, 5)) +>this : Symbol(A, Decl(privateNameFieldCallExpression.ts, 0, 0)) +>getInstance : Symbol(A.getInstance, Decl(privateNameFieldCallExpression.ts, 25, 5)) + + (this.#fieldFunc)(); +>this.#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameFieldCallExpression.ts, 0, 9)) +>this : Symbol(A, Decl(privateNameFieldCallExpression.ts, 0, 0)) + + this.#fieldFunc!(); +>this.#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameFieldCallExpression.ts, 0, 9)) +>this : Symbol(A, Decl(privateNameFieldCallExpression.ts, 0, 0)) + + (this.#fieldFunc as () => void)(); +>this.#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameFieldCallExpression.ts, 0, 9)) +>this : Symbol(A, Decl(privateNameFieldCallExpression.ts, 0, 0)) + + (this.#fieldFunc satisfies () => void)(); +>this.#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameFieldCallExpression.ts, 0, 9)) +>this : Symbol(A, Decl(privateNameFieldCallExpression.ts, 0, 0)) + + (this.#fieldFunc)?.(); +>this.#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameFieldCallExpression.ts, 0, 9)) +>this : Symbol(A, Decl(privateNameFieldCallExpression.ts, 0, 0)) + + this.#fieldFunc!?.(); +>this.#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameFieldCallExpression.ts, 0, 9)) +>this : Symbol(A, Decl(privateNameFieldCallExpression.ts, 0, 0)) + + (this.getInstance().#fieldFunc)(); +>this.getInstance().#fieldFunc : Symbol(A.#fieldFunc, Decl(privateNameFieldCallExpression.ts, 0, 9)) +>this.getInstance : Symbol(A.getInstance, Decl(privateNameFieldCallExpression.ts, 25, 5)) +>this : Symbol(A, Decl(privateNameFieldCallExpression.ts, 0, 0)) +>getInstance : Symbol(A.getInstance, Decl(privateNameFieldCallExpression.ts, 25, 5)) + + (this.#fieldFunc2)`test${1}and${2}`; +>this.#fieldFunc2 : Symbol(A.#fieldFunc2, Decl(privateNameFieldCallExpression.ts, 1, 45)) >this : Symbol(A, Decl(privateNameFieldCallExpression.ts, 0, 0)) ->getInstance : Symbol(A.getInstance, Decl(privateNameFieldCallExpression.ts, 16, 5)) } getInstance() { return new A(); } ->getInstance : Symbol(A.getInstance, Decl(privateNameFieldCallExpression.ts, 16, 5)) +>getInstance : Symbol(A.getInstance, Decl(privateNameFieldCallExpression.ts, 25, 5)) >A : Symbol(A, Decl(privateNameFieldCallExpression.ts, 0, 0)) } diff --git a/tsc/testdata/baselines/reference/conformance/privateNameFieldCallExpression.types b/tsc/testdata/baselines/reference/conformance/privateNameFieldCallExpression.types index 48aaa10e1fe37..e7492d528c57f 100644 --- a/tsc/testdata/baselines/reference/conformance/privateNameFieldCallExpression.types +++ b/tsc/testdata/baselines/reference/conformance/privateNameFieldCallExpression.types @@ -93,6 +93,62 @@ class A { >getInstance : () => A >`test${1}and${2}` : string >1 : 1 +>2 : 2 + + (this.#fieldFunc)(); +>(this.#fieldFunc)() : void +>(this.#fieldFunc) : () => void +>this.#fieldFunc : () => void +>this : this + + this.#fieldFunc!(); +>this.#fieldFunc!() : void +>this.#fieldFunc! : () => void +>this.#fieldFunc : () => void +>this : this + + (this.#fieldFunc as () => void)(); +>(this.#fieldFunc as () => void)() : void +>(this.#fieldFunc as () => void) : () => void +>this.#fieldFunc as () => void : () => void +>this.#fieldFunc : () => void +>this : this + + (this.#fieldFunc satisfies () => void)(); +>(this.#fieldFunc satisfies () => void)() : void +>(this.#fieldFunc satisfies () => void) : () => void +>this.#fieldFunc satisfies () => void : () => void +>this.#fieldFunc : () => void +>this : this + + (this.#fieldFunc)?.(); +>(this.#fieldFunc)?.() : void +>(this.#fieldFunc) : () => void +>this.#fieldFunc : () => void +>this : this + + this.#fieldFunc!?.(); +>this.#fieldFunc!?.() : void +>this.#fieldFunc! : () => void +>this.#fieldFunc : () => void +>this : this + + (this.getInstance().#fieldFunc)(); +>(this.getInstance().#fieldFunc)() : void +>(this.getInstance().#fieldFunc) : () => void +>this.getInstance().#fieldFunc : () => void +>this.getInstance() : A +>this.getInstance : () => A +>this : this +>getInstance : () => A + + (this.#fieldFunc2)`test${1}and${2}`; +>(this.#fieldFunc2)`test${1}and${2}` : void +>(this.#fieldFunc2) : (a: any, ...b: any[]) => void +>this.#fieldFunc2 : (a: any, ...b: any[]) => void +>this : this +>`test${1}and${2}` : string +>1 : 1 >2 : 2 } getInstance() { return new A(); } diff --git a/tsc/testdata/baselines/reference/conformance/privateNameMethodCallExpression.js b/tsc/testdata/baselines/reference/conformance/privateNameMethodCallExpression.js index 96d6a37cc3b12..713b5fc91cfe5 100644 --- a/tsc/testdata/baselines/reference/conformance/privateNameMethodCallExpression.js +++ b/tsc/testdata/baselines/reference/conformance/privateNameMethodCallExpression.js @@ -21,6 +21,20 @@ class AA { this.getInstance().#method2(0, ...arr, 3); const b2 = new (this.getInstance().#method2)(0, ...arr, 3); //Error const str2 = this.getInstance().#method2`head${1}middle${2}tail`; + + (this.#method)(); + this.#method!(); + (this.#method as () => void)(); + (this.#method satisfies () => void)(); + (((this.#method as () => void)!))(); + (this.#method)?.(); + this.#method!?.(); + (this.getInstance().#method2)(0, ...arr, 3); + (this.#method2)`test${1}and${2}`; + this.#method2!`test${1}and${2}`; + (this.#method2 as any)`test${1}and${2}`; + (this.#method2 satisfies Function)`test${1}and${2}`; + (0, this.#method)(); } getInstance() { return new AA(); } } @@ -42,7 +56,8 @@ class AA { ; ; test() { - var _a, _b, _c; + var _a, _b; + var _c, _d, _e, _f; __classPrivateFieldGet(this, _AA_instances, "m", _AA_method).call(this); const func = __classPrivateFieldGet(this, _AA_instances, "m", _AA_method); func(); @@ -51,10 +66,23 @@ class AA { __classPrivateFieldGet(this, _AA_instances, "m", _AA_method2).call(this, 0, ...arr, 3); const b = new (__classPrivateFieldGet(this, _AA_instances, "m", _AA_method2))(0, ...arr, 3); //Error const str = __classPrivateFieldGet(this, _AA_instances, "m", _AA_method2).bind(this) `head${1}middle${2}tail`; - __classPrivateFieldGet((_a = this.getInstance()), _AA_instances, "m", _AA_method2).bind(_a) `test${1}and${2}`; - __classPrivateFieldGet((_b = this.getInstance()), _AA_instances, "m", _AA_method2).call(_b, 0, ...arr, 3); + __classPrivateFieldGet((_c = this.getInstance()), _AA_instances, "m", _AA_method2).bind(_c) `test${1}and${2}`; + __classPrivateFieldGet((_d = this.getInstance()), _AA_instances, "m", _AA_method2).call(_d, 0, ...arr, 3); const b2 = new (__classPrivateFieldGet(this.getInstance(), _AA_instances, "m", _AA_method2))(0, ...arr, 3); //Error - const str2 = __classPrivateFieldGet((_c = this.getInstance()), _AA_instances, "m", _AA_method2).bind(_c) `head${1}middle${2}tail`; + const str2 = __classPrivateFieldGet((_e = this.getInstance()), _AA_instances, "m", _AA_method2).bind(_e) `head${1}middle${2}tail`; + (__classPrivateFieldGet(this, _AA_instances, "m", _AA_method)).call(this); + __classPrivateFieldGet(this, _AA_instances, "m", _AA_method).call(this); + __classPrivateFieldGet(this, _AA_instances, "m", _AA_method).call(this); + __classPrivateFieldGet(this, _AA_instances, "m", _AA_method).call(this); + ((__classPrivateFieldGet(this, _AA_instances, "m", _AA_method))).call(this); + (_a = (__classPrivateFieldGet(this, _AA_instances, "m", _AA_method))) === null || _a === void 0 ? void 0 : _a.call(this); + (_b = __classPrivateFieldGet(this, _AA_instances, "m", _AA_method)) === null || _b === void 0 ? void 0 : _b.call(this); + (__classPrivateFieldGet((_f = this.getInstance()), _AA_instances, "m", _AA_method2)).call(_f, 0, ...arr, 3); + (__classPrivateFieldGet(this, _AA_instances, "m", _AA_method2)).bind(this) `test${1}and${2}`; + __classPrivateFieldGet(this, _AA_instances, "m", _AA_method2).bind(this) `test${1}and${2}`; + __classPrivateFieldGet(this, _AA_instances, "m", _AA_method2).bind(this) `test${1}and${2}`; + __classPrivateFieldGet(this, _AA_instances, "m", _AA_method2).bind(this) `test${1}and${2}`; + (0, __classPrivateFieldGet(this, _AA_instances, "m", _AA_method))(); } getInstance() { return new AA(); } } diff --git a/tsc/testdata/baselines/reference/conformance/privateNameMethodCallExpression.symbols b/tsc/testdata/baselines/reference/conformance/privateNameMethodCallExpression.symbols index 0488f95f6775b..14112f3d62c94 100644 --- a/tsc/testdata/baselines/reference/conformance/privateNameMethodCallExpression.symbols +++ b/tsc/testdata/baselines/reference/conformance/privateNameMethodCallExpression.symbols @@ -58,34 +58,90 @@ class AA { this.getInstance().#method2`test${1}and${2}`; >this.getInstance().#method2 : Symbol(AA.#method2, Decl(privateNameMethodCallExpression.ts, 1, 31)) ->this.getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 20, 5)) +>this.getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 34, 5)) >this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) ->getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 20, 5)) +>getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 34, 5)) this.getInstance().#method2(0, ...arr, 3); >this.getInstance().#method2 : Symbol(AA.#method2, Decl(privateNameMethodCallExpression.ts, 1, 31)) ->this.getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 20, 5)) +>this.getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 34, 5)) >this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) ->getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 20, 5)) +>getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 34, 5)) >arr : Symbol(arr, Decl(privateNameMethodCallExpression.ts, 10, 13)) const b2 = new (this.getInstance().#method2)(0, ...arr, 3); //Error >b2 : Symbol(b2, Decl(privateNameMethodCallExpression.ts, 18, 13)) >this.getInstance().#method2 : Symbol(AA.#method2, Decl(privateNameMethodCallExpression.ts, 1, 31)) ->this.getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 20, 5)) +>this.getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 34, 5)) >this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) ->getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 20, 5)) +>getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 34, 5)) >arr : Symbol(arr, Decl(privateNameMethodCallExpression.ts, 10, 13)) const str2 = this.getInstance().#method2`head${1}middle${2}tail`; >str2 : Symbol(str2, Decl(privateNameMethodCallExpression.ts, 19, 13)) >this.getInstance().#method2 : Symbol(AA.#method2, Decl(privateNameMethodCallExpression.ts, 1, 31)) ->this.getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 20, 5)) +>this.getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 34, 5)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) +>getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 34, 5)) + + (this.#method)(); +>this.#method : Symbol(AA.#method, Decl(privateNameMethodCallExpression.ts, 0, 10)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) + + this.#method!(); +>this.#method : Symbol(AA.#method, Decl(privateNameMethodCallExpression.ts, 0, 10)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) + + (this.#method as () => void)(); +>this.#method : Symbol(AA.#method, Decl(privateNameMethodCallExpression.ts, 0, 10)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) + + (this.#method satisfies () => void)(); +>this.#method : Symbol(AA.#method, Decl(privateNameMethodCallExpression.ts, 0, 10)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) + + (((this.#method as () => void)!))(); +>this.#method : Symbol(AA.#method, Decl(privateNameMethodCallExpression.ts, 0, 10)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) + + (this.#method)?.(); +>this.#method : Symbol(AA.#method, Decl(privateNameMethodCallExpression.ts, 0, 10)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) + + this.#method!?.(); +>this.#method : Symbol(AA.#method, Decl(privateNameMethodCallExpression.ts, 0, 10)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) + + (this.getInstance().#method2)(0, ...arr, 3); +>this.getInstance().#method2 : Symbol(AA.#method2, Decl(privateNameMethodCallExpression.ts, 1, 31)) +>this.getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 34, 5)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) +>getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 34, 5)) +>arr : Symbol(arr, Decl(privateNameMethodCallExpression.ts, 10, 13)) + + (this.#method2)`test${1}and${2}`; +>this.#method2 : Symbol(AA.#method2, Decl(privateNameMethodCallExpression.ts, 1, 31)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) + + this.#method2!`test${1}and${2}`; +>this.#method2 : Symbol(AA.#method2, Decl(privateNameMethodCallExpression.ts, 1, 31)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) + + (this.#method2 as any)`test${1}and${2}`; +>this.#method2 : Symbol(AA.#method2, Decl(privateNameMethodCallExpression.ts, 1, 31)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) + + (this.#method2 satisfies Function)`test${1}and${2}`; +>this.#method2 : Symbol(AA.#method2, Decl(privateNameMethodCallExpression.ts, 1, 31)) +>this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + + (0, this.#method)(); +>this.#method : Symbol(AA.#method, Decl(privateNameMethodCallExpression.ts, 0, 10)) >this : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) ->getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 20, 5)) } getInstance() { return new AA(); } ->getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 20, 5)) +>getInstance : Symbol(AA.getInstance, Decl(privateNameMethodCallExpression.ts, 34, 5)) >AA : Symbol(AA, Decl(privateNameMethodCallExpression.ts, 0, 0)) } diff --git a/tsc/testdata/baselines/reference/conformance/privateNameMethodCallExpression.types b/tsc/testdata/baselines/reference/conformance/privateNameMethodCallExpression.types index 8a1fa63e1e9cc..175d8a8232d2d 100644 --- a/tsc/testdata/baselines/reference/conformance/privateNameMethodCallExpression.types +++ b/tsc/testdata/baselines/reference/conformance/privateNameMethodCallExpression.types @@ -125,6 +125,113 @@ class AA { >`head${1}middle${2}tail` : string >1 : 1 >2 : 2 + + (this.#method)(); +>(this.#method)() : void +>(this.#method) : () => void +>this.#method : () => void +>this : this + + this.#method!(); +>this.#method!() : void +>this.#method! : () => void +>this.#method : () => void +>this : this + + (this.#method as () => void)(); +>(this.#method as () => void)() : void +>(this.#method as () => void) : () => void +>this.#method as () => void : () => void +>this.#method : () => void +>this : this + + (this.#method satisfies () => void)(); +>(this.#method satisfies () => void)() : void +>(this.#method satisfies () => void) : () => void +>this.#method satisfies () => void : () => void +>this.#method : () => void +>this : this + + (((this.#method as () => void)!))(); +>(((this.#method as () => void)!))() : void +>(((this.#method as () => void)!)) : () => void +>((this.#method as () => void)!) : () => void +>(this.#method as () => void)! : () => void +>(this.#method as () => void) : () => void +>this.#method as () => void : () => void +>this.#method : () => void +>this : this + + (this.#method)?.(); +>(this.#method)?.() : void +>(this.#method) : () => void +>this.#method : () => void +>this : this + + this.#method!?.(); +>this.#method!?.() : void +>this.#method! : () => void +>this.#method : () => void +>this : this + + (this.getInstance().#method2)(0, ...arr, 3); +>(this.getInstance().#method2)(0, ...arr, 3) : void +>(this.getInstance().#method2) : (a: any, ...b: any[]) => void +>this.getInstance().#method2 : (a: any, ...b: any[]) => void +>this.getInstance() : AA +>this.getInstance : () => AA +>this : this +>getInstance : () => AA +>0 : 0 +>...arr : number +>arr : number[] +>3 : 3 + + (this.#method2)`test${1}and${2}`; +>(this.#method2)`test${1}and${2}` : void +>(this.#method2) : (a: any, ...b: any[]) => void +>this.#method2 : (a: any, ...b: any[]) => void +>this : this +>`test${1}and${2}` : string +>1 : 1 +>2 : 2 + + this.#method2!`test${1}and${2}`; +>this.#method2!`test${1}and${2}` : void +>this.#method2! : (a: any, ...b: any[]) => void +>this.#method2 : (a: any, ...b: any[]) => void +>this : this +>`test${1}and${2}` : string +>1 : 1 +>2 : 2 + + (this.#method2 as any)`test${1}and${2}`; +>(this.#method2 as any)`test${1}and${2}` : any +>(this.#method2 as any) : any +>this.#method2 as any : any +>this.#method2 : (a: any, ...b: any[]) => void +>this : this +>`test${1}and${2}` : string +>1 : 1 +>2 : 2 + + (this.#method2 satisfies Function)`test${1}and${2}`; +>(this.#method2 satisfies Function)`test${1}and${2}` : void +>(this.#method2 satisfies Function) : (a: any, ...b: any[]) => void +>this.#method2 satisfies Function : (a: any, ...b: any[]) => void +>this.#method2 : (a: any, ...b: any[]) => void +>this : this +>`test${1}and${2}` : string +>1 : 1 +>2 : 2 + + (0, this.#method)(); +>(0, this.#method)() : void +>(0, this.#method) : () => void +>0, this.#method : () => void +>0 : 0 +>this.#method : () => void +>this : this } getInstance() { return new AA(); } >getInstance : () => AA diff --git a/tsc/testdata/baselines/reference/conformance/privateNameStaticMethodCallExpression.js b/tsc/testdata/baselines/reference/conformance/privateNameStaticMethodCallExpression.js index b6ef055f96275..1e350d7a30a94 100644 --- a/tsc/testdata/baselines/reference/conformance/privateNameStaticMethodCallExpression.js +++ b/tsc/testdata/baselines/reference/conformance/privateNameStaticMethodCallExpression.js @@ -21,6 +21,15 @@ class AA { AA.getClass().#method2(0, ...arr, 3); const b2 = new (AA.getClass().#method2)(0, ...arr, 3); //Error const str2 = AA.getClass().#method2`head${1}middle${2}tail`; + + (AA.#method)(); + AA.#method!(); + (AA.#method as () => void)(); + (AA.#method satisfies () => void)(); + (AA.#method)?.(); + AA.#method!?.(); + (AA.getClass().#method2)(0, ...arr, 3); + (AA.#method2)`test${1}and${2}`; } static getClass() { return AA; } } @@ -38,7 +47,8 @@ class AA { ; ; test() { - var _b, _c, _d; + var _b, _c; + var _d, _e, _f, _g; __classPrivateFieldGet(_a, _a, "m", _AA_method).call(_a); const func = __classPrivateFieldGet(_a, _a, "m", _AA_method); func(); @@ -47,10 +57,18 @@ class AA { __classPrivateFieldGet(_a, _a, "m", _AA_method2).call(_a, 0, ...arr, 3); const b = new (__classPrivateFieldGet(_a, _a, "m", _AA_method2))(0, ...arr, 3); //Error const str = __classPrivateFieldGet(_a, _a, "m", _AA_method2).bind(_a) `head${1}middle${2}tail`; - __classPrivateFieldGet((_b = _a.getClass()), _a, "m", _AA_method2).bind(_b) `test${1}and${2}`; - __classPrivateFieldGet((_c = _a.getClass()), _a, "m", _AA_method2).call(_c, 0, ...arr, 3); + __classPrivateFieldGet((_d = _a.getClass()), _a, "m", _AA_method2).bind(_d) `test${1}and${2}`; + __classPrivateFieldGet((_e = _a.getClass()), _a, "m", _AA_method2).call(_e, 0, ...arr, 3); const b2 = new (__classPrivateFieldGet(_a.getClass(), _a, "m", _AA_method2))(0, ...arr, 3); //Error - const str2 = __classPrivateFieldGet((_d = _a.getClass()), _a, "m", _AA_method2).bind(_d) `head${1}middle${2}tail`; + const str2 = __classPrivateFieldGet((_f = _a.getClass()), _a, "m", _AA_method2).bind(_f) `head${1}middle${2}tail`; + (__classPrivateFieldGet(_a, _a, "m", _AA_method)).call(_a); + __classPrivateFieldGet(_a, _a, "m", _AA_method).call(_a); + __classPrivateFieldGet(_a, _a, "m", _AA_method).call(_a); + __classPrivateFieldGet(_a, _a, "m", _AA_method).call(_a); + (_b = (__classPrivateFieldGet(_a, _a, "m", _AA_method))) === null || _b === void 0 ? void 0 : _b.call(_a); + (_c = __classPrivateFieldGet(_a, _a, "m", _AA_method)) === null || _c === void 0 ? void 0 : _c.call(_a); + (__classPrivateFieldGet((_g = _a.getClass()), _a, "m", _AA_method2)).call(_g, 0, ...arr, 3); + (__classPrivateFieldGet(_a, _a, "m", _AA_method2)).bind(_a) `test${1}and${2}`; } static getClass() { return _a; } } diff --git a/tsc/testdata/baselines/reference/conformance/privateNameStaticMethodCallExpression.symbols b/tsc/testdata/baselines/reference/conformance/privateNameStaticMethodCallExpression.symbols index 502889b095085..a2f5b770edb8c 100644 --- a/tsc/testdata/baselines/reference/conformance/privateNameStaticMethodCallExpression.symbols +++ b/tsc/testdata/baselines/reference/conformance/privateNameStaticMethodCallExpression.symbols @@ -58,34 +58,69 @@ class AA { AA.getClass().#method2`test${1}and${2}`; >AA.getClass().#method2 : Symbol(AA.#method2, Decl(privateNameStaticMethodCallExpression.ts, 1, 38)) ->AA.getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 20, 5)) +>AA.getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 29, 5)) >AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) ->getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 20, 5)) +>getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 29, 5)) AA.getClass().#method2(0, ...arr, 3); >AA.getClass().#method2 : Symbol(AA.#method2, Decl(privateNameStaticMethodCallExpression.ts, 1, 38)) ->AA.getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 20, 5)) +>AA.getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 29, 5)) >AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) ->getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 20, 5)) +>getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 29, 5)) >arr : Symbol(arr, Decl(privateNameStaticMethodCallExpression.ts, 10, 13)) const b2 = new (AA.getClass().#method2)(0, ...arr, 3); //Error >b2 : Symbol(b2, Decl(privateNameStaticMethodCallExpression.ts, 18, 13)) >AA.getClass().#method2 : Symbol(AA.#method2, Decl(privateNameStaticMethodCallExpression.ts, 1, 38)) ->AA.getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 20, 5)) +>AA.getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 29, 5)) >AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) ->getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 20, 5)) +>getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 29, 5)) >arr : Symbol(arr, Decl(privateNameStaticMethodCallExpression.ts, 10, 13)) const str2 = AA.getClass().#method2`head${1}middle${2}tail`; >str2 : Symbol(str2, Decl(privateNameStaticMethodCallExpression.ts, 19, 13)) >AA.getClass().#method2 : Symbol(AA.#method2, Decl(privateNameStaticMethodCallExpression.ts, 1, 38)) ->AA.getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 20, 5)) +>AA.getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 29, 5)) +>AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) +>getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 29, 5)) + + (AA.#method)(); +>AA.#method : Symbol(AA.#method, Decl(privateNameStaticMethodCallExpression.ts, 0, 10)) +>AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) + + AA.#method!(); +>AA.#method : Symbol(AA.#method, Decl(privateNameStaticMethodCallExpression.ts, 0, 10)) +>AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) + + (AA.#method as () => void)(); +>AA.#method : Symbol(AA.#method, Decl(privateNameStaticMethodCallExpression.ts, 0, 10)) +>AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) + + (AA.#method satisfies () => void)(); +>AA.#method : Symbol(AA.#method, Decl(privateNameStaticMethodCallExpression.ts, 0, 10)) +>AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) + + (AA.#method)?.(); +>AA.#method : Symbol(AA.#method, Decl(privateNameStaticMethodCallExpression.ts, 0, 10)) +>AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) + + AA.#method!?.(); +>AA.#method : Symbol(AA.#method, Decl(privateNameStaticMethodCallExpression.ts, 0, 10)) +>AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) + + (AA.getClass().#method2)(0, ...arr, 3); +>AA.getClass().#method2 : Symbol(AA.#method2, Decl(privateNameStaticMethodCallExpression.ts, 1, 38)) +>AA.getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 29, 5)) +>AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) +>getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 29, 5)) +>arr : Symbol(arr, Decl(privateNameStaticMethodCallExpression.ts, 10, 13)) + + (AA.#method2)`test${1}and${2}`; +>AA.#method2 : Symbol(AA.#method2, Decl(privateNameStaticMethodCallExpression.ts, 1, 38)) >AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) ->getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 20, 5)) } static getClass() { return AA; } ->getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 20, 5)) +>getClass : Symbol(AA.getClass, Decl(privateNameStaticMethodCallExpression.ts, 29, 5)) >AA : Symbol(AA, Decl(privateNameStaticMethodCallExpression.ts, 0, 0)) } diff --git a/tsc/testdata/baselines/reference/conformance/privateNameStaticMethodCallExpression.types b/tsc/testdata/baselines/reference/conformance/privateNameStaticMethodCallExpression.types index 0d460715ce3b5..571a29deebc63 100644 --- a/tsc/testdata/baselines/reference/conformance/privateNameStaticMethodCallExpression.types +++ b/tsc/testdata/baselines/reference/conformance/privateNameStaticMethodCallExpression.types @@ -124,6 +124,66 @@ class AA { >getClass : () => typeof AA >`head${1}middle${2}tail` : string >1 : 1 +>2 : 2 + + (AA.#method)(); +>(AA.#method)() : void +>(AA.#method) : () => void +>AA.#method : () => void +>AA : typeof AA + + AA.#method!(); +>AA.#method!() : void +>AA.#method! : () => void +>AA.#method : () => void +>AA : typeof AA + + (AA.#method as () => void)(); +>(AA.#method as () => void)() : void +>(AA.#method as () => void) : () => void +>AA.#method as () => void : () => void +>AA.#method : () => void +>AA : typeof AA + + (AA.#method satisfies () => void)(); +>(AA.#method satisfies () => void)() : void +>(AA.#method satisfies () => void) : () => void +>AA.#method satisfies () => void : () => void +>AA.#method : () => void +>AA : typeof AA + + (AA.#method)?.(); +>(AA.#method)?.() : void +>(AA.#method) : () => void +>AA.#method : () => void +>AA : typeof AA + + AA.#method!?.(); +>AA.#method!?.() : void +>AA.#method! : () => void +>AA.#method : () => void +>AA : typeof AA + + (AA.getClass().#method2)(0, ...arr, 3); +>(AA.getClass().#method2)(0, ...arr, 3) : void +>(AA.getClass().#method2) : (a: any, ...b: any[]) => void +>AA.getClass().#method2 : (a: any, ...b: any[]) => void +>AA.getClass() : typeof AA +>AA.getClass : () => typeof AA +>AA : typeof AA +>getClass : () => typeof AA +>0 : 0 +>...arr : number +>arr : number[] +>3 : 3 + + (AA.#method2)`test${1}and${2}`; +>(AA.#method2)`test${1}and${2}` : void +>(AA.#method2) : (a: any, ...b: any[]) => void +>AA.#method2 : (a: any, ...b: any[]) => void +>AA : typeof AA +>`test${1}and${2}` : string +>1 : 1 >2 : 2 } static getClass() { return AA; } diff --git a/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameAccessorsCallExpression.ts b/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameAccessorsCallExpression.ts index ea5afe9baf7a9..a1d0091cb1373 100644 --- a/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameAccessorsCallExpression.ts +++ b/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameAccessorsCallExpression.ts @@ -16,6 +16,15 @@ class A { const b = new this.#fieldFunc2(0, ...arr, 3); const str = this.#fieldFunc2`head${1}middle${2}tail`; this.getInstance().#fieldFunc2`test${1}and${2}`; + + (this.#fieldFunc)(); + this.#fieldFunc!(); + (this.#fieldFunc as () => void)(); + (this.#fieldFunc satisfies () => void)(); + (this.#fieldFunc)?.(); + this.#fieldFunc!?.(); + (this.getInstance().#fieldFunc)(); + (this.#fieldFunc2)`test${1}and${2}`; } getInstance() { return new A(); } } \ No newline at end of file diff --git a/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameFieldCallExpression.ts b/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameFieldCallExpression.ts index 466a4b79bba86..6d4d00f99f9d2 100644 --- a/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameFieldCallExpression.ts +++ b/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameFieldCallExpression.ts @@ -17,6 +17,15 @@ class A { const b = new this.#fieldFunc2(0, ...arr, 3); const str = this.#fieldFunc2`head${1}middle${2}tail`; this.getInstance().#fieldFunc2`test${1}and${2}`; + + (this.#fieldFunc)(); + this.#fieldFunc!(); + (this.#fieldFunc as () => void)(); + (this.#fieldFunc satisfies () => void)(); + (this.#fieldFunc)?.(); + this.#fieldFunc!?.(); + (this.getInstance().#fieldFunc)(); + (this.#fieldFunc2)`test${1}and${2}`; } getInstance() { return new A(); } } diff --git a/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameMethodCallExpression.ts b/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameMethodCallExpression.ts index 67f546d04f08e..d9145c7527e5b 100644 --- a/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameMethodCallExpression.ts +++ b/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameMethodCallExpression.ts @@ -21,6 +21,20 @@ class AA { this.getInstance().#method2(0, ...arr, 3); const b2 = new (this.getInstance().#method2)(0, ...arr, 3); //Error const str2 = this.getInstance().#method2`head${1}middle${2}tail`; + + (this.#method)(); + this.#method!(); + (this.#method as () => void)(); + (this.#method satisfies () => void)(); + (((this.#method as () => void)!))(); + (this.#method)?.(); + this.#method!?.(); + (this.getInstance().#method2)(0, ...arr, 3); + (this.#method2)`test${1}and${2}`; + this.#method2!`test${1}and${2}`; + (this.#method2 as any)`test${1}and${2}`; + (this.#method2 satisfies Function)`test${1}and${2}`; + (0, this.#method)(); } getInstance() { return new AA(); } } diff --git a/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodCallExpression.ts b/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodCallExpression.ts index fa6620870edaf..70ba986e04530 100644 --- a/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodCallExpression.ts +++ b/tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodCallExpression.ts @@ -21,6 +21,15 @@ class AA { AA.getClass().#method2(0, ...arr, 3); const b2 = new (AA.getClass().#method2)(0, ...arr, 3); //Error const str2 = AA.getClass().#method2`head${1}middle${2}tail`; + + (AA.#method)(); + AA.#method!(); + (AA.#method as () => void)(); + (AA.#method satisfies () => void)(); + (AA.#method)?.(); + AA.#method!?.(); + (AA.getClass().#method2)(0, ...arr, 3); + (AA.#method2)`test${1}and${2}`; } static getClass() { return AA; } }