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

Setup script generic type problem #11394

Open
Frantab opened this issue Jul 18, 2024 · 4 comments
Open

Setup script generic type problem #11394

Frantab opened this issue Jul 18, 2024 · 4 comments

Comments

@Frantab
Copy link

Frantab commented Jul 18, 2024

Vue version

3.4.32

Link to minimal reproduction

https://play.vuejs.org/#eNqdVE1v2zAM/SusL3aBxsawnTK7RbcGWId+BG3Qy7yDazOpOlk2JDlNkeW/j5Js10mDFuvFsMhH6vGR1No7retw2aA39mKVS1ZrUKib+jgVrKwrqWENEuewgbmsSvAJ6veuc1E3unWEkT2ZXP7XQbC1zp5r7FOEkaajMqhU5JVQGpYZbxASc1Pw6ZAcceTIEA06aCxrnmmkE0B8MBqBSdjRfagaXsAzcg76IdMgmvIeJTAFotKQKcUWIrvnCLoCpSUTC/hLIIKPRi6jq2M5KqsCeZJ6lk7qwdgQpXNfQ3hr48kVUWQcDYh5R55WVM2cLcJHVQkSdG2Sp15elTXjKK9rzaja1BuD9Rhfxnn19NPatGzwqLPnD5j/2WN/VCtjS72pRIVySSx7n87kArVzT26vcEX/vZNKazih33DeoKp4Yzg62LdGFER7gLNsz21nSYWZmqw0CtUVZYga5MbiScUGv79R+gvdz+EXG5eKDanYj9HuSALPxIK6oSkPLFCgZDkdZ0DFoCjUy6gdwR0N0x5HeOVm46QbknYQxnvBrtkE3p6aMQhcGl2GO2Ka3GgsthblP/YgimB6cz29pQihUc6zHGEqq1o5wQySSBKUVOq2prb+BAqcM4EWHdvvcWB2yCa9vD6bXFBWF2EH/K5dNhd2aUzx3SDk7HR22gVgwbTZnS6mKzP+Mbu8sCVNOJYo9C/fLo3/+ziwhKm1wWHXbEntk2Jwe+gW/iBJnKQn4LQOdiGHpLZvFOrGiiYhEPhkIX1+NofAihEanSChtLst77EAVOJAh/b5uMftkejArzgT4/Z6S592xMpYUA3upgE9mhRKZdkTf0Cu8H0aW8P2ERq9Y/v6TsPNe+9rwZb2h37ZzsO4NQ7tK0iwyIW8eg/NeIda0SLjyq4BksaDTbBatCuZgO8a4Ns+t7tHVqeHsVIJ3uYflE9Dxw==

Steps to reproduce

enum Type {
Number = 'number',
String = 'string',
}

  1. make generic type like
    generic="T extends Type, V = T extends Type.Number ? number | null : T extends Type.String ? string | null : never">
  2. try to use V. It will never be used as resolved by T

What is expected?

V should be generic based on the given T

What is actually happening?

V is never resolved inside vue component nor when using the component

System Info

VS code IDE

Any additional comments?

When defining model as
const modelValue = defineModel<T extends Type.Number ? number | null : T extends Type.String ? string | null : never>();
than when using the component, type is calculated from the generic T.

@edison1105
Copy link
Member

/cc @so1ve

@so1ve
Copy link
Member

so1ve commented Jul 19, 2024

V = ... is not associated with T. It can be any other type.

@Frantab
Copy link
Author

Frantab commented Jul 19, 2024

Ok, I see the problem. I tried to write it differently in TS:
Ts playground

Then I tried it in my IDE and it works for the component itself so when I pass InputType.String, will tell me I need to pass string | null in prop modelValue. In the <script> however it's not resolved. I tried it in the vue playground and there is an Error: [@vue/compiler-sfc] Unresolvable type: TSConditionalType which I'm not getting on my local IDE.
Vue version in playground

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

4 participants