I just tried installing 0.4.1 and using it. See https://github.com/mdn/yari/pull/4484
Thankfully I manually tested it in my browser too because I managed to stumble into an error that I really struggle to reproduce now. I wasn't able to capture what the input was when it happened.
But basically, the result's .positions was undefined. I would have expected it to be a new Set() at least.
and so it would fail hard on if (positions.size) { because it's like doing if (undefined.size) {.
My TypeScript is unable to notice because it thinks that FzfResultItem always contains a .positions that is a Set<number>.
I just tried installing 0.4.1 and using it. See https://github.com/mdn/yari/pull/4484 Thankfully I manually tested it in my browser too because I managed to stumble into an error that I really struggle to reproduce now. I wasn't able to capture what the input was when it happened.
But basically, the result's
.positions
wasundefined
. I would have expected it to be anew Set()
at least.Looking at this code: https://github.com/ajitid/fzf-for-js/blob/3de0f96210facb8efcd02f7a7fac71df45e81e61/src/lib/matchers.ts#L49 it seems it tries to fall back to an empty
Set
but only if it's alreadynull
.The reason I noticed was that I have this code:
and so it would fail hard on
if (positions.size) {
because it's like doingif (undefined.size) {
. My TypeScript is unable to notice because it thinks thatFzfResultItem
always contains a.positions
that is aSet<number>
.