Repository: TypeScript
Issue: Protected and private functions are not visible when 'this' context "arg" is provided if it doesn't explicitly define a return type
Labels: Bug,Help Wanted

# Bug Report

<!--
  Please fill in each section completely. Thank you!
-->

### 🔎 Search Terms

<!--
  What search terms did you use when trying to find an existing bug report?
  List them here so people in the future can find this one more easily.
-->
private type is not visible

### 🕗 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 is the behavior in every version I tried (3.3.3 -> Nightly), and I reviewed the FAQ for entries about types and not-a-bugs.

### ⏯ 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 with relevant code](https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgJLmvJBGZBvAXwChRJZEV0ysIAmfYohAGzgGc3kBZYAD1HxFkw5AAcowAG5xIyGMAjMAJgC5kcEAE8A3EJHiA9pASQlchctpqNOonuGHjp5EoMB5EBAAqAC1ABzAAoASgZ7MSgjCBMIM1cPbz8QfwA1A2AlELVJdLNCOxEIqRkUVy8AdwNfALYQsMLxYtkyyurktjSMrOQcjLDw0QBXACNmYAQXKp8oCESauvyGkbGJsunZtv8O3O7evMZCtYDAsD82NR5+EGQAMmRAqkwKXAAfNAxyJFpg0LxwwoA9ADkAA5IzmTz-ESnYBsAB08kUSloukKhRh8Pink2IVRaOEGLhWLmyU6mWCePxhJaU3mFKhwiByAAYqAIAzkITEcpKWjqVVWkktmTcRz+b4ZiStqL8QSzkSppLNtsuvTCsRiEA)

### 💻 Code

<!-- Please post the relevant code sample here as well-->
```ts
interface Interface1 {}
interface Interface2 {}

class Mixin {
    private field: any;
    protected field2: any;

    protected doOneThing() {}
    protected doOneThingVoid(): void {}

    private doTwoThings() {}
    private doTwoThingsVoid(): void {}

    public doThreeThings() {}
    public doThreeThingsVoid(): void {}

    doThing(this: Mixin & (Interface1 | Interface2)) {
        // Not fine
        this.field2;
        this.doOneThing();
        this.doOneThingVoid();
        this.doTwoThings();
        // Fine
        this.field;
        this.doTwoThingsVoid();
        this.doThreeThings();
        this.doThreeThingsVoid();
    }
}
```

### 🙁 Actual behavior

The protected fields and functions are declared as not visible. The private functions that implicitly return void are not visible.

### 🙂 Expected behavior

Protected fields are visible. Functions that return an implicit void are visible and therefore treated the same as functions that return an explicit void.

### Further Notes

It doesn't matter if I return void, any return value will do. I'm also finding it odd that private works, but protected doesn't even though protected should have greater visibility here. However it may be trying to say that it doesn't think that we're inside of a `Mixin` class instance, in which case neither private nor protected should be visible in that case, even though that's not my preferred outcome. At minimum there shouldn't be a difference between implicit and explicit void.

Yes this is used as a mixin with the `ts-mixer` library, however, the type errors are all contained within the class itself like the example above, and so are a problem without involvement of any mixin libraries.

Also this seems related to #29132 except there's no generics used here. I also found #10637 when researching this, but that involves inheritance which isn't in play here.