Contextual 'this' parameter in JSDoc doesn't show correct completions after property assignment on `this` in function-valued object literal property
#50 240 ouverte le 9 août 2022
Métriques du dépôt
- Stars
- (48 455 stars)
- Métriques de merge PR
- (Merge moyen 6j 17h) (9 PRs mergées en 30 j)
Description
Bug Report
🔎 Search Terms
- js this type
- js this function property
- function property this type
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about "Functions"
⏯ Playground Link
N/A - involves JS code which cant be emulated in playground at the moment
💻 Code
Below are some examples of the issue including the tsconfig.json and the code. The code comments describe what suggestions the intellisense provide, and here is what is expected, ie the types showing up on this as defined in the ts file:

The issue is below, where if the function assigns any property to this then the intellisense for this is limited to those assigned properties and ignores the defined type, e.g.:

🙁 Actual behavior
If the function assigns any property to this then the intellisense for this is limited to those assigned properties and ignores the defined type.
🙂 Expected behavior
The issue above seems to only be for function properties with function declarations ie {property: function() {...}} if the function property uses shorthand ie {property() {...}} then the expected behaviour occurs regarding the typing of this, ie there is intellisense based on the defined type of this regardless of what happens in the function (from what I have tried).
For example:

From my understanding the function declaration and shorthand notations shouldnt have different behaviour according to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions, so the typing also shouldnt behave differently.
Turning on checkJs fixes the issue however it means migrating to TS is more difficult as all the issues need to be fixed before getting any of the benefits e.g. intellisense, and this also limits functionality for large code bases migrating to TS but with a lot of legacy JS code.