Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix this-type in prototype-assigned object literals #26925

Merged
merged 3 commits into from
Sep 12, 2018

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Sep 5, 2018

Some cases were missing from tryGetThisTypeAt.

Like the previous fix, the baselines still have an error because of a new bug I found: #26923. It's a regression, but it's only in noImplicitAny.

Fixes #26831

Some cases were missing from tryGetThisTypeAt.
Fixes #26831
@sandersn sandersn requested review from a user and RyanCavanaugh September 5, 2018 22:00
.left as PropertyAccessExpression) // x.prototype.y
.expression as PropertyAccessExpression) // x.prototype
.expression; // x
const className = getClassNameFromPrototypeMethod(container);
Copy link

@ghost ghost Sep 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this code be gated by isInJavaScriptFile(node) like a later block at the bottom of tryGetThisTypeAt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and the @constructor check below as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@ghost
Copy link

ghost commented Sep 5, 2018

Is there an issue open for the following problem?

/** @type {Multimap} */
let m = new Multimap();
m.set("", "");

This doesn't work because set apparently isn't a member of Multimap.

@sandersn
Copy link
Member Author

Here's the issue you found: #26885

It must have to do with type resolution because removing the type annotation makes the error go away.

@sandersn sandersn merged commit 614423b into master Sep 12, 2018
@sandersn sandersn deleted the js/fix-this-type-in-prototype-object-literals branch September 12, 2018 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Object literal methods in prototype assignments don't have correct this-type
1 participant