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

refactor: make the code parameter of safeReject non-nullable #2875

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

mlazari
Copy link
Contributor

@mlazari mlazari commented Nov 1, 2024

The reject method of Promise class became non-nullable in React Native 0.76 after rewriting it from Java to Kotlin. We fixed it being called with a nullable value in #2872 by providing and empty string as a fallback if it happens to be null. But after more investigation it seems like it's not called with a value that could be null anywhere in the code, so a better solution would be to just update the type of the code parameter to be non-nullable.

The reject method of Promise class became non-nullable in React Native 0.76 after rewriting it from Java to Kotlin. We fixed it being called with a nullable value in hyochan#2872 by providing and empty string as a fallback if it happens to be null. But after more investigation it seems like it's not called with a value that could be null anywhere in the code, so a better solution would be to just update the type of the `code` parameter to be non-nullable.
@hyochan hyochan added 🤖 android Related to android ❄️ types Typing issues labels Nov 4, 2024
Copy link
Owner

@hyochan hyochan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates!
It seems like the type mismatch issue was due to a Kotlin internal type system inference rather than an error with the React Native API itself. Changing the code parameter from String? to String effectively resolved the inferred type mismatch.

@hyochan hyochan merged commit 22ac087 into hyochan:main Nov 4, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants