Subscribe on changes!

[Typescript] defining components and props results in "Unsafe assignment of an any value"

avatar
Jan 30th 2021

Version

3.0.5

Reproduction link

https://github.com/susnux/eslint-typescript-issue

Steps to reproduce

yarn install
yarn lint

What is expected?

No lint error.

What is actually happening?

src/App.vue
  12:33  error  Unsafe assignment of an any value  @typescript-eslint/no-unsafe-assignment

No sure if this is a vue-next error or a typescript-eslint error. If you do not set components (e.g. components: undefined, see comment in App.vue) props work as expected.

avatar
Jan 31st 2021

You need to add a declaration file:

// shims.d.ts
declare module '*.vue' {
  import { ComponentOptions } from 'vue'
  const component: ComponentOptions
  export default component
}
avatar
Jan 31st 2021

@HcySunYang Tank you, it works! Is that intended and I missed it in the docs or is this an issue?

avatar
Jan 31st 2021

@susnux you need the shims and I think it's valuable to add to https://v3.vuejs.org/guide/typescript-support.htmlin the docs-next repository