Open
Description
Version
16.8.1
Reproduction link
github.com
Steps to reproduce
Given I have an array in my component:
private bookmakersVote: DataTypes.BookmakerVoteData[] = [];
and I'm using it in the template:
<div v-show="appState == 2" class="bookmaker-vote-wrapper" v-for="(bk, bkIndex) in bookmakersVote" :key="bk.id" :class="bkIndex % 2 == 0 ? 'even' : 'odd'"></div>
What is expected?
Successful compilation
What is actually happening?
vue-loader compiles it into:
_createElementBlock(_Fragment, null, _renderList(_ctx.bookmakersVote, (bk, bkIndex) => {
return _withDirectives((_openBlock(), _createElementBlock("div", {
class: _normalizeClass(["bookmaker-vote-wrapper", bkIndex % 2 == 0 ? 'even' : 'odd']),
key: bk.id
}, [
_createVNode(_component_bookmaker_vote, {
data: _ctx.bookmakersVote[bkIndex],
"onUpdate:data": ($event: any) => ((_ctx.bookmakersVote[bkIndex]) = $event),
lock: _ctx.bkVotesCount > 2,
onError: _ctx.showVoteError,
onVote: _ctx.countVote
}, null, 8 /* PROPS */, ["data", "onUpdate:data", "lock", "onError", "onVote"])
], 2 /* CLASS */)), [
[_vShow, _ctx.appState == 2]
])
}), 128 /* KEYED_FRAGMENT */)
ts-loader (v 9.2.6) refuses to compile that. It throws error:
ERROR in src/popup/popup.vue.ts
321:64-71
[tsl] ERROR in src/popup/popup.vue.ts(321,65)
TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
ts-loader-default_0c5a263502dc9404
Temporary fix is to wrap the index:
parseInt(`${bkIndex}`)