Add isComplete check to Reflection#2155
Merged
Merged
Conversation
msujew
reviewed
May 20, 2026
Comment on lines
+269
to
+272
| const value = (node as GenericAstNode)[prop.name]; | ||
| if (value === undefined || value === null) { | ||
| return false; | ||
| } |
Member
There was a problem hiding this comment.
Question: Now that I think about this - Arrays are always initialized as empty arrays, even if no explicit default value is set. But here we only check against undefined and null. This means that an array that is empty, but non-optional will still pass this check. Is this intended?
Contributor
Author
There was a problem hiding this comment.
In this case that's intended, but it's a good point. This is just meant to avoid accessing any prop that might otherwise crash. So the empty array case should be okay, so long as some value is present.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Candidate feature for adding an
isCompletechecker to our reflection setup, so we can do built-in checks for whether nodes are missing non-optional properties. This is in response to a number of cases where nodes deviate from their declared type interfaces in the generated ast.ts, which can lead to some nasty surprises when doing validation checks, generation, etc. Really anything that expects the node to conform to it's type. As far as I'm aware, there's been a lot of manual sanity checking to avoid these kinds of cases when they pop up, so the idea here is to try and make that easier to handle up front.To support this I added in an
optionalproperty to the generated property metadata, so we can recover optionality at runtime without too much effort, but then this requires a regeneration of the ast.ts to get the feature working.Definitely open for suggestions & feedback on this one, as this is the first approach I've come up with.