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
Fix crash from missing valueDeclaration on intersection property #37696
Conversation
We still want to serialise properties that come from an intersection but only have one source property, right? If I understand correctly, |
I thought there was a reliable way to differentiate between properties that are just passed through an intersection vs those that combine two source properties. It might be having a defined Combined, these two statements:
make me think that the rules for setting valueDeclaration on intersection properties should change first and then the serialisation code can change if there's still a need. |
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.
Let's talk about the possibility of changing the rules for setting valueDeclaration in createUnionOrIntersectionProperty.
Yep, that’s what this PR does. But in my test case, the inherited |
I should also be more clear that I think my change to |
Fixes #37015
The error was occurring when trying to serialize a JS symbol into a class declaration, because one of its inherited property symbols was missing a
valueDeclaration
, which was the target of aDebug.assertIsDefined
.When two object types were unioned/intersectioned, the order of types was having an observable effect on whether the resulting property symbol had a
valueDeclaration
set. If the first type’s property didn’t have avalueDeclaration
but a later type’s property did, we’d take the later one. But in the inverse case, we’d say that there was a non-uniform value declaration so we wouldn’t attach one at all.Fixing this fixed the real-world repro at #37015 and improved one types baseline, but my minimal repro was still failing because the intersection property for
toString
had two different defined declarations, which seemed like a legitimate violation of the assertion’s assumption, so I removed the assertion. My understanding of this code is that inherited properties could all be filtered out, and ifvalueDeclaration
is undefined, the property must be inherited.