Make plugin.tsx strict
Reviewed By: danielbuechele Differential Revision: D17228192 fbshipit-source-id: 74e5edf9dfd3260a3463e57a16d1f9c8c0399137
This commit is contained in:
committed by
Facebook Github Bot
parent
6e8b31e2ed
commit
6aab0bd826
@@ -116,19 +116,12 @@ export abstract class FlipperBasePlugin<
|
|||||||
) => void,
|
) => void,
|
||||||
) => void)
|
) => void)
|
||||||
| null;
|
| null;
|
||||||
// forbid instance properties that should be static
|
|
||||||
title: never;
|
|
||||||
id: never;
|
|
||||||
persist: never;
|
|
||||||
icon: never;
|
|
||||||
keyboardActions: never;
|
|
||||||
screenshot: never;
|
|
||||||
|
|
||||||
reducers: {
|
reducers: {
|
||||||
[actionName: string]: (state: State, actionData: any) => Partial<State>;
|
[actionName: string]: (state: State, actionData: any) => Partial<State>;
|
||||||
} = {};
|
} = {};
|
||||||
app: App;
|
app: App;
|
||||||
onKeyboardAction: ((action: string) => void) | null;
|
onKeyboardAction: ((action: string) => void) | undefined;
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
return `<${this.constructor.name}#${this.constructor.id}>`;
|
return `<${this.constructor.name}#${this.constructor.id}>`;
|
||||||
@@ -172,7 +165,7 @@ export abstract class FlipperBasePlugin<
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof action === 'function') {
|
if (typeof action === 'function') {
|
||||||
this.setState(action.call(this, this.state, actionData));
|
this.setState(action.call(this, this.state, actionData) as State);
|
||||||
} else {
|
} else {
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
throw new TypeError(`Reducer ${actionData.type} isn't a function`);
|
throw new TypeError(`Reducer ${actionData.type} isn't a function`);
|
||||||
@@ -217,6 +210,7 @@ export class FlipperPlugin<
|
|||||||
['constructor']: typeof FlipperPlugin;
|
['constructor']: typeof FlipperPlugin;
|
||||||
constructor(props: Props<P>) {
|
constructor(props: Props<P>) {
|
||||||
super(props);
|
super(props);
|
||||||
|
// @ts-ignore constructor should be assigned already
|
||||||
const {id} = this.constructor;
|
const {id} = this.constructor;
|
||||||
this.subscriptions = [];
|
this.subscriptions = [];
|
||||||
// @ts-ignore props.target will be instance of Client
|
// @ts-ignore props.target will be instance of Client
|
||||||
|
|||||||
Reference in New Issue
Block a user