From f74c0ea5a182d10087e865583f4652bd3a724391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Johansen=20Amundrud?= Date: Wed, 23 May 2018 01:47:39 +0200 Subject: [PATCH 1/4] Add optional and null --- .../facebook-instant-games/facebook-instant-games-tests.ts | 2 +- types/facebook-instant-games/index.d.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/facebook-instant-games/facebook-instant-games-tests.ts b/types/facebook-instant-games/facebook-instant-games-tests.ts index 949782c41a..6223c3d5e3 100644 --- a/types/facebook-instant-games/facebook-instant-games-tests.ts +++ b/types/facebook-instant-games/facebook-instant-games-tests.ts @@ -1,5 +1,5 @@ const locale: string = FBInstant.getLocale()!; -const platform: string = FBInstant.getPlatform(); +const platform: string = FBInstant.getPlatform()!; const sdkVersion: string = FBInstant.getSDKVersion(); FBInstant.initializeAsync().then(() => {}); FBInstant.setLoadingProgress(10); diff --git a/types/facebook-instant-games/index.d.ts b/types/facebook-instant-games/index.d.ts index 74c93c6c96..2e6da873cd 100644 --- a/types/facebook-instant-games/index.d.ts +++ b/types/facebook-instant-games/index.d.ts @@ -33,7 +33,7 @@ declare namespace FBInstant { /** * The platform on which the game is currently running. The value will always be null until FBInstant.initializeAsync() resolves. */ - function getPlatform(): Platform; + function getPlatform(): Platform | null; /** * The string representation of this SDK version. @@ -458,7 +458,7 @@ declare namespace FBInstant { * @throws PENDING_REQUEST * @throws CLIENT_UNSUPPORTED_OPERATION */ - chooseAsync(options: ContextOptions): Promise; + chooseAsync(options?: ContextOptions): Promise; /** * Attempts to create or switch into a context between a specified player and the current player. The returned promise will reject if the player listed is not a Connected Player of the current @@ -521,7 +521,7 @@ declare namespace FBInstant { * @throws INVALID_OPERATION * @throws RATE_LIMITED */ - setScoreAsync(score: number, extraData: string): Promise; + setScoreAsync(score: number, extraData?: string): Promise; /** * Retrieves the leaderboard's entry for the current player, or null if the player has not set one yet. From 69e739a7ab02312393774f44a63e659507da22dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Johansen=20Amundrud?= Date: Wed, 23 May 2018 01:58:50 +0200 Subject: [PATCH 2/4] Add missing function for testing leaderboard --- .../facebook-instant-games/facebook-instant-games-tests.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/facebook-instant-games/facebook-instant-games-tests.ts b/types/facebook-instant-games/facebook-instant-games-tests.ts index 6223c3d5e3..cf93053288 100644 --- a/types/facebook-instant-games/facebook-instant-games-tests.ts +++ b/types/facebook-instant-games/facebook-instant-games-tests.ts @@ -70,6 +70,12 @@ FBInstant.getLeaderboardAsync("name").then((leaderboard: FBInstant.Leaderboard) const score: number = leaderboardEntry.getScore(); const timestamp: number = leaderboardEntry.getTimestamp(); }); + const contextID: string = leaderboard.getContextID()!; + leaderboard.getEntriesAsync(10, 10).then(entries => {}); + leaderboard.getEntryCountAsync().then((entryCount: number) => {}); + const name = leaderboard.getName(); + leaderboard.getPlayerEntryAsync().then(playerEntry => {}); + leaderboard.setScoreAsync(10).then(leaderboardEntry => {}); }); FBInstant.player.canSubscribeBotAsync().then((canSubscribeBot: boolean) => {}); From b78b4d15d4c0de3ac5c5cd51d3d2e866c8c91544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Johansen=20Amundrud?= Date: Wed, 23 May 2018 02:03:25 +0200 Subject: [PATCH 3/4] Plural spelling --- types/facebook-instant-games/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/facebook-instant-games/index.d.ts b/types/facebook-instant-games/index.d.ts index 2e6da873cd..c0722b11ec 100644 --- a/types/facebook-instant-games/index.d.ts +++ b/types/facebook-instant-games/index.d.ts @@ -174,11 +174,11 @@ declare namespace FBInstant { * * @param eventName Name of the event. Must be 2 to 40 characters, and can only contain '_', '-', ' ', and alphanumeric characters. * @param valueToSum An optional numeric value that FB Analytics can calculate a sum with. - * @param parameter An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, + * @param parameters An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, * and can only contain '_', '-', ' ', and alphanumeric characters. Values must be less than 100 characters in length. * @returns The error if the event failed to log; otherwise returns null. */ - function logEvent(eventName: string, valueToSum?: number, parameter?: { [key: string]: string; }): APIError | null; + function logEvent(eventName: string, valueToSum?: number, parameters?: { [key: string]: string; }): APIError | null; /** * Set a callback to be fired when a pause event is triggered. From f46cd6448bb8ba489848cbd6a3df0eccfcf17592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Johansen=20Amundrud?= Date: Wed, 23 May 2018 02:20:51 +0200 Subject: [PATCH 4/4] Add type --- types/facebook-instant-games/facebook-instant-games-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/facebook-instant-games/facebook-instant-games-tests.ts b/types/facebook-instant-games/facebook-instant-games-tests.ts index cf93053288..f8fc559360 100644 --- a/types/facebook-instant-games/facebook-instant-games-tests.ts +++ b/types/facebook-instant-games/facebook-instant-games-tests.ts @@ -73,7 +73,7 @@ FBInstant.getLeaderboardAsync("name").then((leaderboard: FBInstant.Leaderboard) const contextID: string = leaderboard.getContextID()!; leaderboard.getEntriesAsync(10, 10).then(entries => {}); leaderboard.getEntryCountAsync().then((entryCount: number) => {}); - const name = leaderboard.getName(); + const name: string = leaderboard.getName(); leaderboard.getPlayerEntryAsync().then(playerEntry => {}); leaderboard.setScoreAsync(10).then(leaderboardEntry => {}); });