Open
Description
We should have a type that represent an optional type.
Syntax could be something like int?
or ?int
or option<int>
or optional<int>
Original comment: Introduce undefined values for properties and struct fields
I have the following use case:
export struct Style {
border-radius: length,
border-top-left-radius: length,
background: brush
}
component StyledRectangle {
in property <Style> style;
Rectangle {
background: style.background;
border-radius: style.border-radius;
border-top-left-radius: style.border-top-left-radius;
}
}
export component MyExample inherits Window {
width: 600px;
height: 400px;
StyledRectangle {
style: {
background: #000000;
border-top-left-radius: 8px;
}
}
}
The following example does not work as expected, because the top left border radius of inner Rectangle
will not be rendered with 8px
but instead with 0
. The problem is, that if the border-radius
field on Style
is not explicit set it will defaults to 0
and it overwrites the setting of border-top-left-radius
. What could help to solve this problem is to introduce undefined
for values and use this as default e.g. for border-radius
instead of 0
, so that is handled like there is no value set on the property border-radius
.