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

in operator typeguard can widen types #46403

Open
wants to merge 56 commits into
base: main
Choose a base branch
from

Conversation

@marekdedic
Copy link

@marekdedic marekdedic commented Oct 17, 2021

Fixes #21732

This PR is a continuation of #39746 - thanks @ShuiRuTian for his work. I have made the branch up-to-date with main and fixed new test breakages. As I am not the original author of most of the changes, I would greatly appreciate a review either from @ShuiRuTian or the maintainers of TS.

Submission containing materials of a third party: @ShuiRuTian

Please verify that:

  • There is an associated issue in the Backlog milestone (required)
  • Code is up-to-date with the main branch
  • You've successfully run gulp runtests locally
  • There are new or updated unit tests validating the change
@microsoft-cla
Copy link

@microsoft-cla microsoft-cla bot commented Oct 17, 2021

CLA assistant check
All CLA requirements met.

Loading

@marekdedic marekdedic changed the title in operator typeguard now can widen types in operator typeguard can widen types Oct 17, 2021
@marekdedic
Copy link
Author

@marekdedic marekdedic commented Oct 17, 2021

I have signed the CLA, however, I have no idea what to do with the code that is not my own - my layman's interpretation of the CLA is that if @ShuiRuTian signed the CLA as well, than it should all be OK. However, I can't check that he did.

Loading

@marekdedic marekdedic marked this pull request as draft Oct 17, 2021
@marekdedic
Copy link
Author

@marekdedic marekdedic commented Oct 19, 2021

It looks like at least TS2361 has to be modified as well in order to allow for 'a' in b where b: unknown;.

Ok, I simplified it to 'a' in b where b: object, leaving the more general widening for later.

Loading

@ShuiRuTian
Copy link
Contributor

@ShuiRuTian ShuiRuTian commented Oct 22, 2021

Not worried, I signed the CLA too.

The changes until now looks good to me.

And please refer this commnet #39746 (comment)

Loading

@marekdedic marekdedic marked this pull request as ready for review Oct 24, 2021
function widenObjectType(type: ObjectType, newSymbol: Symbol): Type {
const members = createSymbolTable();
if (type.members !== undefined) {
mergeSymbolTable(members, type.members);
Copy link
Author

@marekdedic marekdedic Oct 24, 2021

Choose a reason for hiding this comment

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

Hi, @weswigham
I was directed to your comment, however, I don't really know what to do with it. Ideally, I think I would like to clone the symbol table and just add the new symbol to it (that way there are no merges), but I can't figure out how to clone a symbol table :/

Loading

@sandersn sandersn added this to Not started in PR Backlog Oct 25, 2021
@sandersn sandersn removed this from Not started in PR Backlog Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants