Skip to content

Explicitly typed prototype assignments are context sensitive #25688

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

Conversation

sandersn
Copy link
Member

Follow up to #25619: Add the necessary code to type prototype correctly so that prototype assignments in code like F.prototype = { ... } properly make the object literal context sensitive.

Still doesn't fix module.exports [property] assignments; the problem there is the typing of the symbol module, which is either any or { exports: any }.

Follow up to #25619: Add the necessary code to type `prototype`
correctly in prototype assignments so that code like
`F.prototype = { ... }` properly makes the object literal context
sensitive.
@sandersn sandersn requested review from a user and mhegazy July 16, 2018 15:55
@sandersn
Copy link
Member Author

sandersn commented Jul 16, 2018

Travis says the linter failed; VSTS' output just says a log was missing (?).

Edit: VSTS just failed to (1) wrap the line (2) show a visible scroll bar to indicate that the error was off the right side of the page. Same lint error though.

@sandersn sandersn merged commit 5b21cbc into master Jul 16, 2018
@sandersn sandersn deleted the js/explicitly-typed-prototype-assignments-are-context-sensitive branch July 16, 2018 17:03
sandersn added a commit that referenced this pull request Jul 16, 2018
sandersn added a commit that referenced this pull request Jul 17, 2018
sandersn added a commit that referenced this pull request Jul 17, 2018
* Revert "Revert "Explicitly typed special assignments are context sensitive (#25619)""

This reverts commit 16676f2.

* Revert "Revert "Explicitly typed prototype assignments are context sensitive (#25688)""

This reverts commit ff8c30d.
sandersn added a commit that referenced this pull request Jul 20, 2018
* Revert "Revert "Explicitly typed special assignments are context sensitive (#25619)""

This reverts commit 16676f2.

* Revert "Revert "Explicitly typed prototype assignments are context sensitive (#25688)""

This reverts commit ff8c30d.

* Initial, wasteful, solution

It burns a check flags. Probably necessary, but perhaps not.

I haven't accepted baselines, but they are a bit questionable. I'm not
sure the synthetic type is right, because I expected to see
{ "exports": typeof import("x") } but instead see { "x": typeof
import("x") }.

* Update some baselines

* module.exports= always uses lhs type

Conflicts between exports property assignments and exports assignments
should get a union type instead of an error.

* Fix lint and accept good user baselines

* Add tests based on user tests.

These currently fail.

* Fix all but 1 of user test bugs found by typing module.exports

Still quite messy and full of notes

* Follow merged symbols+allow any object type

This allows exports like `module.exports = new EE` to have properties
added to them.

Still messy, but I'm going to run user tests and look for regressions.

* Update improved user baselines

* Fix infinite recursion when checking module.exports

* Fix bogus use-before-def error

getExportSymbolOfValueSymbolIfExported should always merge its returned
symbol, whether it's symbol.exportSymbol or just symbol.

* Update user test baselines

* Cleanup

* More small cleanup

* Bind `module` of `module.exports` as a special symbol

Previously it was also special, but created during name resolution in
the checker. It made sense when there was only one special symbol for
all files, but now there is one `module` symbol per file.
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.

1 participant