Closed
Description
TypeScript Version: 4.1.2
Search Terms:
Expected behavior:
should throw an error with "target": "ESNext"
and #
private member
Actual behavior:
Related Issues:
#17535
https://stackoverflow.com/a/45244695/4794368
Code
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
}
Output
"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;
}
Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"allowUnusedLabels": true,
"esModuleInterop": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": 2,
"target": "Latest",
"jsx": "React",
"module": "ESNext"
}
}
Playground Link: Provided