-
-
Notifications
You must be signed in to change notification settings - Fork 399
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
Experimental RFC 436 - cannot use generic prop as object key in template without props
#2192
Comments
This is the @pikax I'm pinging you here, but maybe I can try to fix it when I am free. |
Hi, when I try upgrading vue from |
@pikax naively changing these few lines would avoid the problem, but I don't know how much this would break. I'll leave this issue for upstream attention. @cohlar can you open an issue on the vuejs/core repo? type InferPropType<T> = [T] extends [null]
? any // null & true would fail to infer
: [T] extends [{ type: null | true }]
? any // As TS issue https://github.com/Microsoft/TypeScript/issues/14829 // somehow `ObjectConstructor` when inferred from { (): T } becomes `any` // `BooleanConstructor` when inferred from PropConstructor(with PropMethod) becomes `Boolean`
: [T] extends [ObjectConstructor | { type: ObjectConstructor }]
? Record<string, any>
: [T] extends [BooleanConstructor | { type: BooleanConstructor }]
? boolean
: [T] extends [DateConstructor | { type: DateConstructor }]
? Date
: [T] extends [(infer U)[] | { type: (infer U)[] }]
? U extends DateConstructor
? Date | InferPropType<U>
: InferPropType<U>
- : [T] extends [Prop<infer V, infer D>]
- ? unknown extends V
- ? IfAny<V, V, D>
- : V
+ : [T] extends [PropType<infer V>] ? V
+ : [T] extends [{ type: PropType<infer V> }] ? V
: T |
With
defineProps
, the props are normally available in the template without the need to useconst props = defineProps<...>()
and addingprops.
before the prop name.However when adding a generic prop as a key to an object in the HTML template, we get an error.
I made a public repo to showcase the issue. The generic component with the error is
TheWelcome
- please note this repo is shared with #2191 (separate branches).The text was updated successfully, but these errors were encountered: