Skip to content

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

Closed as not planned
@coolCucumber-cat

Description

@coolCucumber-cat

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions