Normalise prop types of mapped components with ArrayValue
#1739
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.
From #1738 (comment)
The
value
,auxValues
,errors
,auxErrors
andaxisValues
props of mapped components (MappedLineVis
,MappedRgbVis
, etc.) were typed in a few different, inconsistent ways:NumArray
(=number[] | TypedArray
)ArrayValue<DType>
(whereDType
matches the one of thedataset
prop — e.g.Dataset<ArrayShape, NumericType>
=>ArrayValue<NumericType>
, but it works with any other dtype or dtype union likeNumericLikeType
)Value<Props['dataset']>
to avoid duplicating the dtype.While the third way is the most robust and DRY, it's not the most readable since it adds an extra level of misdirection. And while the first way is the most explicit, it becomes less readable and/or more error-prone with other dtypes, like
NumericLikeType
,PrintableType
orComplexType
(especially once we start supporting big ints).So I'm going for the middle ground with
ArrayValue
.While I'm at it:
NumArrayDataset
completely, which was an alias forDataset<ArrayShape, NumericType>
; it adds a couple of imports in a few files, but it's less confusing, especially since we don't have aliases for datasets with other dtypes, likeDataset<ArrayShape, NumericLikeType>
.Primitive
toScalarValue
. This makes it clearer thatScalarValue
is the value of datasets withScalarShape
.