Ensure functions that have prototype properties assigned by Object.defineProperty get marked as classes #34577
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 #34481
Various JS constructs indicate to the binder that a function is actually a constructor:
this
inside the body/** @constructor */
JSDoc tagA missing one was defining a prototype property via
Object.defineProperty
. So if you have the codeThe
Object.defineProperty
to the prototype is the sole indicator thatGraphic
is a constructor, but it was being missed, so the symbolGraphic
was not marked as a class. However, when the checker tries to get the type ofthis
, it rightly assumes thatGraphic
must be a class, and hence the crash.It’s also notable that the provided repro had something like this:
which we don’t recognize as a bindable declaration onto Graphic at all—if we did, this bug would have remained undiscovered. Similarly, if the original code had any assignment to
this
, or any property assignment toGraphic.prototype
, or used the JSDoc/** @constructor */
tag, the crash wouldn‘t have occurred because a different declaration would have markedGraphic
as class-like.