Repository: TypeScript
Issue: Allow `this` type inside inline object-typed parameters and output
Labels: Suggestion,Help Wanted,Experience Enhancement

# Bug Report

<!--
  Please fill in each section completely. Thank you!
-->

### 🔎 Search Terms

A 'this' type is available only in a non-static member of a class or interface.

### 🕗 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, and I reviewed the FAQ for entries about `this` types. I believe this is a bug (oversight) and not a suggestion because it _does already_ work for what look like _very_ analogous situations.

### ⏯ 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?ts=4.5.4#code/MYGwhgzhAEBiD29oG8BQ0PQPRegUQCcD4CAuaAQWgHIAXACwEsJrpaBPABwFNpnowANzCNwAIxC94AOxDs+0gdGkyAtBFphajYNAC23PWO4Fo8AGZLQkGCQW0T5sMG4A6dJjFgAJgHkxAFYA6owMACpMEBQEAOYAFPCB5MjQ5ojkDPwAvgCUKFkeGF5+gSHhkQDCYCAgXsAA1glJKKnp0HG0GZF5ALwAfGyR0Ln5hdDF-sGh9BHMvgCutJyLcTnJrfBd2S0E3LTzBIopaZuD2QDcw6hjOJQ1qYzS3GPw9bNRsR1bEHkpBZhmN6Vaq1ZyNYBichfM4-aD9GG-f6YV7RAhgdhlGaRaLxMDfADaAF1flcASiiOjMe8qjU6o08e1oZlYfDmTkiSSkRhyWiMdN3gslis1jCiTs9gdFPjmYTLlzAQBJaTeRi7YC0SZU7GfRIBcgAITABAAPMy+oiXvUlSq1RrSvzgbSwU09dBDSamd04QMzZzLdbVdx1ZqHXNFstaKsDUbTZEBildvtDi0Tt9hucCgVUI8HAQnC43TGwvHoGNU9AwudUFkgA)

### 💻 Code

<!-- Please post the relevant code sample here as well-->
```ts
class Foo {
    // Error: A 'this' type is available only in a non-static member of a class or interface.
    badObjWithThisArg(obj: { foo: this }) {}
    badObjWithThisCallback(obj: { foo: (t: this) => this }) {}
    badObjWithThisOutput(): { foo: this } { return { foo: this }; }

    // All fine
    okThisArg(t: this) { }
    okThisCallback(cb: (t: this) => this) {}
    okArrayWithThisArg(a: this[]) { }
    okArrayWithThisCallback(a: ((t: this) => this)[]) { }
    okArrayWithThisOutput(): this[] { return [this]; }
    okIndirectObjWithThisArg(obj: Bar<this>) {}
    okIndirectObjWithThisCallback(obj: Bar<(t: this) => this>) { }
    okIndirectObjWithThisOutput(): Bar<this> { return { foo: this };}
}

interface Bar<T> { 
    foo: T;
}
```

### 🙁 Actual behavior

Using `{ foo: this }` as an argument or an output is an error, even in cases where `this` and other derivatives of `this` are allowed.

### 🙂 Expected behavior

Inline object types containing `this` should be allowed:
1. Exactly the same type is totally legal as long as it is expressed indirectly through a generic interface instead of inline. There is no actual type difference whatsoever between these situations, as far as I understand.
2. Other analogous derivatives such as arrays or functions of this are allowed in the same places.