remove generics from static methods
Summary: Generics on static methods don't seem to work the way we are using them. I looked into how react types getDerivedStateFromProps as this is a very similar concept, and they don't seem to type it at all. For that reason I've given up and just type the persistedState passed to our static methods as `Object`. Reviewed By: passy Differential Revision: D17152767 fbshipit-source-id: d9c2159be26fa341c5411dd0b40895d4c8ddf71e
This commit is contained in:
committed by
Facebook Github Bot
parent
b924b14225
commit
57fb3853ba
@@ -14,22 +14,24 @@ import {MetricType} from './utils/exportMetrics';
|
|||||||
import {ReactNode, Component} from 'react';
|
import {ReactNode, Component} from 'react';
|
||||||
import BaseDevice from './devices/BaseDevice';
|
import BaseDevice from './devices/BaseDevice';
|
||||||
|
|
||||||
|
type Parameters = any;
|
||||||
|
|
||||||
// This function is intended to be called from outside of the plugin.
|
// This function is intended to be called from outside of the plugin.
|
||||||
// If you want to `call` from the plugin use, this.client.call
|
// If you want to `call` from the plugin use, this.client.call
|
||||||
export function callClient(
|
export function callClient(
|
||||||
client: Client,
|
client: Client,
|
||||||
id: string,
|
id: string,
|
||||||
): (string, params: Object | null) => Promise<Object> {
|
): (method: string, params: Parameters) => Promise<any> {
|
||||||
return (method, params) => client.call(id, method, false, params);
|
return (method, params) => client.call(id, method, false, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PluginClient {
|
export interface PluginClient {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
send(method: string, params?: Object): void;
|
send(method: string, params?: Parameters): void;
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
call(method: string, params?: Object): Promise<any>;
|
call(method: string, params?: Parameters): Promise<any>;
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
subscribe(method: string, callback: (params: any) => void): void;
|
subscribe(method: string, callback: (params: Parameters) => void): void;
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
supportsMethod(method: string): Promise<boolean>;
|
supportsMethod(method: string): Promise<boolean>;
|
||||||
}
|
}
|
||||||
@@ -61,6 +63,8 @@ export type BaseAction = {
|
|||||||
type: string;
|
type: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type StaticPersistedState = any;
|
||||||
|
|
||||||
export abstract class FlipperBasePlugin<
|
export abstract class FlipperBasePlugin<
|
||||||
State,
|
State,
|
||||||
Actions extends BaseAction,
|
Actions extends BaseAction,
|
||||||
@@ -82,26 +86,32 @@ export abstract class FlipperBasePlugin<
|
|||||||
static screenshot: string | null;
|
static screenshot: string | null;
|
||||||
static defaultPersistedState: any;
|
static defaultPersistedState: any;
|
||||||
static persistedStateReducer:
|
static persistedStateReducer:
|
||||||
| (<U>(persistedState: U, method: string, data: Object) => Partial<U>)
|
| ((
|
||||||
|
persistedState: StaticPersistedState,
|
||||||
|
method: string,
|
||||||
|
data: any,
|
||||||
|
) => StaticPersistedState)
|
||||||
|
| null;
|
||||||
|
static metricsReducer:
|
||||||
|
| ((persistedState: StaticPersistedState) => Promise<MetricType>)
|
||||||
| null;
|
| null;
|
||||||
static metricsReducer: (<U>(persistedState: U) => Promise<MetricType>) | null;
|
|
||||||
static exportPersistedState:
|
static exportPersistedState:
|
||||||
| (<U>(
|
| ((
|
||||||
callClient: (string, params: Object | null) => Promise<Object>,
|
callClient: (method: string, params?: any) => Promise<any>,
|
||||||
persistedState: U | null,
|
persistedState: StaticPersistedState | undefined,
|
||||||
store: MiddlewareAPI | null,
|
store: MiddlewareAPI | undefined,
|
||||||
) => Promise<U>)
|
) => Promise<StaticPersistedState | undefined>)
|
||||||
| null;
|
| null;
|
||||||
static getActiveNotifications:
|
static getActiveNotifications:
|
||||||
| (<U>(persistedState: U) => Array<Notification>)
|
| ((persistedState: StaticPersistedState) => Array<Notification>)
|
||||||
| null;
|
| null;
|
||||||
static onRegisterDevice:
|
static onRegisterDevice:
|
||||||
| (<U>(
|
| ((
|
||||||
store: Store,
|
store: Store,
|
||||||
baseDevice: BaseDevice,
|
baseDevice: BaseDevice,
|
||||||
setPersistedState: (
|
setPersistedState: (
|
||||||
pluginKey: string,
|
pluginKey: string,
|
||||||
newPluginState: U | null,
|
newPluginState: StaticPersistedState | null,
|
||||||
) => void,
|
) => void,
|
||||||
) => void)
|
) => void)
|
||||||
| null;
|
| null;
|
||||||
@@ -114,7 +124,7 @@ export abstract class FlipperBasePlugin<
|
|||||||
screenshot: never;
|
screenshot: never;
|
||||||
|
|
||||||
reducers: {
|
reducers: {
|
||||||
[actionName: string]: (state: State, actionData: Object) => Partial<State>;
|
[actionName: string]: (state: State, actionData: any) => Partial<State>;
|
||||||
} = {};
|
} = {};
|
||||||
app: App;
|
app: App;
|
||||||
onKeyboardAction: ((action: string) => void) | null;
|
onKeyboardAction: ((action: string) => void) | null;
|
||||||
|
|||||||
Reference in New Issue
Block a user