core
core copied to clipboard
types(defineComponent): support for expose component types
fix #3367
Changes
- Support for typed
Components- to allow extraction of the components available - Support for typed
DirectivesandComponentCustomDirectives(aka global directives) - Initial support for typed
exposed- this is a bit different from the actual implementation, this types will allow the exposed vue internal component types - Improvements on
Directivetype, allowing to specify the modifiers and the expected argument.
Directive usage
Now Directives will hold more types to help the extensions:
export type Directive<
HostElement = any, // host Element type, eg: `HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement`
Value = any, // value typed, eg: `string` or `number`
Modifiers extends string = string, // possible modifiers, eg: `'trim' | 'number' | 'lazy'`
Arg extends string = string, // possible `arg`, eg: `string` or `'passive' | 'other'`
> =
// implementation
| ObjectDirective<HostElement, Value, Arg, Modifiers>
| FunctionDirective<HostElement, Value, Arg, Modifiers>
// vmodel type implementation
Directive<HTMLInputElement | HTMLTextAreaElement, any, 'trim' | 'number' | 'lazy'>