github-url-detection icon indicating copy to clipboard operation
github-url-detection copied to clipboard

Add typed-query-selector/strict for compile-time CSS selector validation

Open Copilot opened this issue 1 month ago • 0 comments

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:

  • https://github.com/refined-github/github-url-detection/pull/120#issuecomment-1177894837
  • https://github.com/refined-github/github-url-detection/commit/1a04193dc4f8809329e9c448c8d05b3e8094ad6d

cc @yakov116 </issue_description>

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

  • Fixes refined-github/github-url-detection#137

✨ 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 avatar Jan 14 '26 08:01 Copilot