From 585763750eab62200158e41a08d827028ce212ff Mon Sep 17 00:00:00 2001 From: Doug Keen Date: Fri, 24 Dec 2021 07:19:30 -0800 Subject: [PATCH] Fix Typescript typings in react-native-flipper (#3209) Summary: The implementation of react-native-flipper [makes runtime assertions](https://github.com/facebook/flipper/blob/main/react-native/react-native-flipper/index.js#L20) about some variables but those type requirements [aren't properly reflected in the Typescript type defs](https://github.com/facebook/flipper/blob/main/react-native/react-native-flipper/index.d.ts#L45). ## Changelog Corrected Typescript type defs in react-native-flipper Pull Request resolved: https://github.com/facebook/flipper/pull/3209 Test Plan: (No runtime effect) In vscode, the typings now properly restrict the arguments to `FlipperResponder.success`, `FlipperResponder.error`, and `FlipperConnection.send` Reviewed By: antonk52 Differential Revision: D33307792 Pulled By: mweststrate fbshipit-source-id: da3bf7fcacdf3718dc9a625e4229f3c8ecd7ac93 --- react-native/react-native-flipper/index.d.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/react-native/react-native-flipper/index.d.ts b/react-native/react-native-flipper/index.d.ts index 0435b8553..bbf42de60 100644 --- a/react-native/react-native-flipper/index.d.ts +++ b/react-native/react-native-flipper/index.d.ts @@ -41,13 +41,15 @@ declare namespace Flipper { runInBackground?(): boolean; } + type Serializable = undefined | Array | object + export interface FlipperResponder { - success(response?: any): void; - error(response: any): void; + success(response?: Serializable): void; + error(response: Serializable): void; } export interface FlipperConnection { - send(method: string, data: any): void; + send(method: string, data: Serializable): void; reportErrorWithMetadata(reason: string, stackTrace: string): void; reportError(error: Error): void; receive(