Skip to content

Commit

Permalink
fix: revert breaking type change (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanick authored Jun 4, 2022
1 parent 5336903 commit 8d30f73
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,42 @@
// Definitions by: Rahim Alwer <https://github.com/mihar-22>

import {queries, Queries, BoundFunction, EventType} from '@testing-library/dom'
import { SvelteComponentTyped } from 'svelte/types/runtime'
import { SvelteComponent } from 'svelte/types/runtime'

export * from '@testing-library/dom'

export interface SvelteComponentOptions<P extends Record<string, any> = any> {
target?: HTMLElement
anchor?: string
props?: P
context?: any
hydrate?: boolean
intro?: boolean
}
type SvelteComponentOptions = any

type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>

/**
* Render a Component into the Document.
*/
export type RenderResult<Q extends Queries = typeof queries> = {
container: Element
container: HTMLElement
component: SvelteComponent
component: SvelteComponentTyped
debug: (el?: Element | DocumentFragment) => void
debug: (el?: HTMLElement | DocumentFragment) => void
rerender: (options: SvelteComponentOptions) => void
unmount: () => void
} & { [P in keyof Q]: BoundFunction<Q[P]> }

export interface RenderOptions<Q extends Queries = typeof queries> {
container?: Element
container?: HTMLElement
queries?: Q
}

export function render(
component: SvelteComponentTyped,
component: typeof SvelteComponent,
componentOptions?: SvelteComponentOptions,
renderOptions?: Omit<RenderOptions, 'queries'>
): RenderResult

export function render<Q extends Queries>(
component: SvelteComponentTyped,
component: typeof SvelteComponent,
componentOptions?: SvelteComponentOptions,
renderOptions?: RenderOptions<Q>,
): RenderResult<Q>

export function render<
P extends Record<string, any> = any,
E extends Record<string, any> = any,
S extends Record<string, any> = any
>(
component: SvelteComponentTyped<P, E, S>,
componentOptions?: SvelteComponentOptions<P>,
renderOptions?: Omit<RenderOptions, "queries">
): RenderResult;

/**
* Unmounts trees that were mounted with render.
*/
Expand Down

0 comments on commit 8d30f73

Please sign in to comment.