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

Update isExpoPushToken type signature #36

Merged
merged 2 commits into from
Jun 29, 2020
Merged

Update isExpoPushToken type signature #36

merged 2 commits into from
Jun 29, 2020

Conversation

smichel17
Copy link
Contributor

@smichel17 smichel17 commented May 19, 2020

I think this is a better fit for what the function actually does: we don't know the type of the thing coming in, but we do know the type if it returns true.

https://www.typescriptlang.org/docs/handbook/advanced-types.html#using-type-predicates

note: I did this in GitHub's web interface so I didn't test if it compiles, although it should (famous last words)

I think this is a better fit for what the function actually does: we don't know the type of the thing coming in, but we do know the type if it returns true.

https://www.typescriptlang.org/docs/handbook/advanced-types.html#using-type-predicates
@@ -51,7 +51,7 @@ export class Expo {
/**
* Returns `true` if the token is an Expo push token
*/
static isExpoPushToken(token: ExpoPushToken): boolean {
static isExpoPushToken(token: any): token is ExpoPushToken {
Copy link
Member

Choose a reason for hiding this comment

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

Does this type check with unknown?

@ide
Copy link
Member

ide commented Jun 16, 2020

Awaiting feedback. Will close in a month if this goes stale.

This forces us to check that the token is a string.
@ide ide merged commit ea03159 into expo:master Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants