<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨 Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section! Please help us by doing the following steps before logging an issue: * Search: https://github.com/Microsoft/TypeScript/search?type=Issues * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ Please fill in the *entire* template below. --> **TypeScript Version:** 4.1.2 <!-- Search terms you tried before logging this (so others can find this issue more easily) --> **Search Terms:** **Expected behavior:** should throw an error with `"target": "ESNext"` and `#` private member **Actual behavior:** <!-- Did you find other bugs that looked similar? --> **Related Issues:** https://github.com/Microsoft/TypeScript/issues/17535 https://stackoverflow.com/a/45244695/4794368 **Code** ```ts 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 } ``` <details><summary><b>Output</b></summary> ```ts "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; } ``` </details> <details><summary><b>Compiler Options</b></summary> ```json { "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" } } ``` </details> **Playground Link:** [Provided](https://www.typescriptlang.org/play?allowUnusedLabels=true&target=99&ssl=1&ssc=1&pln=15&pc=1#code/MYGwhgzhAECC0G8BQ1XQMQQC4CdoF5oByABzwGVciU1gB7AO2xwFdgs6cAKASkRrRoGAUwDucAHQAhLlgAWASwg8B0AL6qyCgG5gsw6Nj0Lg0KQWihIMZIMH0muNh25bd+6GABccPrbsBDhB0IMISIHQA5rKKEBJgEpi4KgGoGoIaGvrYPv6oIuKwSBpAA)
Activity
RyanCavanaugh commentedon Dec 2, 2020
Why? This code runs without error
qwabra commentedon Dec 2, 2020
Oh, hmm, hmmm but.
But your example is different from the compiler output
RyanCavanaugh commentedon Dec 2, 2020
Not really seeing any argument being made here. Private identifiers have lexical visibility and
#stris inB's containing lexical scope.qwabra commentedon Dec 2, 2020
ok, now i see. but the generated code doesn't work. please look at the output
DanielRosenwasser commentedon Dec 2, 2020
Thanks for clarifying - I opened up #41788 for you.