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

No contextual types from circular mapped type properties #38653

Merged
merged 2 commits into from
May 19, 2020
Merged

Conversation

ahejlsberg
Copy link
Member

With this PR we no longer attempt to produce contextual types from mapped type properties that are circular. Specifically, in getTypeOfPropertyOfContextualType we now check if the property originates in mapped type and if resolution of the type of the property would cause a circularity. If so, instead of resolving the type (which would produce a circularity error) we simply return undefined to indicate that there is no contextual type.

I have added the simplified repro from #38279 to the tests, plus I have manually verified that each of the complex repros in that issue no longer error.

Fixes #38279.

@ahejlsberg
Copy link
Member Author

@typescript-bot test this
@typescript-bot user test this
@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 19, 2020

Heya @ahejlsberg, I've started to run the extended test suite on this PR at 1dcf4ab. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 19, 2020

Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 1dcf4ab. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 19, 2020

Heya @ahejlsberg, I've started to run the parallelized community code test suite on this PR at 1dcf4ab. You can monitor the build here.

Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

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

Seems sensible to me.

Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

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

We also do type resolution stack inspection for avoiding some circularities in JS checking, so we have some precedent for doing this. We probably need to monitor LS bug reports to to make sure this doesn't cause a bug in the category of thing-gets-contextual-type-if-mouseover-A-then-B-but-not-B-then-A. I don't think the results of this calculation should be cached anywhere, so it should be OK; but we should be vigilant in case we get a report that sounds like that.

@ahejlsberg ahejlsberg merged commit 7ba0a65 into master May 19, 2020
cangSDARM added a commit to cangSDARM/TypeScript that referenced this pull request May 20, 2020
* upstream/master:
  Support naming tuple members (microsoft#38234)
  LEGO: check in for master to temporary branch.
  fix: extract const in jsx (microsoft#37912)
  No contextual types from circular mapped type properties (microsoft#38653)
  Ensure formatter can always get a newline character (microsoft#38579)
  Fix debug command for Node debugging
  Remove mentions of runtests-browser in CONTRIBUTING.md
  fix(33233): add outlining for comments before property access expression
  regression(38485): allow using rawText property in processing a tagged template
@RyanCavanaugh
Copy link
Member

@typescript-bot cherry-pick this to release-3.9

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 20, 2020

Heya @RyanCavanaugh, I've started to run the task to cherry-pick this into release-3.9 on this PR at 1dcf4ab. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @RyanCavanaugh, I've opened #38687 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request May 20, 2020
Component commits:
97cb818 No contextual types from circular mapped type properties

1dcf4ab Add regression test
weswigham added a commit that referenced this pull request Jun 15, 2020
Component commits:
97cb818 No contextual types from circular mapped type properties

1dcf4ab Add regression test

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
Co-authored-by: Wesley Wigham <wwigham@gmail.com>
amcasey added a commit to amcasey/TypeScript that referenced this pull request Jul 7, 2020
@jakebailey jakebailey deleted the fix38279 branch November 7, 2022 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Surprising circularity error in 3.9 RC
5 participants