vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.87k stars 400 forks source link

『Decorators are not valid here』 on methods #4631

Closed woden0415 closed 3 months ago

woden0415 commented 3 months ago

Vue - Official extension or vue-tsc version

v2.0.28

VSCode version

Version: 1.91.1

Vue version

^2.7.0

TypeScript version

null

System Info

System:
    OS: macOS 13.2.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 42.89 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
  Browsers:
    Chrome: 127.0.6533.88
    Edge: 125.0.2535.51
    Safari: 16.3

Steps to reproduce

this is demo repositories

git clone https://github.com/woden0415/test.git
cd test
npm i
npm run dev

the code can running normally image image

but the ts check failed Decorators are not valid here.ts-plugin(1206) image

image

What is expected?

ts check pass

What is actually happening?

ts check fail

Link to minimal reproduction

https://github.com/woden0415/test.git

Any additional comments?

No response

Pentadome commented 3 months ago

Decorators can only be used on classes and their members

davidmatter commented 3 months ago

As @Pentadome mentioned, this is a syntax issue and has nothing to do with this repo. If you need further information on how to use decorators, refer to https://www.typescriptlang.org/docs/handbook/decorators.html