Skip to content

Set symbol/flags only on (fresh) object spreads#12896

Merged
sandersn merged 2 commits into
masterfrom
implicit-any-error-on-explicit-any
Dec 13, 2016
Merged

Set symbol/flags only on (fresh) object spreads#12896
sandersn merged 2 commits into
masterfrom
implicit-any-error-on-explicit-any

Conversation

@sandersn
Copy link
Copy Markdown
Member

Set symbol/flags only on (fresh) object spreads. If you spread any into an object, the type is any, which should not be changed.

Previously, checkObjectLiteral assumed that the return value of getSpreadType was a fresh object type, but this is not true when spreading an expression of type any. So it incorrectly added flags to any that it inherits from the rest of the object literal.

In the test case, [] contributes a ContainsWideningType flag, which previously made all uses of any trigger an implicit any error.

If you spread any into an object, the type is any, which should not be
changed.
@sandersn
Copy link
Copy Markdown
Member Author

@mhegazy do you want this ported to 2.1 as well?

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Dec 13, 2016

yes please.

@sandersn sandersn merged commit ae2a13c into master Dec 13, 2016
@sandersn sandersn deleted the implicit-any-error-on-explicit-any branch December 13, 2016 22:15
@sandersn
Copy link
Copy Markdown
Member Author

OK, done.

@mhegazy mhegazy mentioned this pull request Dec 14, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
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.

3 participants