Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/consistent-type-definitions -- Module augmentation */
/// <reference path="./node_modules/typed-query-selector/strict.d.ts" />

// Broaden types because testing against `"undefined"` is fine for our regexes
interface RegExp {
Expand Down
6 changes: 4 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import reservedNames from 'github-reserved-names/reserved-names.json' with {type: 'json'};
import {addTests} from './collector.ts';

const $ = <E extends Element>(selector: string) => document.querySelector<E>(selector);
const exists = (selector: string) => Boolean($(selector));
// Selector helpers with typed-query-selector validation.
// The generic parameter allows type override when selector inference isn't specific enough (e.g., attribute-only selectors)
const $ = <E extends Element = Element>(selector: string) => document.querySelector<E>(selector);
const exists = (selector: string): boolean => Boolean(document.querySelector(selector));
Comment thread
fregante marked this conversation as resolved.
Outdated

const combinedTestOnly = ['combinedTestOnly']; // To be used only to skip tests of combined functions, i.e. isPageA() || isPageB()

Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"svelte-check": "^4.3.5",
"ts-morph": "^27.0.2",
"tsx": "^4.21.0",
"typed-query-selector": "^2.12.0",
"typescript": "5.9.3",
"vite": "^7.3.1",
"vitest": "^4.0.17",
Expand Down