fix(ts): upgrade to TypeScript 6, fix type errors, modernize jsconfig#5169
fix(ts): upgrade to TypeScript 6, fix type errors, modernize jsconfig#5169marcoscaceres wants to merge 19 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the codebase to be compatible with newer TypeScript checking by modernizing jsconfig.json, refining ambient type helpers, and adding JSDoc/type assertions across core/template/UI modules to address stricter JS type-checking.
Changes:
- Update
src/jsconfig.jsonmodule resolution settings and compiler options for modern TS tooling. - Adjust
src/type-helper.d.tsto align with updated DOM/Intl typings and module declarations. - Add JSDoc annotations / type assertions and null-safety fixes across
src/to eliminate TS type errors.
Reviewed changes
Copilot reviewed 97 out of 98 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/w3c/templates/sotd.js | Add JSDoc annotations and type assertions for l10n/status mappings. |
| src/w3c/templates/headers.js | Add JSDoc annotations; type assertions for l10n and DOM details element. |
| src/w3c/templates/cgbg-sotd.js | Add JSDoc params for template entrypoint. |
| src/w3c/templates/cgbg-headers.js | Add JSDoc params; add optional chaining for missing title element. |
| src/w3c/style.js | Add null-safety/type annotations around export-time stylesheet handling. |
| src/w3c/seo.js | Add JSDoc/types; safer indexing into status maps; meta access typing. |
| src/w3c/linter-rules/required-sections.js | Add JSDoc to localized message/hint helpers; type cast l10n. |
| src/w3c/headers.js | Add JSDoc/types; safer map indexing and iterator destructuring typing. |
| src/w3c/group.js | Add explicit Record casts when merging multi-group results. |
| src/w3c/defaults.js | Add JSDoc to config processing helpers; typed status map lookup. |
| src/w3c/conformance.js | Add JSDoc/types for keyword interpretation; conformance section rendering tweaks. |
| src/ui/search-xref.js | Add event parameter typing for iframe onload handler. |
| src/ui/search-specref.js | Add event parameter typing for iframe onload handler. |
| src/ui/save-html.js | Add JSDoc params/types for download link creation and UI state. |
| src/ui/about-respec.js | Add JSDoc typing for perf entries list and formatter. |
| src/type-helper.d.ts | Remove redundant DOM/Intl typings; update module/enum declarations and UI types. |
| src/jsconfig.json | Switch moduleResolution to bundler; add checkJs setting. |
| src/geonovum/style.js | Add JSDoc annotations for helper functions and run(conf). |
| src/geonovum/l10n.js | Add type cast when assigning localized additions by key. |
| src/geonovum/defaults.js | Add JSDoc annotations for config defaults/run. |
| src/dini/templates/headers.js | Cast l10n to any; add JSDoc and explicit arrow param typing. |
| src/dini/style.js | Add JSDoc annotations; add parameter typing to styleMover callback. |
| src/dini/headers.js | Add JSDoc/types; safer error typing and status map indexing. |
| src/dini/defaults.js | Add JSDoc annotations for defaults computation/run. |
| src/dini/conformance.js | Add JSDoc to keyword interpretation helpers; type-safety tweaks. |
| src/core/xref.js | Add JSDoc/types; null-safe dataset access; safer network result handling. |
| src/core/xref-db.js | Null-safe localStorage parse and default empty results from Map. |
| src/core/webidl-clipboard.js | Guard against missing <pre>; optional chaining for header removal. |
| src/core/web-monetization.js | Add JSDoc/types for run() and config normalization docs. |
| src/core/utils.js | Tighten JSDoc generics; null-safe text/dataset access; iterator filter typing. |
| src/core/ui.js | Add JSDoc/types; tighten DOM/event typing and safer overlay removal sequencing. |
| src/core/templates/show-people.js | Add JSDoc; null-safe retiredDate and extras validation defaulting. |
| src/core/tables.js | Guard against missing caption after querySelector (defensive). |
| src/core/structure.js | Prefer undefined over null for addId; pass explicit detail to pub(); null-safe dataset parsing. |
| src/core/seo.js | Add JSDoc annotation for run(conf). |
| src/core/respec-global.js | Add JSDoc typing for errors/warnings arrays and pubsub handlers. |
| src/core/requirements.js | Null-safe href parsing and requirement text lookup. |
| src/core/render-biblio.js | Cast l10n; add type assertions around alias/circular handling and dataset typing. |
| src/core/pubsubhub.js | Update JSDoc; add error typing casts; cast listener for addEventListener typing. |
| src/core/pre-process.js | Add JSDoc; cast filter callbacks and error cause typing. |
| src/core/post-process.js | Add JSDoc; cast filter callbacks and error cause typing. |
| src/core/pluralize.js | Add JSDoc; expand inline JSDoc param typing for returned function. |
| src/core/override-configuration.js | Add JSDoc annotation for run(config). |
| src/core/mdn-annotation.js | Type cast browser lookup; add JSDoc; correct return type for getMdnKey. |
| src/core/markdown.js | Add Renderer method token typing; guard missing respec-ui during markdown processing. |
| src/core/list-sorter.js | Add sorter param typing; ensure textContent null-safety; JSDoc updates. |
| src/core/linter-rules/wpt-tests-exist.js | Add JSDoc; null-safe dataset/tests parsing and regexp match access. |
| src/core/linter-rules/privsec-section.js | Add JSDoc to helper and rule entrypoint. |
| src/core/linter-rules/no-unused-vars.js | Add JSDoc; optional chaining on map get() results for typing. |
| src/core/linter-rules/no-unused-dfns.js | Add JSDoc for localization msg; add JSDoc for rule functions. |
| src/core/linter-rules/no-http-props.js | Add JSDoc to rule entrypoint. |
| src/core/linter-rules/no-headingless-sections.js | Add JSDoc to rule entrypoint. |
| src/core/linter-rules/no-captionless-tables.js | Add JSDoc to rule entrypoint. |
| src/core/linter-rules/local-refs-exist.js | Add JSDoc; null-safe href substring parsing. |
| src/core/linter-rules/informative-dfn.js | Add JSDoc for msg helpers; cast l10n to any; add run(conf) typing. |
| src/core/linter-rules/check-punctuation.js | Add JSDoc to rule entrypoint. |
| src/core/linter-rules/check-internal-slots.js | Add JSDoc; null-safe previousSibling access. |
| src/core/linter-rules/check-charset.js | Add JSDoc; null-safe charset attribute access. |
| src/core/linter-rules/a11y.js | Add JSDoc; null-safe grouping pushes; make axe run result default to []. |
| src/core/link-to-dfn.js | Add JSDoc; null-safe map lookups and dataset operations. |
| src/core/l10n.js | Add l10n record typing and run(config) JSDoc. |
| src/core/issues-notes.js | Cast l10n; refine Report typing; add JSDoc; null-safe dataset parsing. |
| src/core/inlines.js | Cast usage record; null-safe parentElement access; add JSDoc to helpers/run. |
| src/core/inline-idl-parser.js | Null-safe regex match values; default args to empty; add JSDoc for mappers. |
| src/core/informative.js | Add a type-guard filter to satisfy narrowing. |
| src/core/include-config.js | Add JSDoc; type userConfig as record; type amendConfig param. |
| src/core/id-headers.js | Add JSDoc; null-safe parentElement id access. |
| src/core/highlight.js | Add JSDoc; cast element for aria-busy; use innerText on HTMLElement. |
| src/core/highlight-vars.runtime.js | Add JSDoc; type casts in foreach callbacks for TS checking. |
| src/core/highlight-vars.js | Add JSDoc annotation for run(conf). |
| src/core/github.js | Add promise resolver/rejecter typings; cast l10n; add JSDoc for run(). |
| src/core/fix-headers.js | Add a type-guard filter; null-safe parent traversal in getParents. |
| src/core/expose-modules.js | Add typed local alias for window.require; cast require/modules access. |
| src/core/exporter.js | Add JSDoc; type callback param in cleanup forEach removal. |
| src/core/dfn.js | Null-safe closest dataset access; add JSDoc; safer knownTypes lookups. |
| src/core/dfn-panel.runtime.js | Add JSDoc and null-safety tweaks around panel lifecycle and caret lookup. |
| src/core/dfn-panel.js | Guard missing script insertion point; null-safe reference title/id grouping. |
| src/core/dfn-map.js | Optional chaining for set add() to satisfy typing. |
| src/core/dfn-index.js | Refine Entry typedef; null-safe dataset/text; add JSDoc; safer type lookups. |
| src/core/dfn-finder.js | Add intermediate array typings; cast alternative names to expected record type. |
| src/core/data-type.js | Add JSDoc annotation for run(conf). |
| src/core/data-tests.js | Add JSDoc; null-safe dataset parsing; filter undefined URLs with type guard. |
| src/core/data-include.js | Guard missing include target element; add error typing casts. |
| src/core/data-cite.js | Null-safe rawKey usage; null-safe closest lookup; default href to empty string. |
| src/core/data-abbr.js | Add JSDoc; null-safe textContent match/join; default to empty string. |
| src/core/custom-elements/rs-changelog.js | Precompute filter function safely; null-safe from query param and error typing. |
| src/core/contrib.js | Add JSDoc; type cast editors mapping; type error cause. |
| src/core/caniuse.js | Add JSDoc; null-safe headDl insertion; safer browser map access and callback typings. |
| src/core/biblio.js | Add resolver typing; null-safe Expires header parsing; skip null idb ref data. |
| src/core/biblio-db.js | Null-safe id usage; resolveAlias nullable return; safer expiry checks. |
| src/core/best-practices.js | Default append fragment when summaryItems is nullish. |
| src/core/base-runner.js | Add JSDoc; type callbacks for filters/forEach; pass explicit detail to pub(). |
| src/core/anchor-expander.js | Null-safe href parsing; add JSDoc; add safer node/text operations. |
| src/aom/templates/headers.js | Add JSDoc; convert default export to typed arrow; add copyright helper typing. |
| src/aom/style.js | Add JSDoc annotations; add parameter typing to styleMover callback. |
| src/aom/headers.js | Add JSDoc; typed status map indexing. |
| src/aom/defaults.js | Add JSDoc; cast defaults lint merge for typing. |
| src/aom/conformance.js | Add JSDoc to keyword interpretation; add run(conf) JSDoc. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Switch moduleResolution from deprecated "node10" to "bundler" (correct for Rollup-based projects, forward-compatible with TypeScript 7) - Fix type-helper.d.ts conflicts with TypeScript 6 DOM updates: remove redundant NodeIterator/TreeWalker generics (now in lib.dom.d.ts), remove Intl.ListFormat declaration (now in lib.es2021.intl.d.ts), add declare to module/enum declarations - Add JSDoc @param/@type annotations across ~95 src/ files to resolve the 689 implicit-any and type-safety errors TypeScript 6 now enforces for jsconfig.json projects; annotations use block @param style consistent with the existing codebase - All 1004 tests pass
- w3c/conformance.js: remove JSDoc block accidentally placed inside html template literal (would have rendered as literal text in output) - w3c/style.js: guard styleMover() to only append when w3cStyle is a real Node, not null (was appending empty string to <head>) - core/dfn-panel.runtime.js: add null guards for dfn.id and panel before calling displayPanel() to prevent potential null-deref throw - core/list-sorter.js: move @param before @returns in both JSDoc blocks
- conformance-spec: assert JSDoc annotations don't appear as literal text in the rendered conformance section output - style-spec: assert no empty text nodes are appended to <head> during export (guards against styleMover appending "" when link is absent)
f611993 to
6de9e7d
Compare
…t to 6 - Add simple-git-hooks + lint-staged so contributors get prettier/eslint auto-fix on every commit, preventing CI lint failures - Bump typescript devDependency from ^5.9.3 to ^6.0.2 (the actual version upgrade this PR is built on) - Fix XSS in core/data-abbr.js: replace insertAdjacentHTML with DOM construction so textContent values are never interpreted as HTML (flagged by CodeQL on this PR)
- Set target to "es2025" in jsconfig.json for ES2025 language features - Add stableTypeOrdering: true for deterministic TS error ordering - Use RegExp.escape() in inlines.js for abbr keys (prevents special characters in abbreviations from breaking the regex) - Use RegExp.escape() in link-to-dfn.js for shortName (prevents dots and other regex metacharacters in shortnames from matching broadly)
- xref.js: replace manual hex encoding loop with Uint8Array.toHex() - highlight-vars.runtime.js: use Map.keys().find() directly (no intermediate array) - utils.js: use Map.keys().find() directly in CaseInsensitiveMap.getCanonicalKey() - jsconfig.json: add esnext.typedarrays lib so toHex() types are available
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 101 out of 103 changed files in this pull request and generated 8 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Expand the Conf interface in type-helper.d.ts with all 57 missing
properties (boolean status flags, dates, strings, arrays, complex
types) so every module that receives conf can use {Conf} instead of
{any}. Also fix two genuine bugs caught by the stricter typing:
- conf.isPr → conf.isPR (w3c/headers.js)
- conf.noTOC → conf.noToc (core/structure.js)
Replace all remaining @param {any} conf/config/exportDoc annotations
with concrete types across ~90 src/ files. Zero {any} params remain.
- dini/style.js, aom/style.js: apply same null-guard as w3c/style.js in styleMover() — was appending null to <head> when link not found - highlight-vars.runtime.js: guard closest() returning null; return [] instead of undefined so callers can safely check .length - utils.js: add regExpEscape() polyfill (RegExp.escape ?? manual impl) so abbr/shortName regex escaping works on browsers before Chrome 136 - inlines.js, link-to-dfn.js: use regExpEscape() instead of RegExp.escape() - xref.js: use Uint8Array.toHex?.() with fallback for older runtimes
- structure.js was changed to conf.noToc but the config key is noTOC; revert to conf.noTOC to match user-facing docs and test expectations - type-helper.d.ts: expose both noToc (style modules) and noTOC (structure module) since they are genuinely separate config keys - headers-spec.js: add prEnd to the w3cid-missing test config; the isPr → isPR fix correctly enabled the prEnd validation check for PR status, which was previously silently broken (undefined is falsy)
…ectives, address remaining review feedback
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 103 out of 105 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- rs-changelog: remove redundant Commit type cast in map callback - base-runner: remove redundant ReSpecPlugin annotation in filter - dfn-index: use optional property syntax in typedef - dfn-index: simplify dfnFor with optional chaining - dfn-panel.runtime: narrow Event param to KeyboardEvent|MouseEvent - fix-headers: use .filter(Boolean) instead of verbose type guard
- anchor-expander: use HTMLAnchorElement for anchor queries - dfn-finder: remove unnecessary Record cast on getAlternativeNames - github: create typed ghConf to eliminate 3 @ts-expect-error directives - highlight-vars.runtime: cast varElem once, type parent as HTMLElement, remove redundant @param on filter callback
…vars, dfn-finder, caniuse
Summary
Closes #5155