mobx icon indicating copy to clipboard operation
mobx copied to clipboard

Resolve TypeScript errors in React 19 (by removing the deprecated propTypes.ts)

Open Venryx opened this issue 10 months ago • 3 comments

Removed the deprecated propTypes.ts, and some remaining references to its exports, in order to make mobx-react compatible with React 19 (without TypeScript compile errors), since React 19 removes its prop-types exports of React.Requireable and React.Validator. (@mweststrate gave a go-ahead for this here)

Changelog:

  • Removed propTypes.ts, as React 19 no longer provides the types React.Requireable and React.Validator.
  • Updated docs to not mention the mobx-react specific prop-types anymore.
  • Removed the propTypes.test.ts file. (not applicable anymore, since the mobx-react specific prop-types no longer exist)
  • Removed the "component with observable propTypes" test, since it's no longer applicable. (and it was referencing typescript types that are no longer importable, so using test.skip is not sufficient)

Code change checklist

  • [X] Added/updated unit tests
  • [X] Updated /docs. For new functionality, at least API.md should be updated
  • [X] Verified that there is no significant performance drop (yarn mobx test:performance)

Venryx avatar Mar 09 '25 20:03 Venryx

🦋 Changeset detected

Latest commit: f5c0fe72b0617903032ee71fc7bfb5498de1a364

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mobx-react Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Mar 09 '25 20:03 changeset-bot[bot]

I added a basic changelog entry for the PR: (to satisfy changeset-bot)

Removed the deprecated PropTypes export, as React 19 no longer provides the types React.Requireable and React.Validator, and this was causing TypeScript errors with @types/[email protected].

I marked it as a major change (assuming even deprecated APIs are considered part of the semver-tracked api-surface), but I can change it to minor if needed.

Venryx avatar Mar 09 '25 23:03 Venryx

I've added the second change requested (compatibility table update in readme). [although, I'm not 100% sure it matches what you wanted/expected]

I'm also trying to add the first change requested (adding of react 19 as a peer dependency). But git appears to have a hook that warns me to run "yarn install" prior to pushing. When I do so, it seems to result in a massive set of changes to the lock file, which would not be feasible for maintainers to visually review. So I imagine this step would have to be performed by an existing trusted maintainer (to ensure the lock file is authentic).

Note: It's possible I'm running a different version of yarn? Running "yarn install" resulted in an unexpectedly large set of file changes. (to .yarnrc.yml, yarn.lock, install-state.gz, mobx/package.json, mobx-react/package.json, and mobx-react-lite/package.json)

Venryx avatar Aug 05 '25 10:08 Venryx