Skip to content

Better handling of circular JS containers in getTypeOfVariableOrParameterOrProperty#24732

Merged
sandersn merged 9 commits into
masterfrom
js/fix-circularity-error-when-extending-class2
Jun 12, 2018
Merged

Better handling of circular JS containers in getTypeOfVariableOrParameterOrProperty#24732
sandersn merged 9 commits into
masterfrom
js/fix-circularity-error-when-extending-class2

Conversation

@sandersn
Copy link
Copy Markdown
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 mhegazy and weswigham 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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants