From ad73adce33e1ef5c4e3036e8ac95650558afbceb Mon Sep 17 00:00:00 2001 From: smichel17 Date: Tue, 19 May 2020 19:49:03 +0000 Subject: [PATCH 1/2] Update isExpoPushToken type signature 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 --- src/ExpoClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ExpoClient.ts b/src/ExpoClient.ts index 255e29b..32e9842 100644 --- a/src/ExpoClient.ts +++ b/src/ExpoClient.ts @@ -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 { return ( typeof token === 'string' && (((token.startsWith('ExponentPushToken[') || token.startsWith('ExpoPushToken[')) && From 38906a6983d960b9bb35a614ea11aee9a3e787a8 Mon Sep 17 00:00:00 2001 From: James Ide Date: Mon, 29 Jun 2020 01:11:46 -0700 Subject: [PATCH 2/2] Use unknown instead of any in isExpoPushToken This forces us to check that the token is a string. --- src/ExpoClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ExpoClient.ts b/src/ExpoClient.ts index 32e9842..380954e 100644 --- a/src/ExpoClient.ts +++ b/src/ExpoClient.ts @@ -51,7 +51,7 @@ export class Expo { /** * Returns `true` if the token is an Expo push token */ - static isExpoPushToken(token: any): token is ExpoPushToken { + static isExpoPushToken(token: unknown): token is ExpoPushToken { return ( typeof token === 'string' && (((token.startsWith('ExponentPushToken[') || token.startsWith('ExpoPushToken[')) &&