vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.87k stars 405 forks source link

fallthroughAttributes does not work with generic components #4884

Closed jods4 closed 1 month ago

jods4 commented 2 months ago

Vue - Official extension or vue-tsc version

2.1.6

VSCode version

1.93.1

Vue version

5.4.8

TypeScript version

5.6.2

System Info

I have a playground repro, check it out

package.json dependencies

No response

Steps to reproduce

Check out the repro in playground link below.

It seems that all you need to break fallthroughAttributes is a generic component as the wrapper.

What is expected?

In playground, I expect completion for :str, which is a props of Comp2, that is wrapped by Comp1 with fallthrough.

What is actually happening?

I don't get completion. Note that all it takes to fix it is to remove the generic="T" in Comp1. If the wrapper is not generic, it seems to work.

Link to minimal reproduction

https://play.vuejs.org/#eNqNUk1r3DAQ/StTXTaFYNNtC8U4C2kJtD20oQ30Iihee+xVKktCGm0XjP97RjbxZkMSchHz+ebN6A3i0rlsH1EUogy1V44gIEW3kUb1znqCATy2MELrbQ8rLl0tqS+2d+/mhBRZPrkJTApppKmtCQR96OAiQZytvqLWFv5Yr5s3q7fSlPk8kWexQ9g7XRGyB1DO0EV1IcUHKSDnaJk/KBHnggJPaFWX3QZrmP+QGqWouVNp9D8dKWYgRQFTJuUqJvD/+xQjH/H8Pl7vsP73RPw2HFJMimuPAf2eN1tyVPkOaU5f/f6BB7aXZG+bqLn6heQvDFbHxHEu+xxNw7Qf1E1sv02nVqa7CVcHQhPul0pEU+U41UvBd09He271ltFo523sdpdEXm0j4SmONCNfdfnEx4oAXZmOv4O4Czo06FXN7g3wcmiawELZFmBiv0XPYOKooAS5PpXJ+iiTBltl8NpbF8oBqiPE5uwVGllvBm6CcSxn3Cd0ssx7aSMuPSUSyBfp4cu/gkqj9pPBZtCWJr2ync/xx4z+7tGnf2RC77OP2Scx3gEwRi8l

Any additional comments?

No response

KazariEX commented 2 months ago

Generic cannot be passed across components. It might be a design limitation.

It is better to explicitly specify the parent component that has root generic component as a generic component, rather than passing it via fallthrough attributes.

jods4 commented 2 months ago

@KazariEX Indeed, a wrapped (root) generic component cannot be inferred automatically across another component. I also agree that the best approach for this issue is to have the wrapper use some explicit generic instantiation.

My issue here is that if the wrapper is generic -- and the inner component might not be -- there is no fallthrough happening at all, as demonstrated in repro.

This case should be doable, I've managed to do it myself here: https://github.com/vuejs/language-tools/issues/4882#issuecomment-2375092076

KazariEX commented 2 months ago

Sorry, I misread it. This is indeed a bug.