Skip to content

fix(deps): widen @mittwald/react-use-promise peer range to 3.x and 4.x - #294

Open
mfal wants to merge 2 commits into
masterfrom
claude/react-use-promise-compat-9ece12
Open

fix(deps): widen @mittwald/react-use-promise peer range to 3.x and 4.x#294
mfal wants to merge 2 commits into
masterfrom
claude/react-use-promise-compat-9ece12

Conversation

@mfal

@mfal mfal commented Aug 31, 2026

Copy link
Copy Markdown
Member

Fixes the disjoint peer range reported in #293.

@mittwald/api-models, @mittwald/api-client-commons and @mittwald/api-client declared "@mittwald/react-use-promise": "^2.6.0", which has no intersection with the ^4.2.2 that @mittwald/flow-react-components requires. Since the peer is optional: true this was a warning rather than a failure, but every consumer of both libraries saw it.

Changes

before after
peerDependencies (all 3 packages) ^2.6.0 ^2.6.0 || ^3.0.0 || ^4.0.0
devDependencies (all 3 packages) ^2.6.2 ^4.2.3

The range was never widened, not deliberately held

Every symbol this repo uses is unchanged or only widened between 2.6 and 4.2.3:

  • getAsyncResource(fn, params, { tags, loaderId }) — identical signature (the parameter type was renamed AsyncFnLoaderFn in 4.0, but structurally widened: it now also accepts sync loaders)
  • refresh({ tag })Tag widened from string to string | [string, string]; a plain string still fits
  • Store<T> from /store with get / set / getAll; StorageEntryOptions.tags still accepts string[]
  • usePromise(..., { useSuspense: false }).hasValue — unchanged
  • AsyncResource<T>, asyncResourceStore — present throughout

The React-19 peer that made 3.0.0 and 4.0.0 look like hard breaks was walked back in a patch each time:

version peerDependencies.react
2.6.2 >=17.0
3.0.0 >=19.0
3.0.4 >=18.3
4.0.0 >=19.0
4.0.2 – 4.2.3 >=18.3

So the widened range forces React 19 on nobody.

The devDependency tracks latest again (was briefly held at ~4.0.2)

This PR originally pinned the devDependency to ~4.0.2, because 4.1.0 through 4.2.2 reddened this repo's build. 4.2.3 fixes that, so the devDependency now moves to ^4.2.3 and CI exercises the same latest 4.x that consumers resolve.

The defect, for the record: from 4.1.0 on, the shipped .d.ts files used extensionless relative imports while the package is "type": "module":

4.0.2:         export * from "./resource/refresh.js";
4.1.0 – 4.2.2: export * from "./resource/refresh";
4.2.3:         export * from "./resource/refresh.js";   ← fixed

Under this repo's moduleResolution: NodeNext those paths did not resolve and the whole export surface collapsed:

src/react/ApiCallAsyncResourceFactory.ts(1,10): error TS2305: Module
'"@mittwald/react-use-promise"' has no exported member 'getAsyncResource'.

It was always types-only — dist/esm/index.js kept its .js extensions throughout — which is why the peer range admitted ^4.0.0 in full even while the devDependency was held back. Verified against the 4.2.3 tarball: no extensionless relative import remains anywhere in dist/types/**/*.d.ts.

Measured per version — pin as devDependency in all three packages, yarn install, then nx run-many -t build (tsc per package) and the Jest suites:

version build tests
2.6.2 (previous)
3.0.4
4.0.2
4.1.0 ❌ TS2305
4.2.2 ❌ TS2305
4.2.3 (this PR)

Known side effect

client-react.ts does export * from "@mittwald/react-use-promise", so the type exports removed in 3.x/4.x — AsyncFn, AsyncLoader, TagPattern, and the deprecated AsyncResource.watch() — also disappear from what @mittwald/api-client re-exports for consumers who resolve a 3.x/4.x peer. Nothing in this repo uses them.

Verification

build, lint and test all green against 4.2.3, each with --skip-nx-cache:

  • nx run-many -t build — 4/4 projects, no TS2305
  • nx run-many -t lint — 4/4 projects
  • nx run-many -t test — 45 tests across the three packages (23 code-generator, 17 commons, 5 models), including ApiCallAsyncResourceFactory.test.ts and provideReact.test.tsx, which are the ones exercising the hooks

yarn explain peer-requirements reports no unmet peer for @mittwald/react-use-promise — the yarn install warning is gone. The one remaining unmet peer, @typescript-eslint/utilstypescript, pre-dates this branch and is untouched by it.

🤖 Generated with Claude Code

The published peer range `^2.6.0` could not be satisfied alongside the
current `@mittwald/react-use-promise` release (4.2.2), so any project
combining these packages with `@mittwald/flow-react-components` (which
requires `^4.2.2`) saw a non-overlapping-range warning on install.

The range was never widened rather than deliberately held: every symbol
used here is unchanged or only widened between 2.6 and 4.2.2, and the
React-19-only peer that 3.0.0 and 4.0.0 declared was walked back to
`react >=18.3` in 3.0.4 and 4.0.2.

The devDependency moves to `~4.0.2` rather than `^4.0.2`: from 4.1.0 on,
the shipped `.d.ts` files use extensionless relative imports while the
package is `"type": "module"`, which does not resolve under this repo's
`moduleResolution: NodeNext` and collapses the export surface. That is a
types-only packaging regression upstream; once it is fixed the
devDependency can move to `^4.2.x` with no change to the peer range.

Refs #293

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
4.2.3 restores the `.js` extensions in the shipped `.d.ts` files, so the
TS2305 collapse of the export surface under `moduleResolution: NodeNext`
that pinned this repo to `~4.0.2` is gone. CI now exercises the same
latest 4.x that consumers resolve. The peer range is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant