You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constinput: readonlystring[]=['foo','bar'];constmatchSorted=matchSorter(input,'f');// does not compile, plain array is required
Problem description:
The type signature of matchSorter is overly restrictive. Even though it does not modify its input array, it does not accept readonly arrays.
To work around this one needs to either do a cast (which basically disables type safety) or copy the array unnecessarily before passing it to matchSorter.
Suggested solution: matchSorter should accept a ReadonlyArray instead of a plain Array.
I am creating this issue before a pull request, to first have a discussion about the scope. This readonly issue not only affects the input array (although that is where I discovered it), it also applies to for example MatchSorterOptions.keys. Changing it there however would be a breaking change (as opposed to the type signature of matchSorter).
The text was updated successfully, but these errors were encountered:
match-sorter
version: 6.3.0node
version: 14.17.0Problem description:
The type signature of
matchSorter
is overly restrictive. Even though it does not modify its input array, it does not acceptreadonly
arrays.To work around this one needs to either do a cast (which basically disables type safety) or copy the array unnecessarily before passing it to
matchSorter
.Suggested solution:
matchSorter
should accept aReadonlyArray
instead of a plainArray
.I am creating this issue before a pull request, to first have a discussion about the scope. This readonly issue not only affects the input array (although that is where I discovered it), it also applies to for example
MatchSorterOptions.keys
. Changing it there however would be a breaking change (as opposed to the type signature ofmatchSorter
).The text was updated successfully, but these errors were encountered: