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

Better handling of circular JS containers in getTypeOfVariableOrParameterOrProperty #24732

Merged
merged 9 commits into from
Jun 12, 2018

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Jun 6, 2018

This PR handles JS containers specially inside getTypeOfVariableOrParameterOrProperty. Now, instead of delegating to get[Widened]TypeOfVariableLikeDeclaration to get the type of object-literal initializers, it constructs the anonymous type by immediately calling the new getJSInitializerType.

The PR also improves:

  1. The number of times we check whether a declaration is in a js file while getting the type.
  2. The construction of js container types, by looking at the assigned properties of all parents in the assignment chain, instead of only the immediate parent. This improves patterns like var G = m.G = {}, where both G and m.G have special property assignments later in the file.

Fixes #24730 and improves the chrome-devtools-frontend baselines.

sandersn added 5 commits June 6, 2018 13:43
Modify getTypeOfVariableOrParameterOrProperty to get the type of the
variable declaration before widening it. This essentially avoids some
circularities by (1) setting the type of the variable declaration to the
unwidened type (2) updating the type of the variable declaration to the
widened one.

You will still get a circular noImplicitAny in (1), for expressions that
actually are circular, but not in (2), for the containers of things that
are not themselves circular.
Also make sure to respect the type annotation if there is one.
@sandersn sandersn changed the title In JS containers, avoid circularity in getTypeOfVariableOrParameterOrProperty Better handling of circular JS containers in getTypeOfVariableOrParameterOrProperty Jun 11, 2018
@sandersn sandersn requested review from weswigham and mhegazy June 11, 2018 18:01
@sandersn sandersn merged commit 5be8f1f into master Jun 12, 2018
@sandersn sandersn deleted the js/fix-circularity-error-when-extending-class2 branch June 12, 2018 16:42
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.

2 participants