Summary: Let's migrate one file to TS, this helps us to test our tooling and make sure, everything works as expected.

Reviewed By: bnelo12

Differential Revision: D16149514

fbshipit-source-id: 05055a1830f187c6812baa661e109ea67995253b
This commit is contained in:
Daniel Büchele
2019-07-12 04:17:35 -07:00
committed by Facebook Github Bot
parent 474cc1289e
commit 0a42558344
3 changed files with 20 additions and 15 deletions

View File

@@ -9,7 +9,7 @@ import React from 'react';
import {FlexColumn, FlexRow} from 'flipper'; import {FlexColumn, FlexRow} from 'flipper';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import WelcomeScreen from './chrome/WelcomeScreen.js'; import WelcomeScreen from './chrome/WelcomeScreen.js';
import TitleBar from './chrome/TitleBar.js'; import TitleBar from './chrome/TitleBar.tsx';
import MainSidebar from './chrome/MainSidebar.js'; import MainSidebar from './chrome/MainSidebar.js';
import BugReporterDialog from './chrome/BugReporterDialog.js'; import BugReporterDialog from './chrome/BugReporterDialog.js';
import ErrorBar from './chrome/ErrorBar.js'; import ErrorBar from './chrome/ErrorBar.js';

View File

@@ -5,14 +5,13 @@
* @format * @format
*/ */
import type {ActiveSheet, LauncherMsg} from '../reducers/application'; import {ActiveSheet, LauncherMsg} from '../reducers/application.js';
import { import {
colors, colors,
Button, Button,
ButtonGroup, ButtonGroup,
FlexRow, FlexRow,
Component,
Spacer, Spacer,
styled, styled,
Text, Text,
@@ -33,6 +32,7 @@ import config from '../fb-stubs/config.js';
import {isAutoUpdaterEnabled} from '../utils/argvUtils.js'; import {isAutoUpdaterEnabled} from '../utils/argvUtils.js';
import isProduction from '../utils/isProduction.js'; import isProduction from '../utils/isProduction.js';
import {clipboard} from 'electron'; import {clipboard} from 'electron';
import React from 'react';
const AppTitleBar = styled(FlexRow)(({focused}) => ({ const AppTitleBar = styled(FlexRow)(({focused}) => ({
background: focused background: focused
@@ -54,22 +54,24 @@ const AppTitleBar = styled(FlexRow)(({focused}) => ({
zIndex: 4, zIndex: 4,
})); }));
type OwnProps = {| type OwnProps = {
version: string, version: string,
|}; };
type Props = {| type DispatchFromProps = {
...OwnProps, toggleLeftSidebarVisible: (visible?: boolean) => void,
toggleRightSidebarVisible: (visible?: boolean) => void,
setActiveSheet: (sheet: ActiveSheet) => void,
};
type StateFromProps = {
windowIsFocused: boolean, windowIsFocused: boolean,
leftSidebarVisible: boolean, leftSidebarVisible: boolean,
rightSidebarVisible: boolean, rightSidebarVisible: boolean,
rightSidebarAvailable: boolean, rightSidebarAvailable: boolean,
downloadingImportData: boolean, downloadingImportData: boolean,
toggleLeftSidebarVisible: (visible?: boolean) => void,
toggleRightSidebarVisible: (visible?: boolean) => void,
setActiveSheet: (sheet: ActiveSheet) => void,
launcherMsg: LauncherMsg, launcherMsg: LauncherMsg,
|}; };
const VersionText = styled(Text)({ const VersionText = styled(Text)({
color: colors.light50, color: colors.light50,
@@ -84,7 +86,7 @@ const VersionText = styled(Text)({
}, },
}); });
class Version extends Component<{children: string}, {copied: boolean}> { class Version extends React.Component<{children: string}, {copied: boolean}> {
state = { state = {
copied: false, copied: false,
}; };
@@ -109,7 +111,8 @@ const Importing = styled(FlexRow)({
marginLeft: 10, marginLeft: 10,
}); });
class TitleBar extends Component<Props> { type Props = OwnProps & DispatchFromProps & StateFromProps;
class TitleBar extends React.Component<Props> {
render() { render() {
return ( return (
<AppTitleBar focused={this.props.windowIsFocused} className="toolbar"> <AppTitleBar focused={this.props.windowIsFocused} className="toolbar">
@@ -161,7 +164,9 @@ class TitleBar extends Component<Props> {
} }
} }
export default connect<Props, OwnProps, _, _, _, _>( // @TODO: TS_MIGRATION
type Store = any;
export default connect<StateFromProps, DispatchFromProps, OwnProps, Store>(
({ ({
application: { application: {
windowIsFocused, windowIsFocused,

View File

@@ -5,7 +5,7 @@
* @format * @format
*/ */
import TitleBar from '../TitleBar.js'; import TitleBar from '../TitleBar.tsx';
import renderer from 'react-test-renderer'; import renderer from 'react-test-renderer';
import reducers from '../../reducers/index.js'; import reducers from '../../reducers/index.js';
import configureStore from 'redux-mock-store'; import configureStore from 'redux-mock-store';