language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Property '$t' does not exist on type 'Vue3Instance'

Open TheDutchCoder opened this issue 1 year ago • 8 comments

We have a Nuxt2/Vue2 project, but for some reason, in certain components, Volar reports the following error:

Property '$t' does not exist on type 'Vue3Instance<{}, Readonly<ExtractPropTypes<{}>>, Readonly<ExtractPropTypes<{}>>, {}, {}, true, ComponentOptionsBase<any, any, any, any, ... 5 more ..., any>> & ... 4 more ... & Readonly<...>'.ts(2339)

Why is it thinking it should be a Vue3Instance, when the project is vue 2? It also doesn't happen everywhere, which is odd.

Weird error: image

This seems fine: image

TheDutchCoder avatar Oct 04 '23 23:10 TheDutchCoder

Could you please provide a minimal reproduction?

so1ve avatar Oct 05 '23 02:10 so1ve

Are you using vue 2.7? The exported type name from vue package is called Vue3Instance to tell users its began will be like vue 3, and this doesn't matter.

so1ve avatar Oct 05 '23 09:10 so1ve

Did you do this https://i18n.nuxtjs.org/v7/setup#typescript ?

rchl avatar Oct 05 '23 10:10 rchl

We're not using Typescript and the Volat TS extension is disabled as well, this comes from the Volar Language Server one.

TheDutchCoder avatar Oct 05 '23 10:10 TheDutchCoder

Please provide a minimal reproduction to help debug, thanks!

so1ve avatar Oct 05 '23 10:10 so1ve

It doesn't matter if you are using typescript or not you have to configure it as per nuxt-i18n module documentation.

rchl avatar Oct 05 '23 10:10 rchl

I came across the same error, also with nuxt2, vue2 and no ts.

It only occurs in .vue files without <script> tags. Even an empty <script></script> "resolves" the error.

I don't think that counts as a solution or is a <script> tag a must in .vue files?

s4b2x avatar Dec 05 '23 09:12 s4b2x

Same problem in a Nuxt Bidge app

Suniron avatar May 13 '24 08:05 Suniron

Closing this one due to lack of a minimal reproduction. If this is still an issue in version 2.x, feel free to create a new issue with a minimal reproduction.

davidmatter avatar Aug 05 '24 20:08 davidmatter