hydrogen icon indicating copy to clipboard operation
hydrogen copied to clipboard

Add DOM.Iterable to hydrogen-react tsconfig lib

Open LeSingh1 opened this issue 6 months ago • 0 comments

WHY are these changes introduced?

The packages/hydrogen-react/tsconfig.json lib setting was ["DOM", "ESNext"], which is missing DOM.Iterable. Without it, the type definitions for URLSearchParams, FormData, Headers, NodeList, and similar DOM iterables do not expose their [Symbol.iterator] method, so iterating them (or spreading them into Object.fromEntries) does not type-check.

This forced a workaround in useSelectedOptionInUrlParam.tsx: two @ts-ignore directives plus matching eslint-disable comments, alongside an outdated TODO: update ts lib. The root tsconfig.json at the monorepo root already sets lib: ["DOM", "DOM.Iterable", "ESNext"], so this brings the package into line with the rest of the workspace.

WHAT is this pull request doing?

  • Adds DOM.Iterable to the lib array in packages/hydrogen-react/tsconfig.json.
  • Removes the @ts-ignore / eslint-disable workaround and the stale TODO comment in useSelectedOptionInUrlParam.tsx. The runtime behaviour is unchanged.
  • Adds a patch changeset.

HOW to test your changes?

From the repo root after pnpm install:

cd packages/hydrogen-react
pnpm run typecheck:code

tsc --noEmit passes with the workaround removed.

Checklist

  • [x] I've read the Contributing Guidelines
  • [x] I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • [x] I've added a changeset if this PR contains user-facing or functional changes. Test changes or internal-only config changes do not require a changeset.
  • [ ] I've added tests to cover my changes
  • [ ] I've added or updated the documentation

LeSingh1 avatar May 19 '26 17:05 LeSingh1