Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 #46403in
operator typeguard can widen types #46403Changes from 56 commits
5a41201
775fd9c
b974add
49b574b
734f4c2
b6cbb3e
d6cabee
48b27e7
5936e27
02ff40a
6ec0edc
79e81be
c2fc19e
a5d17f3
540545a
b6f36cd
13b276c
84f5eeb
f2ee389
758d8df
d10b8d3
e245b88
c79a1fd
f8586b8
3e70f10
5def93a
26a982b
e93b2dc
7d49f33
728a8a3
47d206e
a29c5a5
5bcc2e6
78a50e9
f7bcee0
2015750
08dcd94
9da464b
94b9311
a47d9b2
5594882
b9f6aaf
4b4e63b
fbd0454
6b7b0b1
225f5a1
1f5c6c5
c7641f1
704ae12
83fda77
d739a5a
b75b129
624f586
e53fb8a
8bc9ef4
5eb7dcd
6010fff
caab233
762e56b
b16a4a1
ae755aa
b1fadcd
46e7bc6
efdcc0d
0bbe651
58e9420
aca5344
9c681b6
acf47c8
7293a62
8c3c2ac
dfe51a4
5c32123
d4be592
2f997b5
ed9eea3
02c8b2d
75dc33e
1b82d01
f5555df
ca14f27
13d2150
c891690
2b60aa8
30f89ae
ec41cbb
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably make a separate helper for filtering intersections - if you even still need it after swapping to using
getSpreadType
- rather then repurposingfilterType
. most offilterType
's callers definitely don't want to filter intersection constituents.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, hopefully, the change won't be needed altogether with the introduction of
getSpreadType
(I use it in one other place, but it isn't necessary I think)There was a problem hiding this comment.
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 :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't merge the types :)
Instead, just make an anonymous type with a single member - the new one - and use
getSpreadType
to combine the original type with that new one. It'll combine directly where it can, and intersect otherwise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essentially everything you're doing by hand here in the last 3/4ths of
widenTypeWithSymbol
, but already done for you. 😊There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I tried to do it this way:
It's a really neat solution that removes the entire
widenTypeWithSymbol
function, thanks. However, it discards all call signatures oftype
! Looking at thegetSpreadType
source, I could probably modify that to keep them, but I'm not sure that wouldn't break other stuff.See it in action here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should cache these symbols (and the resulting properties and single-property-types) globally within the checker. Object types aren't structurally cached, so it needs to be done explicitly when the type is constructed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will do that once the discussion about this implementation is resolved