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

Can't use TS generics when defining a type for defineProps #8996

Closed
coolCucumber-cat opened this issue Aug 17, 2023 · 1 comment
Closed

Can't use TS generics when defining a type for defineProps #8996

coolCucumber-cat opened this issue Aug 17, 2023 · 1 comment

Comments

@coolCucumber-cat
Copy link

Vue version

3.3.4

Link to minimal reproduction

https://play.vuejs.org/#eNp9Uk1PwzAM/Sshl27S2IR2m7pKA00CDjDBJC65lNbtOtIkysfYVPW/46RrtwNwqJq892w/x27oSqnpwQFd0NhkulKWGLBOJUxUtZLakoZoKEhLCi1rEqE0ulAPslY9488+E9JMZFIYS2pTkqUPH0WPwLkkH1Lz/CYaMxHPumpYBy8WasVTC3gjJN7dJU0Tgts2nuEtoJVQzpLDbS1z4EtGkWe0o3zpJJ6Fn089pKMTag16KapyujdSYJeNj2A0Q23FQb8qW6FXRhckMJ5L0er3c8CsdjDp8WwH2dcv+N4cPcboRoMBfQBGB86mugTb0ev3FzjieSCxFcdR/Q/5BkZy5z12snsncrR9pQtun8JAKlFuzfpoQZi+KW/UK9ugZxQH5J/pr9YvdufTeYhjosVX7Ifr1+QyLI3Dw+/qwQfoepcIT0WJE7NYKyjsSQHZaKkMrkdTn/xxQYSrP0G3g2AVbxPktx7o9kmdQ3IoKgEhQbyKwz9JRuPOy3mvaPsDtQ/3fw==

Steps to reproduce

I'm using script setup with TypeScript and Nuxt3.

I have a Props type which works perfectly fine, but using a generic makes it break (except 'Partial', 'Required', 'Readonly', 'Pick', 'Omit').

type Props = ... //works
type A<T> = T // should also work

const props = defineProps<Props>() // works
const props = defineProps<A<Props>>() // doesn't work ([plugin:vite:vue] [@vue/compiler-sfc] Unresolvable type reference or unsupported built-in utility type)

What is expected?

That the generic wouldn't change anything

What is actually happening?

[plugin:vite:vue] [@vue/compiler-sfc] Unresolvable type reference or unsupported built-in utility type

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (12) x64 AMD Ryzen 5 5600H with Radeon Graphics
    Memory: 6.96 GB / 15.34 GB
  Binaries:
    Node: 20.5.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.8.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.2134.0), Chromium (115.0.1901.203)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    vue: ^3.2.47 => 3.3.4

Any additional comments?

Pretty sure there are other issues but they're all saying it's a specifc generic that doesn't work, for me it's all generics (except 'Partial', 'Required', 'Readonly', 'Pick', 'Omit'), which is confusing since everone seems to have the same error. Maybe they didn't realise it's all generics. I remember hearing once something like this didn't work and someone on StackOverflow told me the ones that do work, but that's all I know. Could be a duplicate, if it is, I want to know the issue.

I'm just generally confused, hope someone can clear this up

@edison1105
Copy link
Member

duplicate of #8482

@sxzz sxzz closed this as not planned Won't fix, can't repro, duplicate, stale Aug 24, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants