-
-
Notifications
You must be signed in to change notification settings - Fork 529
fix type checking when strictNullChecks
is disabled
#1833
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
Conversation
🦋 Changeset detectedLatest commit: ea2c26b The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
--- | ||
"openapi-typescript-helpers": patch | ||
"openapi-react-query": patch | ||
"openapi-fetch": patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I view this as a bug fix that implements the expected behavior. However, it does have the potential to break type checking in projects with incorrect code, so I can change this to minor
if we want to be safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great fix, and great tests, thank you!
Shoot looks like another PR merged before this caused some conflicts. Once the conflicts are resolved, happy to merge & release. |
…disabled # Conflicts: # packages/openapi-fetch/src/index.d.ts
8e46c42
to
ea2c26b
Compare
Changes
This PR refactors some types to remove usage of
undefined extends T
conditional types. It also adds a new test suite that is type checked withstrictNullChecks
disabled to allow for increased support of that configuration.Resolves #1778
How to Review
See context in this comment on the issue. Using
undefined extends T
only behaves as expected whenstrictNullChecks
is enabled. While this configuration is highly recommended for consuming projects, it is not the default, and we should design types that also work without it when possible.#1778 describes a case where
params
is required on calls to routes with no parameters defined or no required parameters in the spec. At least two other cases are caused by the same underlying issue:params
is not required, regardless of whether any of the parameters are required in the spec.body
property is not required on calls to routes with a required request body defined in the spec.This PR fixes the behavior of those cases.
Checklist
docs/
updated (if necessary)pnpm run update:examples
run (only applicable for openapi-typescript)