-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
fix: TypeScript compatibility with exactOptionalPropertyTypes: true #14741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
fix: TypeScript compatibility with exactOptionalPropertyTypes: true #14741
Conversation
🦋 Changeset detectedLatest commit: 08d06ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
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 |
|
Welcome, and thank you for contributing to React Router! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run. Thanks! - The Remix team |
|
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
The test was using path.join() which creates platform-specific paths (backslashes on Windows), then mixing it with path.posix.join(). This caused path.posix.relative() to calculate incorrect relative paths on Windows, expecting "../routes/route.tsx" but getting "../../../routes/route.tsx". Changed to use path.posix.join() consistently for cross-platform compatibility.
|
I've fixed the Windows test failure in The remaining CI failures ( My changes only modified:
|
…ptionalPropertyTypes compatibility
Fixes #14734
Summary
This PR fixes TypeScript compatibility when exactOptionalPropertyTypes: true is enabled in tsconfig.json.
Problem
When exactOptionalPropertyTypes is enabled, TypeScript requires optional properties to explicitly allow undefined. The generated types from react-router typegen were causing type errors:
This occurred because:
Solution
Added StrictOptionals type helper in packages/react-router/lib/types/utils.ts
Runtime detection in packages/react-router-dev/typegen/generate.ts
Conditional type wrapping in generated code
Exported StrictOptionals via react-router/internal for generated code to use
Testing
Changes