Nuxt2 + ts how to fix a bug?

Viewed 19

I have code. Use Nuxt.js 2 option api + ts

computed: {
      form: {
        get: () => this.value,
        set: (value) => this.$emit('input', value)
      }
    }

and errors

  1. TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

  2. TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

1 Answers

Specify the value type first and try again

for example:

computed: {
      form: {
        get: () => this.value,
        set: (value: string | number) => this.$emit('input', value)
      }
    }
Related