Skip to content
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

Add explicit | undefined to optional fields to improve compatibility with exactOptionalPropertyTypes: true #462

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

ammubhave
Copy link
Contributor

@ammubhave ammubhave commented Sep 24, 2024

Resolves #461


Before the change?

After the change?

  • Typechecking succeeds

Pull request checklist

  • [NA] Tests for the changes have been added (for bug fixes / features)
  • [NA] Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

When typescript is used with the option `exactOptionalProperty: true`, this code fails to typecheck if `undefined` is passed in for the response value.

This is because `exactOptionalProperty` makes tsc consider `?:..` different from `: ... | undefined` for more strictness.
Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@ammubhave ammubhave changed the title Add explicit | undefined to optional fields to improve compatibility with exactOptionalTypes: true Add explicit | undefined to optional fields to improve compatibility with exactOptionalPropertyTypes: true Sep 24, 2024
@wolfy1339 wolfy1339 added the Type: Bug Something isn't working as documented label Sep 24, 2024
@wolfy1339 wolfy1339 merged commit 43fc3bd into octokit:main Sep 24, 2024
9 checks passed
Copy link

🎉 This PR is included in version 6.1.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ammubhave ammubhave deleted the patch-1 branch September 24, 2024 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Type: Bug Something isn't working as documented
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[BUG]: Typechecking fails for external code with exactOptionalPropertyTypes: true
2 participants