Skip to content

Commit 0bb3c2e

Browse files
committed
added explanation on defineComponent generics
1 parent 9d4abd2 commit 0bb3c2e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/guide/typescript/advanced.md

+38
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,44 @@ If you check the [defineComponent source-code](https://github.com/vuejs/core/blo
129129

130130
`DefineComponent` generic order is pretty stable, but it's not guaranteed to be the same in future versions, the reason is because it needs to support the full Vue behavior (eg: Mixins/Extends), so it's recommended to use the more stable helper [DeclareComponent](./../../api/utility-types.html#declarecomponent) instead.
131131

132+
```ts
133+
type DefineComponent<
134+
PropsOrPropOptions = any,
135+
RawBindings = any,
136+
D = any,
137+
C extends ComputedOptions = ComputedOptions,
138+
M extends MethodOptions = MethodOptions,
139+
Mixin extends ComponentOptionsMixin = {},
140+
Extends extends ComponentOptionsMixin = {},
141+
E extends EmitsOptions = {},
142+
EE extends string = string,
143+
PP = PublicProps,
144+
Props = ResolveProps<PropsOrPropOptions, E>,
145+
Defaults = ExtractDefaultPropTypes<PropsOrPropOptions>,
146+
I extends ComponentInjectOptions = any,
147+
II extends string = string,
148+
S extends SlotsType = any,
149+
Options extends Record<PropertyKey, any> = {},
150+
>
151+
```
152+
153+
- `PropsOrPropOptions`: `Props` definition.
154+
- `RawBindings`: `setup` return type.
155+
- `D`: `data` return type.
156+
- `C`: `computed` object.
157+
- `M`: `methods` object.
158+
- `Mixin`: `mixins` union type `(MixinA | MixinB)[]`.
159+
- `Extends`: `extends` type.
160+
- `E`: `emits` object, if object declaration is used.
161+
- `EE`: `emits` string union type, if string is used.
162+
- `PP`: `PublicProps`, contains `class`, `style`, `VNode` specific props and [ComponentCustomProps](../../api/utility-types#componentcustomprops).
163+
- `Props`: Sanitised props, these are `PropsOrPropOptions` but with the resolved type.
164+
- `Defaults`: defaulted props
165+
- `I`: `inject` object, if object declaration is used.
166+
- `II`: `inject` string union type, if string is used.
167+
- `S`: `slots` object.
168+
- `Options`: Unaltered `Options` object used to define the component.
169+
132170
### DefineComponent
133171

134172
Returned from [defineComponent](./../../api/general.html#definecomponent), has [Options](#options), [Render](#render) and [Instance](#instance) information about the component.

0 commit comments

Comments
 (0)