Uh oh!
There was an error while loading. Please reload this page.
Improve narrowing logic for instanceof, type predicate functions, and assertion functions - #49625
Conversation
Anders Hejlsberg (ahejlsberg)
commented
Jun 22, 2022
TypeScript Bot (@typescript-bot) test this |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the abridged perf test suite on this PR at fc81aff. You can monitor the build here. Update: The results are in! |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based user code test suite on this PR at fc81aff. You can monitor the build here. Update: The results are in! |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at fc81aff. You can monitor the build here. |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at fc81aff. You can monitor the build here. |
TypeScript Bot (typescript-bot)
commented
Jun 22, 2022
Anders Hejlsberg (@ahejlsberg) Here they are:Comparison Report - main..49625
System
Hosts
Scenarios
Developer Information: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TypeScript Bot (typescript-bot)
commented
Jun 22, 2022
Heya Anders Hejlsberg (@ahejlsberg), I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here. |
TypeScript Bot (typescript-bot)
commented
Jun 22, 2022
Anders Hejlsberg (@ahejlsberg) |
Anders Hejlsberg (ahejlsberg)
commented
Jun 22, 2022
TypeScript Bot (@typescript-bot) test this |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based user code test suite on this PR at 37bfa91. You can monitor the build here. Update: The results are in! |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the abridged perf test suite on this PR at 37bfa91. You can monitor the build here. Update: The results are in! |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 37bfa91. You can monitor the build here. |
TypeScript Bot (typescript-bot)
commented
Jun 22, 2022
Anders Hejlsberg (@ahejlsberg) |
TypeScript Bot (typescript-bot)
commented
Jun 22, 2022
Heya Anders Hejlsberg (@ahejlsberg), I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here. |
Ryan Cavanaugh (RyanCavanaugh)
commented
Jun 22, 2022
TypeScript Bot (@typescript-bot) pack this |
Heya Ryan Cavanaugh (@RyanCavanaugh), I've started to run the tarball bundle task on this PR at 37bfa91. You can monitor the build here. |
TypeScript Bot (typescript-bot)
commented
Jun 22, 2022
Anders Hejlsberg (@ahejlsberg) Here they are:Comparison Report - main..49625
System
Hosts
Scenarios
Developer Information: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Hey Ryan Cavanaugh (@RyanCavanaugh), I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running There is also a playground for this build and an npm module you can use via |
Anders Hejlsberg (ahejlsberg)
commented
Jul 5, 2022
TypeScript Bot (@typescript-bot) perf test faster |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the abridged perf test suite on this PR at 960ad11. You can monitor the build here. Update: The results are in! |
TypeScript Bot (typescript-bot)
commented
Jul 5, 2022
Anders Hejlsberg (@ahejlsberg) Here they are:Comparison Report - main..49625
System
Hosts
Scenarios
Developer Information: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anders Hejlsberg (ahejlsberg)
commented
Jul 5, 2022
TypeScript Bot (@typescript-bot) test this |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 960ad11. You can monitor the build here. |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based user code test suite on this PR at 960ad11. You can monitor the build here. Update: The results are in! |
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 960ad11. You can monitor the build here. |
TypeScript Bot (typescript-bot)
commented
Jul 5, 2022
Anders Hejlsberg (@ahejlsberg) |
TypeScript Bot (typescript-bot)
commented
Jul 5, 2022
Heya Anders Hejlsberg (@ahejlsberg), I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Jake Bailey (jakebailey)
commented
Jul 15, 2022
Is this for the 4.8 RC, or is this waiting for 4.9? (Wondering because I was hoping to make this main's LKG as it might fix a few workarounds I have on my "enable strictFunctionTypes" branch.) |
microsoft/TypeScript#49625 improves handling of unions in type predicates so that unions are correctly preserved. This breaks types.isMap in node. For now I just changed the tests' expected type, but the type of isMap doesn't make much sense to me. It should probably be changed, but that's a much more complex task. This break is tracked at microsoft/TypeScript#49988 although it's correct, I think, so not very likely to be reverted.
* Update node types.isMap tests microsoft/TypeScript#49625 improves handling of unions in type predicates so that unions are correctly preserved. This breaks types.isMap in node. For now I just changed the tests' expected type, but the type of isMap doesn't make much sense to me. It should probably be changed, but that's a much more complex task. This break is tracked at microsoft/TypeScript#49988 although it's correct, I think, so not very likely to be reverted. * Change test for isSet too
TS 4.8 improves narrowing of type predicates when a union is passed in. This changes the return type of a couple of underscore and weak-napi functions. For now I just updated the tests, since underscore's change is pretty minor. And weak-napi's types probably need to be rewritten substantially, which would probably result in fixing this change. See microsoft/TypeScript#49625 for the change.
TS 4.8 improves narrowing of type predicates when a union is passed in. This changes the return type of a couple of underscore and weak-napi functions. For now I just updated the tests, since underscore's change is pretty minor. And weak-napi's types probably need to be rewritten substantially, which would probably result in fixing this change. See microsoft/TypeScript#49625 for the change.
This PR improves our narrowing logic for
instanceof, type predicate functions, and assertion functions. In particular, we now correctly handle situations where the narrowing target type is a union type.Some examples:
Previously all of the above examples produced wrong results.
Fixes#31156.
Fixes#35953.
Fixes#37807.
Fixes#38869.
Fixes#39105.
Fixes#40035.
Fixes#41871.
Fixes#42101.
Fixes#43825.
Fixes#44754.
Fixes#46909.
Fixes#49588.