-
Hi, is it intentional an optional array like
will become non optional in the generated ast type? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @cdietrich, well, kind of. Currently, we always assign I'm not sure whether it's worth to revisit that decision, since you can assume that if an array is empty, that the respective property has not been visited by the parser, as otherwise there would be at least one element in there. Effectively, there's no difference between |
Beta Was this translation helpful? Give feedback.
Hey @cdietrich,
well, kind of. Currently, we always assign
[]
to any array to ensure that the property exists. This in turn led us to the decision to always generate array types to be non-optional, as they have at least an empty array assigned to them.I'm not sure whether it's worth to revisit that decision, since you can assume that if an array is empty, that the respective property has not been visited by the parser, as otherwise there would be at least one element in there. Effectively, there's no difference between
[]
andundefined
for the value of an array in the AST, except for the fact that handling empty arrays is much easier compared additionally handlingundefined
as a value.