mount.d.ts 1.5 KB

1234567891011121314151617181920212223
  1. import { ComponentPublicInstance, DefineComponent, VNode } from 'vue';
  2. import type { ComponentExposed, ComponentProps, ComponentSlots } from 'vue-component-type-helpers';
  3. import { MountingOptions } from './types';
  4. import { VueWrapper } from './vueWrapper';
  5. type ShimSlotReturnType<T> = T extends (...args: infer P) => any ? (...args: P) => any : never;
  6. type WithArray<T> = T | T[];
  7. type ComponentData<T> = T extends {
  8. data?(...args: any): infer D;
  9. } ? D : {};
  10. export type ComponentMountingOptions<T, P extends ComponentProps<T> = ComponentProps<T>> = Omit<MountingOptions<P, ComponentData<T>>, 'slots'> & {
  11. slots?: {
  12. [K in keyof ComponentSlots<T>]: WithArray<ShimSlotReturnType<ComponentSlots<T>[K]> | string | VNode | (new () => any) | {
  13. template: string;
  14. }>;
  15. };
  16. } & Record<string, unknown>;
  17. export declare function mount<T, C = T extends ((...args: any) => any) | (new (...args: any) => any) ? T : T extends {
  18. props?: infer Props;
  19. } ? DefineComponent<Props extends Readonly<(infer PropNames)[]> | (infer PropNames)[] ? {
  20. [key in PropNames extends string ? PropNames : string]?: any;
  21. } : Props> : DefineComponent, P extends ComponentProps<C> = ComponentProps<C>>(originalComponent: T, options?: ComponentMountingOptions<C, P>): VueWrapper<ComponentProps<C> & ComponentData<C> & ComponentExposed<C>, ComponentPublicInstance<ComponentProps<C>, ComponentData<C> & ComponentExposed<C> & Omit<P, keyof ComponentProps<C>>>>;
  22. export declare const shallowMount: typeof mount;
  23. export {};