index.d.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. /// <reference types="miniprogram-api-typings" />
  2. import { Weapp } from './weapp';
  3. declare type RecordToAny<T> = {
  4. [K in keyof T]: any;
  5. };
  6. declare type RecordToReturn<T> = {
  7. [P in keyof T]: T[P] extends (...args: any[]) => any ? ReturnType<T[P]> : T[P];
  8. };
  9. export declare type CombinedComponentInstance<Data, Props, Methods, Computed> = Methods & WechatMiniprogram.Component.TrivialInstance & Weapp.FormField & {
  10. data: Data & RecordToReturn<Computed> & RecordToAny<Props>;
  11. };
  12. export interface VantComponentOptions<Data, Props, Methods, Computed, Instance> {
  13. data?: Data;
  14. field?: boolean;
  15. classes?: string[];
  16. mixins?: string[];
  17. props?: Props & Weapp.PropertyOption;
  18. watch?: Weapp.WatchOption<Instance>;
  19. computed?: Computed & Weapp.ComputedOption<Instance>;
  20. relation?: Weapp.RelationOption<Instance> & {
  21. name: string;
  22. };
  23. relations?: {
  24. [componentName: string]: Weapp.RelationOption<Instance>;
  25. };
  26. methods?: Methods & Weapp.MethodOption<Instance>;
  27. beforeCreate?: (this: Instance) => void;
  28. created?: (this: Instance) => void;
  29. mounted?: (this: Instance) => void;
  30. destroyed?: (this: Instance) => void;
  31. }
  32. export {};