Make createTablePlugin strict

Summary: _typescript_

Reviewed By: danielbuechele

Differential Revision: D17259739

fbshipit-source-id: a7d36482fc334fd05780fef56ebe3b2a981c2ac5
This commit is contained in:
Pascal Hartig
2019-09-10 05:41:50 -07:00
committed by Facebook Github Bot
parent ce51458eb8
commit 71e2369b41

View File

@@ -21,6 +21,7 @@ import createPaste from './fb-stubs/createPaste';
import {List, Map as ImmutableMap} from 'immutable';
import React from 'react';
import {KeyboardActions} from './MenuBar';
import {TableBodyRow} from './ui';
type ID = string;
@@ -60,7 +61,6 @@ type State = {
* the client in an unknown state.
*/
export function createTablePlugin<T extends RowData>(props: Props<T>) {
// @ts-ignore
return class extends FlipperPlugin<State, any, PersistedState<T>> {
static keyboardActions: KeyboardActions = ['clear', 'createPaste'];
@@ -97,7 +97,7 @@ export function createTablePlugin<T extends RowData>(props: Props<T>) {
}
};
state = {
state: State = {
selectedIds: [],
};
@@ -121,7 +121,7 @@ export function createTablePlugin<T extends RowData>(props: Props<T>) {
createPaste = () => {
let paste = '';
const mapFn = row =>
const mapFn = (row: TableBodyRow) =>
Object.keys(props.columns)
.map(key => textContent(row.columns[key].value))
.join('\t');
@@ -129,7 +129,9 @@ export function createTablePlugin<T extends RowData>(props: Props<T>) {
if (this.state.selectedIds.length > 0) {
// create paste from selection
paste = this.props.persistedState.rows
.filter(row => this.state.selectedIds.indexOf(row.key) > -1)
.filter(
(row: TableBodyRow) => this.state.selectedIds.indexOf(row.key) > -1,
)
.map(mapFn)
.join('\n');
} else {