Property 'XXX' does not exist on type 'CombinedVueInstance<Vue, {}, {}, {}, Readonly<Record<never, any>>>'
As mentioned in the Typescript Support section of the Vue documentation:
Because of the circular nature of Vue’s declaration files, TypeScript may have difficulties inferring the types of certain methods. For this reason, you may need to annotate the return type on methods like render and those in computed.
In your case, you should change profilePath: function () {
to profilePath: function (): string {
You might come across the same error if you have a render() method that returns a value, without a : VNode
annotation.
This seems to be inexplicably caused by using this.$store
to compute the return value of profilePath
, combined with the unspecified return type on its declaration.
One workaround is to specify the return type as string
:
profilePath: function(): string {
verified with npm run serve
and npm run build
, using Vue CLI 3.7.0 on macOS Mojave
Try this:
(this as any).open
This also works with injected properties:
(this as any).injectedProp
And $refs:
(this as any).$refs.myElement
The compiler can show warnings, but work
Important: this is a temporary solution, is more elegant to use class components