Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 14, 2026

Enables strict mode type checking for querySelector calls to catch invalid CSS selectors at compile time rather than runtime.

Changes

  • Added [email protected] as dev dependency
  • Imported typed-query-selector/strict in global.d.ts to enable selector validation
  • Wrapped existing RegExp interface augmentation in declare global block (required when file becomes a module)

Effect

Invalid selectors now produce TypeScript errors:

// Returns `never` type in strict mode - TypeScript error on usage
const el = document.querySelector('div[unclosed'); 

// Valid selectors get precise typing
const div = document.querySelector('div.container'); // HTMLDivElement | null

This prevents issues like malformed selectors reaching production (referenced in #120 and commit 1a04193).

Original prompt

This section details on the original issue you should resolve

<issue_title>Add typed-query-selector/strict locally to ensure selectors are valid</issue_title>
<issue_description>https://github.com/g-plane/typed-query-selector#strict-mode

This type should make TS fail if a selector is invalid. This would avoid:

cc @yakov116 </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add typed-query-selector/strict locally for selector validation Add typed-query-selector/strict for compile-time CSS selector validation Jan 14, 2026
Copilot AI requested a review from fregante January 14, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add typed-query-selector/strict locally to ensure selectors are valid

2 participants