core icon indicating copy to clipboard operation
core copied to clipboard

types(defineComponent): support for expose component types

Open pikax opened this issue 4 years ago • 27 comments

fix #3367

Changes

  • Support for typed Components - to allow extraction of the components available
  • Support for typed Directives and ComponentCustomDirectives (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 Directive type, 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'> 

pikax avatar Mar 09 '21 11:03 pikax