Incorrect output for #private with nested class in ESNext · Issue #41788 · microsoft/TypeScript (original) (raw)

Found from #41773 (comment)

// @target: esnext

class A { #str = 'pr Str' constructor() { new A.B(this) } private static B = class { constructor(private a: A) { console.log(this.a.#str) } } } test: { new A }

Currently, this is emitted as

"use strict"; class A { constructor() { this.#str = 'pr Str'; new A.B(this); } #str; } A.B = class { constructor(a) { this.a = a; console.log(this.a.#str); } }; test: { new A; }

However, #str has been orphaned and this code will have errors.

CC @robpalme