Skip method this type validity filter for objects with more than 20 members #28692
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #23285 specifically by limiting the number of properties we filter methods on to 20 (so if an object has > 20 members, we no longer filter invalid method calls from the completion list), though the underlying issue remains. It's also questionable if the filtering is even really correct, since using the member in a non-calling fashion is still acceptable - the choice to filter methods at all feels somewhat pragmatic.
That underlying issue is that every anonymous type instantiation is unique - so even though we're querying similar types across the ~300 this-type comparisons we perform, since the input anonymous types are differing identities, we repeat a lot of very similar work. Caching on signatures doesn't help here, since each comparison is triggered for a different signature. The issue is simply that if I have 200 methods with
this: {item: T}
, then every time we infer from{item: string}
to{item: T}
and instantiateT
withstring
, we get a new overall type identity and need to perform a structural comparison, even though it's still just{item: string}
.