Remove FlowFixMe's from TypeScript

Summary: This diff was a joy to draft.

Reviewed By: jknoxville

Differential Revision: D17344676

fbshipit-source-id: 0694d0393fa243edef61408ecfee92912fbbfa32
This commit is contained in:
Pascal Hartig
2019-09-12 10:18:25 -07:00
committed by Facebook Github Bot
parent f41cbcd429
commit cbbe32b9b9
11 changed files with 8 additions and 19 deletions

View File

@@ -367,7 +367,6 @@ export default class Client extends EventEmitter {
this.store.getState().plugins.devicePlugins.get(params.api); this.store.getState().plugins.devicePlugins.get(params.api);
if (persistingPlugin && persistingPlugin.persistedStateReducer) { if (persistingPlugin && persistingPlugin.persistedStateReducer) {
let pluginKey = `${this.id}#${params.api}`; let pluginKey = `${this.id}#${params.api}`;
//$FlowFixMe
if (persistingPlugin.prototype instanceof FlipperDevicePlugin) { if (persistingPlugin.prototype instanceof FlipperDevicePlugin) {
// For device plugins, we are just using the device id instead of client id as the prefix. // For device plugins, we are just using the device id instead of client id as the prefix.
this.deviceSerial().then( this.deviceSerial().then(

View File

@@ -98,7 +98,6 @@ export function setupMenuBar(
menuItem => menuItem.label === topLevelMenu, menuItem => menuItem.label === topLevelMenu,
); );
if (menu) { if (menu) {
// $FlowFixMe submenu is missing in electron API spec
const menuItem = menu.submenu.items.find( const menuItem = menu.submenu.items.find(
menuItem => menuItem.label === label, menuItem => menuItem.label === label,
); );

View File

@@ -64,7 +64,6 @@ test('persistedStateReducer is adding data', () => {
const tablePlugin = createTablePlugin({...PROPS, method}); const tablePlugin = createTablePlugin({...PROPS, method});
const id = '1'; const id = '1';
// $FlowFixMe persistedStateReducer exists for createTablePlugin
const {rows, datas} = tablePlugin.persistedStateReducer( const {rows, datas} = tablePlugin.persistedStateReducer(
tablePlugin.defaultPersistedState, tablePlugin.defaultPersistedState,
method, method,

View File

@@ -107,7 +107,6 @@ export function getDynamicPlugins() {
let dynamicPlugins: Array<PluginDefinition> = []; let dynamicPlugins: Array<PluginDefinition> = [];
try { try {
dynamicPlugins = JSON.parse( dynamicPlugins = JSON.parse(
// $FlowFixMe process.env not defined in electron API spec
(remote && remote.process.env.PLUGINS) || process.env.PLUGINS || '[]', (remote && remote.process.env.PLUGINS) || process.env.PLUGINS || '[]',
); );
} catch (e) { } catch (e) {

View File

@@ -6,7 +6,6 @@
*/ */
import {ipcRenderer} from 'electron'; import {ipcRenderer} from 'electron';
// $FlowFixMe perf_hooks is a new API in node
import {performance} from 'perf_hooks'; import {performance} from 'perf_hooks';
import {Store} from '../reducers/index'; import {Store} from '../reducers/index';

View File

@@ -157,17 +157,14 @@ export abstract class FlipperBasePlugin<
_teardown(): void {} _teardown(): void {}
dispatchAction(actionData: Actions) { dispatchAction(actionData: Actions) {
// $FlowFixMe
const action = this.reducers[actionData.type]; const action = this.reducers[actionData.type];
if (!action) { if (!action) {
// $FlowFixMe
throw new ReferenceError(`Unknown action ${actionData.type}`); throw new ReferenceError(`Unknown action ${actionData.type}`);
} }
if (typeof action === 'function') { if (typeof action === 'function') {
this.setState(action.call(this, this.state, actionData) as State); this.setState(action.call(this, this.state, actionData) as State);
} else { } else {
// $FlowFixMe
throw new TypeError(`Reducer ${actionData.type} isn't a function`); throw new TypeError(`Reducer ${actionData.type} isn't a function`);
} }
} }

View File

@@ -63,7 +63,6 @@ export default function reducer(
return; return;
} }
// $FlowFixMe Flow doesn't know prototype
if (p.prototype instanceof FlipperDevicePlugin) { if (p.prototype instanceof FlipperDevicePlugin) {
// @ts-ignore doesn't know p must be typeof FlipperDevicePlugin here // @ts-ignore doesn't know p must be typeof FlipperDevicePlugin here
devicePlugins.set(p.id, p); devicePlugins.set(p.id, p);

View File

@@ -202,13 +202,11 @@ export default class Orderable extends React.Component<
{passive: true}, {passive: true},
); );
// $FlowFixMe
const screenClickPos = event.nativeEvent[this.screenKey]; const screenClickPos = event.nativeEvent[this.screenKey];
document.addEventListener( document.addEventListener(
'mousemove', 'mousemove',
(this._mousemove = (event: MouseEvent) => { (this._mousemove = (event: MouseEvent) => {
// $FlowFixMe
const goingOpposite = event[this.screenKey] < screenClickPos; const goingOpposite = event[this.screenKey] < screenClickPos;
this.possibleMove(activeKey, goingOpposite, event, clickOffset, sizes); this.possibleMove(activeKey, goingOpposite, event, clickOffset, sizes);
}), }),
@@ -230,7 +228,7 @@ export default class Orderable extends React.Component<
if (containerRef) { if (containerRef) {
const containerRect: Rect = containerRef.getBoundingClientRect(); const containerRect: Rect = containerRef.getBoundingClientRect();
let newActivePos = // $FlowFixMe let newActivePos =
event[this.screenKey] - containerRect[this.offsetKey] - cursorOffset; event[this.screenKey] - containerRect[this.offsetKey] - cursorOffset;
newActivePos = Math.max(-1, newActivePos); newActivePos = Math.max(-1, newActivePos);
newActivePos = Math.min( newActivePos = Math.min(

View File

@@ -322,7 +322,6 @@ class ManagedTable extends React.Component<
if (!e.shiftKey) { if (!e.shiftKey) {
highlightedRows.clear(); highlightedRows.clear();
} }
// $FlowFixMe 0 <= newIndex <= rows.size - 1
highlightedRows.add(rows.get(newIndex)!.key); highlightedRows.add(rows.get(newIndex)!.key);
this.onRowHighlighted(highlightedRows, () => { this.onRowHighlighted(highlightedRows, () => {
const {current} = this.tableRef; const {current} = this.tableRef;
@@ -437,11 +436,9 @@ class ManagedTable extends React.Component<
let startIndex = -1; let startIndex = -1;
let endIndex = -1; let endIndex = -1;
for (let i = 0; i < this.props.rows.size; i++) { for (let i = 0; i < this.props.rows.size; i++) {
// $FlowFixMe 0 <= newIndex <= rows.size - 1
if (this.props.rows.get(i)!.key === fromKey) { if (this.props.rows.get(i)!.key === fromKey) {
startIndex = i; startIndex = i;
} }
// $FlowFixMe 0 <= newIndex <= rows.size - 1
if (this.props.rows.get(i)!.key === toKey) { if (this.props.rows.get(i)!.key === toKey) {
endIndex = i; endIndex = i;
} }
@@ -456,7 +453,6 @@ class ManagedTable extends React.Component<
i++ i++
) { ) {
try { try {
// $FlowFixMe 0 <= newIndex <= rows.size - 1
selected.push(this.props.rows.get(i)!.key); selected.push(this.props.rows.get(i)!.key);
} catch (e) {} } catch (e) {}
} }
@@ -475,7 +471,6 @@ class ManagedTable extends React.Component<
!e.shiftKey // When shift key is pressed, it's a range select not a drag select !e.shiftKey // When shift key is pressed, it's a range select not a drag select
) { ) {
current.scrollToItem(index + 1); current.scrollToItem(index + 1);
// $FlowFixMe 0 <= newIndex <= rows.size - 1
const startKey = this.props.rows.get(dragStartIndex)!.key; const startKey = this.props.rows.get(dragStartIndex)!.key;
const highlightedRows = new Set(this.selectInRange(startKey, row.key)); const highlightedRows = new Set(this.selectInRange(startKey, row.key));
this.onRowHighlighted(highlightedRows); this.onRowHighlighted(highlightedRows);

View File

@@ -8,7 +8,6 @@
import electron from 'electron'; import electron from 'electron';
const _isProduction = !/node_modules[\\/]electron[\\/]/.test( const _isProduction = !/node_modules[\\/]electron[\\/]/.test(
// $FlowFixMe: execPath exists, but is not in electron API spec
process.execPath || electron.remote.process.execPath, process.execPath || electron.remote.process.execPath,
); );

View File

@@ -12,8 +12,14 @@ export {};
type RequestIdleHandle = number; type RequestIdleHandle = number;
declare global { declare global {
interface StoreEnhancerStateSanitizer {
stateSanitizer: Function;
}
interface Window { interface Window {
__REDUX_DEVTOOLS_EXTENSION__: undefined | StoreEnhancerStoreCreator; __REDUX_DEVTOOLS_EXTENSION__:
| undefined
| StoreEnhancerStoreCreator & StoreEnhancerStateSanitizer;
Flipper: { Flipper: {
init: () => void; init: () => void;