-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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 generic prop type when definition includes intersection with generic params? #8482
Comments
Pretty sure this is a duplicate of #8468 |
@justin-schroeder They're not exactly the same. |
I get the same error when I use an imported type as an alias. I'm not 100% sure if these errors are related. <script setup lang="ts">
import type * as T from './Foo.types'
defineProps<T.Props>()
</script> |
Hello !! this is my code `export default interface IDynamicSelectInput<E, K, L>{ //props: PropsType & L; this is error `[plugin:vite:vue] [@vue/compiler-sfc] Unresolvable type reference or unsupported built-in utility type /home/trandx/dev/Nucle-x/sso/_mono/packages/ui/src/components/atoms/list/index.ts |
Yep I also tested the latest version (3.3.10) and still have the same issue. |
I am not sure if it is connected, but I have simillar problem even after updating from 3.3.4 to 3.3.13
ApiAuditGetRequest extends ApiGetRequestParams. And I am getting: |
We ran into this when trying to use zod type inference. |
I still have problems with generic on the latest version. Even the simple following code fails to compile: export type Test<T> = T |
Okay, thank you for your solution. But, I think that my issue has already
resolved in the resent version that contents Typescript 5.4
Le sam. 8 juin 2024 à 22:55, Clément Nerma ***@***.***> a
écrit :
… I still have problems with generic on the latest version. Even the simple
following code fails to compile:
export type Test<T> = T
—
Reply to this email directly, view it on GitHub
<#8482 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKENQXTGQCRWEHWYSAG4TY3ZGN4UJAVCNFSM6AAAAAAYX3IKCOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJWGIYDANRYGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I tried to re-use vuetify component's props version 3.4.29 |
I'm also getting the same error when trying to import an inferred zod type import { z } from 'zod';
export const EmailVerificationViewPropsSchema = z.object({
initialStage: z.enum(['send', 'resend', 'verify', 'changeEmail']),
email: z.string().email(),
});
export type EmailVerificationViewProps = z.infer<typeof EmailVerificationViewPropsSchema>; I'm importing it inside script setup: <script setup lang="ts">
import type { EmailVerificationViewProps } from './view-props';
const props = defineProps<EmailVerificationViewProps>();
/* ... */
</script> |
🙏 thanks
Le jeu. 20 juin 2024 à 15:14, rcomesan ***@***.***> a écrit :
… I'm also getting the same error when trying to import an inferred zod type
[plugin:vite:vue] ***@***.***/compiler-sfc] Unresolvable type reference or
unsupported built-in utility type
import { z } from 'zod';
export const EmailVerificationViewPropsSchema = z.object({
initialStage: z.enum(['send', 'resend', 'verify', 'changeEmail']),
email: z.string().email(),});
export type EmailVerificationViewProps = z.infer<typeof EmailVerificationViewPropsSchema>;
I'm importing it inside script setup:
<script setup lang="ts">import type { EmailVerificationViewProps } from './view-props';const props = defineProps<EmailVerificationViewProps>();/* ... */</script>
—
Reply to this email directly, view it on GitHub
<#8482 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKENQXRWG5NGMLLBFHNMY5TZILPUHAVCNFSM6AAAAAAYX3IKCOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBQHAYTONJQHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Any updates here? I am having this problem when importing |
I get a similar error when using prop extraction from the element-plus library. <template>
<ElButton v-bind="$props" :icon>
<slot />
</ElButton>
</template>
<script setup lang="ts">
import { ElButton } from 'element-plus'
import type { IconDefinition } from '@fortawesome/fontawesome-svg-core'
type TElButtonProps = InstanceType<typeof ElButton>['$props'];
const props = defineProps<TElButtonProps & {
awesomeIcon?: IconDefinition
}>()
const GenericIconComponent = resolveComponent('Icon')
const icon = h(GenericIconComponent, { name: props.awesomeIcon })
</script>
|
We massively rely on inferred types from zod schemas and run into this issue. Is this a design limitation of |
Vue version
3.3.4
Link to minimal reproduction
https://play.vuejs.org/#eNqFUbFOwzAQ/ZWTBwJSaRamNI3EgsSGRMXkJW6urYXjs2ynVRTl3zmHQCMGOtnne/feu+dBPDu3PncoClGGvdcuQsDYOTC1PW6liEGKSloA3TryEV6IXiO2cPDUQrbO5zpRZAm2JxsiHIhgC0M6C3hagap9AdkJjaFsBTp86KCVwQKi7xDGjbTSlvm3PqtxwZzO1BEn7fJH9fyotG3YFhNLATl3y3wB5TLE3qSroqaHIU2rev959NTZpgBluGC5ZNQQm7qcdMTpYZwszNNiJRab3Qgn9g5TMNeVbdcq9JvEOTXfqcU3Ty6Uu4pRO7hj5CIGRWSwtgkvbYMHbWf4dZD5q+r+4f+cGn3mjMKJLuzul59Nzh8y2YNxLHNG/g1PjF+nxbYT
Steps to reproduce
What is expected?
this should be valid typescript:
https://www.typescriptlang.org/play?#code/C4TwDgpgBAYg9nKBeKBvKAzBAuKA7AVwFsAjCAJygF8AoUSKAZTiIgAVy4wBnAHgBUAfMij8oAMjRQAltwBqs6SQA2EXCQSqAhnmo0AxnDzdgmHExbtOPXvDjCU6LHFwBmADQz5ilWqjByAmgqAG4aaQwoAApnADpZBW4lVQBKKENjOFVY5TgAcxiEFJCgA
What is actually happening?
compile error:
System Info
Any additional comments?
I'm not actually sure if I'm characterizing this correctly, but it seems like the sfc compiler cannot handle props whose type intersects one of its own generic parameters.
full pnpm lockfile if that's useful: https://gist.github.com/superfreddialpad/248efe40250d772938f31a2440e54e35
The text was updated successfully, but these errors were encountered: