Uh oh!
There was an error while loading. Please reload this page.
Propagate the error any type in union and intersection construction - #58610
Conversation
Jake Bailey (jakebailey)
commented
May 21, 2024
Is this at all related to #56429? |
Wesley Wigham (weswigham)
commented
May 21, 2024
It's related insofar as better |
Nathan Shively-Sanders (sandersn)
left a comment
There was a problem hiding this comment.
Looks good, some quibbles with formatting. And we should see how DT/top400 tests look.
| includes & TypeFlags.IncludesWildcard ? wildcardType : anyType : | ||
| includes & TypeFlags.IncludesWildcard ? wildcardType : | ||
| includes & TypeFlags.IncludesError ? errorType : anyType : | ||
| unknownType; |
There was a problem hiding this comment.
These ternaries are officially off the chain now.
There was a problem hiding this comment.
🤷♀️ I just write the ternaries, I let the formatter figure out how it wants to indent them.
| } | ||
| if (includes & TypeFlags.Any) { | ||
| return includes & TypeFlags.IncludesWildcard ? wildcardType : anyType; | ||
| return includes & TypeFlags.IncludesWildcard ? wildcardType : includes & TypeFlags.IncludesError ? errorType : anyType; |
There was a problem hiding this comment.
it would be nice to have multiple lines here
| /** @internal */ | ||
| Reserved1 = 1 << 29, // Used by union/intersection type construction | ||
| /** @internal */ | ||
| Reserved2 = 1 << 30, // Used by union/intersection type construction |
There was a problem hiding this comment.
remind me, do we have 31 bits available?
There was a problem hiding this comment.
In modern Node, yep, we do.
Jake Bailey (jakebailey)
commented
May 22, 2024
TypeScript Bot (@typescript-bot) test it |
TypeScript Bot (typescript-bot)
commented
May 22, 2024
Jake Bailey (@jakebailey) Here are the results of running the user tests comparing Something interesting changed - please have a look. Details
|
TypeScript Bot (typescript-bot)
commented
May 22, 2024
Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready. Everything looks the same! |
TypeScript Bot (typescript-bot)
commented
May 22, 2024
Jake Bailey (@jakebailey) Here they are:tscComparison Report - baseline..pr
System info unknown Hosts
Scenarios
Developer Information: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Wesley Wigham (weswigham)
commented
May 22, 2024
TypeScript Bot (@typescript-bot) pack this |
Hey Wesley Wigham (@weswigham), 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 |
TypeScript Bot (typescript-bot)
commented
May 22, 2024
Jake Bailey (@jakebailey) Here are the results of running the top 400 repos comparing Something interesting changed - please have a look. Details
|
TypeScript Bot (@typescript-bot) user test this |
TypeScript Bot (typescript-bot)
commented
May 22, 2024
Wesley Wigham (@weswigham) Here are the results of running the user tests comparing Something interesting changed - please have a look. Details
|
Something is funky with Jake Bailey (@jakebailey) is the runner silently failing to install/link dependencies correctly for that user test or something? That's the only thing I could think of, which is why I reran the test. And it would make sense - these kinda of errors are what I'd expect to see if some intersections in class base types contained unresolved types that now get propagated out (instead of quietly |
Jake Bailey (jakebailey)
commented
May 22, 2024
The test thing infers packages and tsconfigs and attempts to install them and run on each of them, so it's possible that it's just doing things "wrong" for that repo. We can convert it to a script test or something where it more clearly tries to run things, but we'll lose the inference of configs and such. I'm not sure I have the time to try and fix the root problem, though. |
The project does have one diff in the real output - a new error - but it's a follow-on caused by what I said above - a class has an error type intersected into its' base types, so all its' base types get erased now, rather than Big downside of using |
Wesley Wigham (weswigham)
commented
May 22, 2024
Useful investigation regardless, even if there wasn't really much related to this issue, disabling |
You might not think this is the obvious fix for the issue, but it is! Type parameter constraints, when they see a non-error
any, remap it tounknown(there are historical reasons for this). So by swallowing the error-any(and replacing it with a normalany), union and intersection construction resulted in the constraint calculation logic not witnessing the error type, and thus remapping the constraint (and, thus, making the constraint from the type node not match the cached constraint on the type parameter itself!)This should also just behave a bit better with respect to follow on errors in some other cases, too.
Fixes#58598