[Vuejs]-How do I fix Vetur type error Typescript / Vue

0👍

Because you are adding the "?" symbol after the slot property, typescript inferred that the object property could have 2 values, either number[] or undefined.
If you are really sure that you already have a real value and not an undefined one, you can use "!" to tell typescript to relax.

siteStore.tableMatch.slot[0]!

You can have a look about the "!" symbol here:

https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#non-null-assertion-operator-postfix-

0👍

The error indicates that tableMatch is an array of TableMatchInterface objects. Did you mean something like

siteStore.tableMatch[0].slot

Either that or check that the typing on tableMatch is actually TableMatchInterface, and not something like TableMatchInterface[]

Leave a comment