Make client.device fulfill type constraints

Summary:
This is an interesting invariant that TS caught here. We
expect `getDevice()` to always return a device but it
cannot because it's set lazily. John Knox suggested we instead
set up a promise in the constructor and resolve it instead of
overriding the stateful promise later.

Reviewed By: jknoxville

Differential Revision: D17313468

fbshipit-source-id: 8fd75f2720546abf67beead23db56216f1a5e0df
This commit is contained in:
Pascal Hartig
2019-09-11 05:36:42 -07:00
committed by Facebook Github Bot
parent a35fd7389f
commit f48fe21eaa
2 changed files with 15 additions and 6 deletions

View File

@@ -120,7 +120,7 @@ export abstract class FlipperBasePlugin<
reducers: {
[actionName: string]: (state: State, actionData: any) => Partial<State>;
} = {};
app: App;
app: App | null = null;
onKeyboardAction: ((action: string) => void) | undefined;
toJSON() {