Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert breaking type change #198

Merged
merged 1 commit into from
Jun 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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