Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot recognize custom components and show error #4841

Closed
GnaugGnay opened this issue Sep 11, 2024 · 11 comments · Fixed by #4845
Closed

Cannot recognize custom components and show error #4841

GnaugGnay opened this issue Sep 11, 2024 · 11 comments · Fixed by #4845
Labels
bug Something isn't working

Comments

@GnaugGnay
Copy link

Vue - Official extension or vue-tsc version

Vue - Official extension

VSCode version

1.93.0

Vue version

2(with vue-class-component)

TypeScript version

3.9.10

System Info

System:
    OS: macOS 11.6
    CPU: (4) x64 Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
    Memory: 9.70 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.6 - /usr/local/bin/node
    Yarn: 1.22.21 - /usr/local/bin/yarn
    npm: 6.14.15 - /usr/local/bin/npm
  Browsers:
    Chrome: 128.0.6613.137
    Safari: 14.1.2

package.json dependencies

{
  devDependencies: {
    "vue-class-component": "7.2.6"
  }
}

Steps to reproduce

  1. open a vue sfc file of my project;
  2. check custom component in template tag.

What is expected?

shows normal with the tag of custom component.

What is actually happening?

shows error with every tag of the custom component.

errors look like: XXX does not exist on type 'Required<{} & __VLS_WithComponent .... ts-plugin(2339).

Link to minimal reproduction

No response

Any additional comments?

it happends when I update the extension to version 2.1.x, and disappears using version 2.0.x.

截屏2024-09-11 下午4 49 22
@KazariEX
Copy link
Collaborator

Could you provide a minimal reproduction for it?

@GnaugGnay
Copy link
Author

@KazariEX here is a demo for you

截屏2024-09-11 下午5 37 48

@KazariEX
Copy link
Collaborator

This is a known limitation, we deliberately do not support decorators to avoid overly complex code. However, since I don't know if it can obtain the correct type (or any) before 2.1, I don't know how to fix it.

@GnaugGnay
Copy link
Author

@KazariEX
I think, you guys should at least provide an option like "suppressTemplateIndexError" for us old-vue-version users. I really appreciate your works on it, but this error lints almost drive me crazy.

@KazariEX
Copy link
Collaborator

How about skipTemplateCodegen?

@GnaugGnay
Copy link
Author

@KazariEX Better name than mine!

@KazariEX
Copy link
Collaborator

This is an existing feature, you can configure it in your tsconfig.json:

"vueCompilerOptions": {
	"skipTemplateCodegen": true
}

@KazariEX
Copy link
Collaborator

KazariEX commented Sep 11, 2024

Could you tell me if using components imported with decorators in template before 2.1 can obtain the correct types?

@GnaugGnay
Copy link
Author

Could you tell me if using components imported with decorators in template before 2.1 can obtain the correct types?

The answer is No. I thought it's a limitation of vue2 or whatever at the first time and ignore this inconvenience.

As for the "skipTemplateCodegen" option, I have tried it and turns out it brings more disadvantages.
e.g., I can no longer using cmd + mouseLeft in template to locate the defination of variables and functions.

@KazariEX
Copy link
Collaborator

KazariEX commented Sep 11, 2024

The answer is No. I thought it's a limitation of vue2 or whatever at the first time and ignore this inconvenience.

This is what I want to know, If we just infer it as unknown, fixing it will become easier.

@GnaugGnay
Copy link
Author

Seems like our opinions finally come up together, hope ur update as soon as posible. I have to use version 2.0.x for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants