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

fix: change isSuccessResponse to a type predicate #1333

Conversation

antklim
Copy link
Contributor

@antklim antklim commented Sep 19, 2024

Description

This PR updates isSuccessResponse method to a type predicate.

This change makes code consistent with isCancelledResponse.

This enables better user experience with type system.

Before

import { GoogleSignin, isSuccessResponse } from '@react-native-google-signin/google-signin'

const response = await GoogleSignin.signIn()

if (isSuccessResponse(response)) {
  // response type is SignInResponse, response.data type is User | null
}

After

import { GoogleSignin, isSuccessResponse } from '@react-native-google-signin/google-signin'

const response = await GoogleSignin.signIn()

if (isSuccessResponse(response)) {
  // response type is SignInSuccessResponse, response.data type is User
}

@vonovak vonovak changed the title feat: change isSuccessResponse to a type predicate fix: change isSuccessResponse to a type predicate Sep 19, 2024
@vonovak vonovak merged commit c01c1c3 into react-native-google-signin:master Sep 19, 2024
2 checks passed
@vonovak
Copy link
Member

vonovak commented Sep 19, 2024

Thank you! This is how it was intended to be 👍

github-actions bot pushed a commit that referenced this pull request Sep 19, 2024
## [13.0.2](v13.0.1...v13.0.2) (2024-09-19)

### Bug Fixes

* change isSuccessResponse to a type predicate ([#1333](#1333)) ([c01c1c3](c01c1c3))

Please note there's a [paid version of the package](https://react-native-google-signin.github.io/docs/install) with some extra features available.
Copy link

🎉 This PR is included in version 13.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@antklim antklim deleted the success-response-type-predicate branch September 19, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants