From 71e2369b4139ddf82bb4ca8841c2f578c39f736a Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Tue, 10 Sep 2019 05:41:50 -0700 Subject: [PATCH] Make createTablePlugin strict Summary: _typescript_ Reviewed By: danielbuechele Differential Revision: D17259739 fbshipit-source-id: a7d36482fc334fd05780fef56ebe3b2a981c2ac5 --- src/createTablePlugin.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/createTablePlugin.tsx b/src/createTablePlugin.tsx index 26c41227e..7208d3e6e 100644 --- a/src/createTablePlugin.tsx +++ b/src/createTablePlugin.tsx @@ -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(props: Props) { - // @ts-ignore return class extends FlipperPlugin> { static keyboardActions: KeyboardActions = ['clear', 'createPaste']; @@ -97,7 +97,7 @@ export function createTablePlugin(props: Props) { } }; - state = { + state: State = { selectedIds: [], }; @@ -121,7 +121,7 @@ export function createTablePlugin(props: Props) { 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(props: Props) { 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 {