@testing-library/svelte
Advanced tools
Comparing version
{ | ||
"name": "@testing-library/svelte", | ||
"version": "5.2.5", | ||
"version": "5.2.6", | ||
"description": "Simple and complete Svelte testing utilities that encourage good testing practices.", | ||
@@ -78,3 +78,6 @@ "main": "src/index.js", | ||
"contributors:generate": "all-contributors generate", | ||
"preview-release": "./scripts/preview-release" | ||
"preview-release": "./scripts/preview-release", | ||
"install:3": "./scripts/install-dependencies 3", | ||
"install:4": "./scripts/install-dependencies 4", | ||
"install:5": "./scripts/install-dependencies 5" | ||
}, | ||
@@ -81,0 +84,0 @@ "peerDependencies": { |
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-redundant-type-constituents */ | ||
import type * as Svelte from 'svelte' | ||
import type { | ||
Component as ModernComponent, | ||
ComponentConstructorOptions as LegacyConstructorOptions, | ||
ComponentProps, | ||
EventDispatcher, | ||
mount, | ||
SvelteComponent as LegacyComponent, | ||
SvelteComponentTyped as Svelte3LegacyComponent, | ||
} from 'svelte' | ||
type IS_MODERN_SVELTE = Svelte.Component extends (...args: any[]) => any | ||
type IS_MODERN_SVELTE = ModernComponent extends (...args: any[]) => any | ||
? true | ||
: false | ||
type IS_LEGACY_SVELTE_4 = | ||
EventDispatcher<any> extends (...args: any[]) => any ? true : false | ||
/** A compiled, imported Svelte component. */ | ||
export type Component< | ||
P extends Record<string, any>, | ||
E extends Record<string, any>, | ||
P extends Record<string, any> = any, | ||
E extends Record<string, any> = any, | ||
> = IS_MODERN_SVELTE extends true | ||
? Svelte.Component<P, E> | Svelte.SvelteComponent<P> | ||
: Svelte.SvelteComponent<P> | ||
? ModernComponent<P, E> | LegacyComponent<P> | ||
: IS_LEGACY_SVELTE_4 extends true | ||
? LegacyComponent<P> | ||
: Svelte3LegacyComponent<P> | ||
@@ -22,8 +35,8 @@ /** | ||
*/ | ||
export type ComponentType<C> = IS_MODERN_SVELTE extends true | ||
? C | ||
: new (...args: any[]) => C | ||
export type ComponentType<C> = C extends LegacyComponent | ||
? new (...args: any[]) => C | ||
: C | ||
/** The props of a component. */ | ||
export type Props<C extends Component<any, any>> = Svelte.ComponentProps<C> | ||
export type Props<C extends Component> = ComponentProps<C> | ||
@@ -36,5 +49,5 @@ /** | ||
*/ | ||
export type Exports<C> = C extends Svelte.SvelteComponent | ||
export type Exports<C> = C extends LegacyComponent | ||
? C | ||
: C extends Svelte.Component<any, infer E> | ||
: C extends ModernComponent<any, infer E> | ||
? E | ||
@@ -48,5 +61,4 @@ : never | ||
*/ | ||
export type MountOptions<C extends Component<any, any>> = | ||
IS_MODERN_SVELTE extends true | ||
? Parameters<typeof Svelte.mount<Props<C>, Exports<C>>>[1] | ||
: Svelte.ComponentConstructorOptions<Props<C>> | ||
export type MountOptions<C extends Component> = C extends LegacyComponent | ||
? LegacyConstructorOptions<Props<C>> | ||
: Parameters<typeof mount<Props<C>, Exports<C>>>[1] |
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-redundant-type-constituents */ | ||
import type * as Svelte from 'svelte' | ||
import type { | ||
Component as ModernComponent, | ||
ComponentConstructorOptions as LegacyConstructorOptions, | ||
ComponentProps, | ||
EventDispatcher, | ||
mount, | ||
SvelteComponent as LegacyComponent, | ||
SvelteComponentTyped as Svelte3LegacyComponent, | ||
} from 'svelte' | ||
type IS_MODERN_SVELTE = Svelte.Component extends (...args: any[]) => any | ||
type IS_MODERN_SVELTE = ModernComponent extends (...args: any[]) => any | ||
? true | ||
: false | ||
type IS_LEGACY_SVELTE_4 = | ||
EventDispatcher<any> extends (...args: any[]) => any ? true : false | ||
/** A compiled, imported Svelte component. */ | ||
export type Component< | ||
P extends Record<string, any>, | ||
E extends Record<string, any>, | ||
P extends Record<string, any> = any, | ||
E extends Record<string, any> = any, | ||
> = IS_MODERN_SVELTE extends true | ||
? Svelte.Component<P, E> | Svelte.SvelteComponent<P> | ||
: Svelte.SvelteComponent<P> | ||
? ModernComponent<P, E> | LegacyComponent<P> | ||
: IS_LEGACY_SVELTE_4 extends true | ||
? LegacyComponent<P> | ||
: Svelte3LegacyComponent<P> | ||
@@ -22,8 +35,8 @@ /** | ||
*/ | ||
export type ComponentType<C> = IS_MODERN_SVELTE extends true | ||
? C | ||
: new (...args: any[]) => C | ||
export type ComponentType<C> = C extends LegacyComponent | ||
? new (...args: any[]) => C | ||
: C | ||
/** The props of a component. */ | ||
export type Props<C extends Component<any, any>> = Svelte.ComponentProps<C> | ||
export type Props<C extends Component> = ComponentProps<C> | ||
@@ -36,5 +49,5 @@ /** | ||
*/ | ||
export type Exports<C> = C extends Svelte.SvelteComponent | ||
export type Exports<C> = C extends LegacyComponent | ||
? C | ||
: C extends Svelte.Component<any, infer E> | ||
: C extends ModernComponent<any, infer E> | ||
? E | ||
@@ -48,5 +61,4 @@ : never | ||
*/ | ||
export type MountOptions<C extends Component<any, any>> = | ||
IS_MODERN_SVELTE extends true | ||
? Parameters<typeof Svelte.mount<Props<C>, Exports<C>>>[1] | ||
: Svelte.ComponentConstructorOptions<Props<C>> | ||
export type MountOptions<C extends Component> = C extends LegacyComponent | ||
? LegacyConstructorOptions<Props<C>> | ||
: Parameters<typeof mount<Props<C>, Exports<C>>>[1] |
/** | ||
* Customize how Svelte renders the component. | ||
*/ | ||
export type SvelteComponentOptions<C extends any> = import("./component-types.js").Props<C> | Partial<import("./component-types.js").MountOptions<C>>; | ||
export type SvelteComponentOptions<C extends import("./component-types.js").Component> = import("./component-types.js").Props<C> | Partial<import("./component-types.js").MountOptions<C>>; | ||
/** | ||
@@ -15,3 +15,3 @@ * Customize how Testing Library sets up the document and binds queries. | ||
*/ | ||
export type RenderResult<C extends any, Q extends import("@testing-library/dom").Queries = typeof import("@testing-library/dom/types/queries.js")> = { | ||
export type RenderResult<C extends import("./component-types.js").Component, Q extends import("@testing-library/dom").Queries = typeof import("@testing-library/dom/types/queries.js")> = { | ||
container: HTMLElement; | ||
@@ -95,3 +95,3 @@ baseElement: HTMLElement; | ||
*/ | ||
export function render<C extends any, Q extends import("@testing-library/dom").Queries = typeof import("@testing-library/dom/types/queries.js")>(Component: import("./component-types.js").ComponentType<C>, options?: SvelteComponentOptions<C>, renderOptions?: RenderOptions<Q>): RenderResult<C, Q>; | ||
export function render<C extends import("./component-types.js").Component, Q extends import("@testing-library/dom").Queries = typeof import("@testing-library/dom/types/queries.js")>(Component: import("./component-types.js").ComponentType<C>, options?: SvelteComponentOptions<C>, renderOptions?: RenderOptions<Q>): RenderResult<C, Q>; | ||
//# sourceMappingURL=pure.d.ts.map |
Sorry, the diff of this file is not supported yet
46581
2.07%667
3.41%