Skip to content

Commit

Permalink
fix(within): fix ts error when reassigning
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis273 committed Dec 12, 2021
1 parent 1fc17be commit a9e1986
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions types/__tests__/type-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ export async function testWithin() {

await container.findByRole('button', {name: /click me/i})
container.getByRole<HTMLButtonElement>('button', {name: /click me/i})

let withinQueries = within(document.body)
withinQueries = within(document.body)
withinQueries.getByRole<HTMLButtonElement>('button', {name: /click me/i})
}

/*
Expand Down
8 changes: 4 additions & 4 deletions types/get-queries-for-element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export interface Queries {
[T: string]: Query
}

export function getQueriesForElement<T extends Queries = typeof queries>(
element: HTMLElement,
queriesToBind?: T,
): BoundFunctions<T>
export function getQueriesForElement<
T extends Queries = typeof queries,
K extends T = T,
>(element: HTMLElement, queriesToBind?: K): BoundFunctions<K>

0 comments on commit a9e1986

Please sign in to comment.