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

Generics: Cannot find name 'T'. #3164

Closed
metkm opened this issue May 11, 2023 · 8 comments
Closed

Generics: Cannot find name 'T'. #3164

metkm opened this issue May 11, 2023 · 8 comments
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@metkm
Copy link

metkm commented May 11, 2023

I've created a repository with this error.
https://github.com/metkm/generic-issue

Volar versions I have installed:
Vue Language Features (Volar) v1.2.0
TypeScript Vue Plugin (Volar) v1.6.4

image

@metkm
Copy link
Author

metkm commented May 11, 2023

Also when I switch to pre-release version on both extensions defineModel macro is overwriting the defineProps macro.

<script setup lang="ts" generic="T">
defineProps<{
  num: number
}>()
const modelValue = defineModel<T>();
</script>

this gives Argument of type '{ num: number; }' is not assignable to parameter of type '{ modelValue?: unknown; } & VNodeProps & AllowedComponentProps & ComponentCustomProps'. Object literal may only specify known properties, and 'num' does not exist in type '{ modelValue?: unknown; } & VNodeProps & AllowedComponentProps & ComponentCustomProps'.

image

@zf1998
Copy link

zf1998 commented May 25, 2023

Update vue to @3.3.x, vue-tsc to @1.6.x , See detail .

@thimonwentink
Copy link

@zf1998 I'm running into the same problem and have exactly the package versions you mention (vue 3.3.4 and vue-tsc 1.6.5)

@localusercamp
Copy link

same here

@metkm
Copy link
Author

metkm commented May 25, 2023

Update vue to @3.3.x, vue-tsc to @1.6.x , See detail .

It doesn't work, please try if it works first

@Danny2462
Copy link

Danny2462 commented May 25, 2023

Something weird about this:
I had generics work when I updated Vue to 3.3
Then I decided to try out the pre-release version of both Vue.volar and Vue.vscode-typescript-vue-plugin
Switched back to release versions, and after a VSCode reload, this error started happening

The extension was in takeover mode before and after too

Switching back to pre-release fixes it, but I wasn't planning on actually using it, and now I seem to be stuck with it, so beware

@metkm
Copy link
Author

metkm commented May 25, 2023

@Danny2462 You can't use DefineModel macro with defineProps on pre-release though, Others should know it as well so I'm gonna comment on it again here. The screenshot of the issue is here #3164 (comment)

@zf1998
Copy link

zf1998 commented May 26, 2023

I update vue to @3.3.4, vue-tsc to @1.6.5, using webstorm development, manually point the typescript directory to vue-tsc.

Suggest using vue-tsc to check for type errors on the command line, to help us determine if the editor plugin and vue-tsc type check results are the same

@johnsoncodehk johnsoncodehk added the good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first label Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first
Projects
None yet
Development

No branches or pull requests

7 participants