Closed diesieben07 closed 3 years ago
I think we should support a regular array as well as a readonly array. PR is welcome.
A regular array can also be passed if a readonly
array is expected. The following compiles fine:
function acceptsArray(array: ReadonlyArray<string>) { }
const plainArray: string[] = ['foo'];
acceptsArray(plainArray); // compiles!
I'll make a PR later today!
:tada: This issue has been resolved in version 6.3.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
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 tomatchSorter
.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
).