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

type inference for generic props with extends and additional options #12186

Open
randName opened this issue Oct 16, 2024 · 1 comment
Open

type inference for generic props with extends and additional options #12186

randName opened this issue Oct 16, 2024 · 1 comment

Comments

@randName
Copy link

Vue version

3.5.12

Link to minimal reproduction

https://play.vuejs.org/#eNqtVNtu2zAM/RVOL7kgsLF1ezGcYF3Xh27YVmx9q4ohcJjMrSNpkpzEMPzvo+Rbll7Q25NF8pA8PKJcsmOlgk2OLGKxSXSqLBi0uZpxka6V1BZKWOAyFXgiyRYoLFSw1HINA0obcMFFOB7Dxw59rqW6KBT+B4Nx2CC5AEJbXKtsbhHO6OTQB+7SWJ2KVQUnMvuKRRMlHHGBsoQbLKImNoGU0qKuElQ+6zMu49Y1qZE00yvwoAKJFMbCt6KXZHoo0rAkLCjSwkTgzwBabnsDwI0TgRfPHaFslet4X17NKmoIw2Ot58Vo0mZq/JunGhcRWJ1j466abyKzx3U5FKmZcfasrobuP8N6wqePVGfXzF9KtWbkl3jo9R+1Yngr6JlCGHb3fnl1G+P4OMz93fdzHq7Y1noDWy3FqlkIIqkFDEcwncHAorH0nmgCLqoRF3FYP0haWzLalXRLDPH+7kWu9pQzasggcjQaIyRsHHaJbMKsodVdpqvg2khBT94Lw1lCtVLS5IeyKa02Z93+cDbPMrn94n171045fzC5ucN/bXbOx9m5RoN6g5x1MTvXK7R1+PTXd9zRuQuu5SLPCP1A8CcameWOYw37lIsF0d7DebZn/ldEz/bCnO4sCtMO5Yj2K8IZ/ZmcjPeN3tM9Ct63F0Mq/t6gdjVJwKPgQ/D2Hav+AUugvU0=

Steps to reproduce

defineComponent with a type parameter that has an extends constraint, and use it to define a required prop (see repro)

What is expected?

props.cols is inferred properly

What is actually happening?

props.cols inferred as

[{
    type: PropType<ColDef<ItemType, ColKey>[]>;
    required: true;
}] extends [Prop<infer V, infer D>] ? unknown extends V ? keyof V extends never ? IfAny<...> : V : V : {
    type: PropType<ColDef<ItemType, ColKey>[]>;
    required: true;
}

System Info

System:
    OS: Linux 5.15 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (32) x64 13th Gen Intel(R) Core(TM) i9-13900K
    Memory: 22.28 GB / 24.45 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 22.9.0 - ~/.nvm/versions/node/v22.9.0/bin/node
    npm: 10.8.3 - ~/.nvm/versions/node/v22.9.0/bin/npm

Any additional comments?

note: using JSDoc annotations, but unsure how to replicate in TS due to the way generics interact with PropTypes. Here is the TS repro but not equivalent

https://play.vuejs.org/#eNrdVU1z0zAQ/Ss7urjteOwhhYvHCVNKD4UBOtBb1GFMsglubMlIctpMxv+dlezYTkOSArfm4mg/3r5dPUlrdlEUwbJEFrFYT1RaGNBoygKyRMyHnBnN2YiLNC+kMrCGKc5SgZeS1gKFgQpmSubgEYTXhplVgRR7o2Rxa/9uB3Hh/Jcye4+z+NpgboN8a/iIK8BHg2KqQRuVivkIhoS0wFXU+H1IKSOCTR5UFnEihTbwadURGz6lenK01ElBhHVE9ZR8oO8mfnznw0RmZNnDeWQjNDWfoc18u51aOywAOfYjQHUKwxGsuQD6OSpBhwlh2APdjbHwNmY/fj/nMOJzsRQJRQk4cbw9g9rQ7lZ+3UIzy7Fna3k+eBbVfrueupXzOdTwrJfczKLejWYBTl0RXCiVrPyNTeGvMlU4jcCoEhtz1Xzrvfv3/I7xdlrHvW+vs85CGsVpJ808WfROzRCOi9FN9amG+6M9Oh1IdHsG23rju9H/Tm0Ld79InllnZ7pHaO9M/a/o1FXdFRdBfeBfxLGrO7OK27kKByS3LfnFa7BXkSjzH6goj0A80hsXcVg/AXTh04LqF1likFYAcf9ujSxVehyIEYPIdtUswp3YweHgOGyrMJ8eGyI/S+fBvZaCXiS3KZxNCCyl/fhSmJSa46yVJWdJlsmHD87W0xbl/MTJ4g/2e/1obZzdKNSolshZ6zOJmqOp3VffPtOB7DlzOS0zij7g/IpaZqXlWIe9K8WUaPfiHNtr90jSGb/VV/bM601TlminUc7oubRz3Nd6R/c8eO3ySAA0xe9LVBaTBngevAleDVj1G0ron44=

related #9546 #9610 #9652

since rows: ItemType[] was inferred properly, it seems like #9546 is fixed? And since props.simplecols is inferred properly, it is only failing when within a detailed prop definition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants