summaryrefslogtreecommitdiff
path: root/source/helpers/types.d.ts
blob: e3224b49301e468f5878fa66f16d551f554b3619 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* eslint-disable @typescript-eslint/consistent-type-definitions -- Declaration merging necessary */
/* eslint-disable @typescript-eslint/ban-types -- The API does return `null`, not `undefined` */
import type {StrictlyParseSelector} from 'typed-query-selector/parser';

declare global {
	interface ParentNode {
		querySelector<S extends string>(selector: S | readonly S[]): StrictlyParseSelector<S, HTMLElement> | null;

		querySelectorAll<S extends string>(
			selector: S | readonly S[],
		): NodeListOf<StrictlyParseSelector<S, HTMLElement>>;
	}

	interface Element {
		closest<S extends string>(selector: S | readonly S[]): StrictlyParseSelector<S, HTMLElement> | null;
		matches(selectors: string | readonly string[]): boolean;
	}

	// This cannot be a regular import because it turns `globals.d.ts` in a "module definition", which it isn't
	type Browser = import('webextension-polyfill').Browser;
	const browser: Browser;

}