Skip to content

Commit

Permalink
Accept read-only selector array types (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Oct 26, 2024
1 parent afdd637 commit 0a0e39c
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ function isQueryable(object: BaseElements): object is ParentNode {
* @return The element found, if any
*/
function $<Selector extends string, Selected extends Element = ParseSelector<Selector, HTMLElement>>(
selectors: Selector | Selector[],
selectors: Selector | readonly Selector[],
baseElement?: ParentNode
): Selected | undefined;
function $<Selected extends Element = HTMLElement>(
selectors: string | string[],
selectors: string | readonly string[],
baseElement?: ParentNode
): Selected | undefined;
function $<Selected extends Element>(
selectors: string | string[],
selectors: string | readonly string[],
baseElement?: ParentNode,
): Selected | undefined {
// Shortcut with specified-but-null baseElement
Expand All @@ -45,15 +45,15 @@ export class ElementNotFoundError extends Error {
* @return The element found, or an error
*/
function expectElement<Selector extends string, Selected extends Element = ParseSelector<Selector, HTMLElement>>(
selectors: Selector | Selector[],
selectors: Selector | readonly Selector[],
baseElement?: ParentNode
): Selected;
function expectElement<Selected extends Element = HTMLElement>(
selectors: string | string[],
selectors: string | readonly string[],
baseElement?: ParentNode
): Selected;
function expectElement<Selected extends Element>(
selectors: string | string[],
selectors: string | readonly string[],
baseElement?: ParentNode,
): Selected {
// Shortcut with specified-but-null baseElement
Expand All @@ -75,15 +75,15 @@ function expectElement<Selected extends Element>(
* @return The element found, if any
*/
function lastElement<Selector extends string, Selected extends Element = ParseSelector<Selector, HTMLElement>>(
selectors: Selector | Selector[],
selectors: Selector | readonly Selector[],
baseElement?: ParentNode
): Selected | undefined;
function lastElement<Selected extends Element = HTMLElement>(
selectors: string | string[],
selectors: string | readonly string[],
baseElement?: ParentNode
): Selected | undefined;
function lastElement<Selected extends Element>(
selectors: string | string[],
selectors: string | readonly string[],
baseElement?: ParentNode,
): Selected | undefined {
// Shortcut with specified-but-null baseElement
Expand All @@ -102,7 +102,7 @@ function lastElement<Selected extends Element>(
* @return Whether it's been found
*/
function elementExists(
selectors: string | string[],
selectors: string | readonly string[],
baseElement?: ParentNode,
): boolean {
// Shortcut with specified-but-null baseElement
Expand All @@ -119,15 +119,15 @@ function elementExists(
* @return An array of elements found
*/
function $$<Selector extends string, Selected extends Element = ParseSelector<Selector, HTMLElement>>(
selectors: Selector | Selector[],
selectors: Selector | readonly Selector[],
baseElements?: BaseElements
): Selected[];
function $$<Selected extends Element = HTMLElement>(
selectors: string | string[],
selectors: string | readonly string[],
baseElements?: BaseElements
): Selected[];
function $$<Selected extends Element>(
selectors: string | string[],
selectors: string | readonly string[],
baseElements?: BaseElements,
): Selected[] {
// Shortcut with specified-but-null baseElements
Expand Down

0 comments on commit 0a0e39c

Please sign in to comment.