Repository: TypeScript
Issue: Issues with JSDoc private and protected
Labels: Bug,Domain: JSDoc

# Bug Report

<!--
  Please fill in each section completely. Thank you!
-->

### 🔎 Search Terms

JSDoc access modifier

### 🕗 Version & Regression Information

<!-- When did you start seeing this bug occur?

"Bugs" that have existed in TS for a long time are very likely to be FAQs; refer to
  https://github.com/Microsoft/TypeScript/wiki/FAQ#common-bugs-that-arent-bugs

If possible, please try testing the nightly version of TS to see if it's already been fixed.
For npm: `typescript@next`
This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly

Note: The TypeScript Playground can be used to try older versions of TypeScript.

Please keep and fill in the line that best applies:
-->
- This changed in version `v3.8` probably because JSDoc accessibility modifiers were introduced; that is to say: it never worked

### ⏯ Playground Link

<!--
  A link to a TypeScript Playground "Share" link which shows this behavior

  The TypeScript Workbench can be used for more complex setups, try
  https://www.typescriptlang.org/dev/bug-workbench/

  As a last resort, you can link to a repo, but these will be slower for us to investigate.
-->
**Playground Link:** [Provided](https://www.typescriptlang.org/play?ts=4.2.0-dev.20210106&useJavaScript=true#code/PQKhAIAEGMBsEMDOjwmAWAFADMCuA7aAFwEsB7fcAGQFMBzeaAT3AAoBKcAby3HFAiQADgCcyRGsRoATVBkx8iACxKIAdKLJDwAXnABGANz9g4RErK5Ys-OPAAjGuHiUaIsSN7hlqtdLIAykS42NgcxsCm5pbW4LZEDk4u4G4eWAC+WFgCUKIkAG7wEnJYtAzMGmJE4kxCNH6BwaG64HiEpBRsnDwK3irqmkIRURZWNnaOzq7uZJ69Pur+QSFh7MNmo7HxiVMpM3OZmFhwSCgAwtxeOcJVkhKyaF6DLUYZWZjXC9xn6SU4BMRyJRsPgOJd5v1Klp1sonDQAI64ArwWA0fAJADuswA1igSJQACoBN6YIA)

### 💻 Code


```ts
/** @class */
function Legacy () {
  /** @protected */
  this.prop = 1; // should not be an error
  this.doStuff(); // should not be an error
}

/** @private */
Legacy.prototype.doStuff = function () {
  this.prop; // should not be an error
  this.doStuff(); // should not be an error
}

class C {
  /** @protected */
  prop = 1;
}

/** @this {C} */
function fn() {
  this.prop; // the equivalent works in TS
}

```


<details><summary><b>Compiler Options</b></summary>

```json
{
  "compilerOptions": {
    "noImplicitAny": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "alwaysStrict": true,
    "esModuleInterop": true,
    "checkJs": true,
    "allowJs": true,
    "declaration": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "moduleResolution": 2,
    "target": "ES2017",
    "jsx": "React",
    "module": "ESNext"
  }
}
```


</details>
      

### 🙁 Actual behavior

Using legacy class syntax and so-called "assignment declarations" don't recognize that the properties are actually accessed inside the class. That's because the checker logic only looks for real ClassLikeDeclaration Nodes.

Note that `@readonly` correctly recognizes `function Legacy` as the constructor and allows assignment there.

Using a protected member in a function with explicit `this`-parameter works in TS, but doesn't when using `@this` in JS.

### 🙂 Expected behavior

No errors in the code.