Skip to content

Commit

Permalink
types(compile): compile's return value takes a Node
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Apr 16, 2021
1 parent a757a4a commit 1419455
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function compile<Node, ElementNode extends Node>(
selector: string | Selector[][],
options: InternalOptions<Node, ElementNode>,
context?: Node[] | Node
): CompiledQuery<ElementNode> {
): CompiledQuery<Node> {
const next = compileUnsafe(selector, options, context);
return ensureIsTag(next, options.adapter);
}
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ function convertOptionFormats<Node, ElementNode extends Node>(
return opts as InternalOptions<Node, ElementNode>;
}

function wrapCompile<Selector, Node, ElementNode extends Node>(
function wrapCompile<Selector, Node, ElementNode extends Node, R extends Node>(
func: (
selector: Selector,
options: InternalOptions<Node, ElementNode>,
context?: Node[] | Node
) => CompiledQuery<ElementNode>
) => CompiledQuery<R>
) {
return function addAdapter(
selector: Selector,
options?: Options<Node, ElementNode>,
context?: Node[] | Node
) {
): CompiledQuery<R> {
const opts = convertOptionFormats(options);

return func(selector, opts, context);
Expand Down
4 changes: 2 additions & 2 deletions src/pseudo-selectors/subselects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export const PLACEHOLDER_ELEMENT = {};
export function ensureIsTag<Node, ElementNode extends Node>(
next: CompiledQuery<ElementNode>,
adapter: Adapter<Node, ElementNode>
): CompiledQuery<ElementNode> {
if (next === falseFunc) return next;
): CompiledQuery<Node> {
if (next === falseFunc) return falseFunc;
return (elem: Node) => adapter.isTag(elem) && next(elem);
}

Expand Down

0 comments on commit 1419455

Please sign in to comment.