johnsoncodehk / vue-tsc

vue-tsc --noEmit && vite build
https://www.npmjs.com/package/vue-tsc
MIT License
241 stars 6 forks source link

Operator '+' cannot be applied to types 'string | number | symbol' and 'number'. #36

Closed gd4Ark closed 3 years ago

gd4Ark commented 3 years ago

template:

<el-menu-item v-for="(developer, index) in developers"
              :key="developer.id"
              :index="index + 1"
              @click="onActive(developer)">
  <template #title>
    {{ developer.name }}
  </template>
</el-menu-item>

error:

Operator '+' cannot be applied to types 'string | number | symbol' and 'number'.
johnsoncodehk commented 3 years ago

Make sure developers is not any type, otherwise index is string | number | symbol type in expected.

gd4Ark commented 3 years ago

@johnsoncodehk Thanks.

I would like to know how to make it not check the template part of the .vue file, since I only want to check the script

johnsoncodehk commented 3 years ago

You can use @ts-ignore in template expression. Currently not support ignore type-checking for <template>, you can open feature request to Volar for discuss if you want.