Convert utils/textContent.tsx to TS
Summary: Convert utils/textContent.tsx to TS Reviewed By: danielbuechele Differential Revision: D16710386 fbshipit-source-id: 225d66965d915fc1c36e382e3c06c7b2dad5d973
This commit is contained in:
committed by
Facebook Github Bot
parent
fd9b83eac3
commit
a522afd64f
@@ -17,7 +17,7 @@ import Button from './ui/components/Button';
|
|||||||
import DetailSidebar from './chrome/DetailSidebar';
|
import DetailSidebar from './chrome/DetailSidebar';
|
||||||
import {FlipperPlugin} from './plugin.tsx';
|
import {FlipperPlugin} from './plugin.tsx';
|
||||||
import SearchableTable_immutable from './ui/components/searchable/SearchableTable_immutable';
|
import SearchableTable_immutable from './ui/components/searchable/SearchableTable_immutable';
|
||||||
import textContent from './utils/textContent.js';
|
import textContent from './utils/textContent.tsx';
|
||||||
import createPaste from './fb-stubs/createPaste.tsx';
|
import createPaste from './fb-stubs/createPaste.tsx';
|
||||||
|
|
||||||
import {List, Map as ImmutableMap} from 'immutable';
|
import {List, Map as ImmutableMap} from 'immutable';
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import FlexColumn from '../ui/components/FlexColumn';
|
|||||||
import DetailSidebar from '../chrome/DetailSidebar';
|
import DetailSidebar from '../chrome/DetailSidebar';
|
||||||
import {FlipperPlugin} from '../plugin.tsx';
|
import {FlipperPlugin} from '../plugin.tsx';
|
||||||
import SearchableTable from '../ui/components/searchable/SearchableTable';
|
import SearchableTable from '../ui/components/searchable/SearchableTable';
|
||||||
import textContent from '../utils/textContent.js';
|
import textContent from '../utils/textContent.tsx';
|
||||||
import createPaste from '../fb-stubs/createPaste.tsx';
|
import createPaste from '../fb-stubs/createPaste.tsx';
|
||||||
|
|
||||||
import type {Node} from 'react';
|
import type {Node} from 'react';
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
import type {Filter} from './types.js';
|
import type {Filter} from './types.js';
|
||||||
import {PureComponent} from 'react';
|
import {PureComponent} from 'react';
|
||||||
import ContextMenu from '../ContextMenu.js';
|
import ContextMenu from '../ContextMenu.js';
|
||||||
import textContent from '../../../utils/textContent.js';
|
import textContent from '../../../utils/textContent.tsx';
|
||||||
import styled from '../../styled/index.js';
|
import styled from '../../styled/index.js';
|
||||||
import {colors} from '../colors.js';
|
import {colors} from '../colors.js';
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import type {SearchableProps} from './Searchable.js';
|
|||||||
import {PureComponent} from 'react';
|
import {PureComponent} from 'react';
|
||||||
import ManagedTable from '../table/ManagedTable.js';
|
import ManagedTable from '../table/ManagedTable.js';
|
||||||
|
|
||||||
import textContent from '../../../utils/textContent.js';
|
import textContent from '../../../utils/textContent.tsx';
|
||||||
import Searchable from './Searchable.js';
|
import Searchable from './Searchable.js';
|
||||||
import deepEqual from 'deep-equal';
|
import deepEqual from 'deep-equal';
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import type {SearchableProps} from './Searchable.js';
|
|||||||
import {PureComponent} from 'react';
|
import {PureComponent} from 'react';
|
||||||
import ManagedTable_immutable from '../table/ManagedTable_immutable.js';
|
import ManagedTable_immutable from '../table/ManagedTable_immutable.js';
|
||||||
|
|
||||||
import textContent from '../../../utils/textContent.js';
|
import textContent from '../../../utils/textContent.tsx';
|
||||||
import Searchable from './Searchable.js';
|
import Searchable from './Searchable.js';
|
||||||
import deepEqual from 'deep-equal';
|
import deepEqual from 'deep-equal';
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import createPaste from '../../../fb-stubs/createPaste.tsx';
|
|||||||
import debounceRender from 'react-debounce-render';
|
import debounceRender from 'react-debounce-render';
|
||||||
import debounce from 'lodash.debounce';
|
import debounce from 'lodash.debounce';
|
||||||
import {DEFAULT_ROW_HEIGHT} from './types';
|
import {DEFAULT_ROW_HEIGHT} from './types';
|
||||||
import textContent from '../../../utils/textContent.js';
|
import textContent from '../../../utils/textContent.tsx';
|
||||||
|
|
||||||
export type ManagedTableProps = {|
|
export type ManagedTableProps = {|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import createPaste from '../../../fb-stubs/createPaste.tsx';
|
|||||||
import debounceRender from 'react-debounce-render';
|
import debounceRender from 'react-debounce-render';
|
||||||
import debounce from 'lodash.debounce';
|
import debounce from 'lodash.debounce';
|
||||||
import {DEFAULT_ROW_HEIGHT} from './types';
|
import {DEFAULT_ROW_HEIGHT} from './types';
|
||||||
import textContent from '../../../utils/textContent.js';
|
import textContent from '../../../utils/textContent.tsx';
|
||||||
|
|
||||||
export type ManagedTableProps_immutable = {|
|
export type ManagedTableProps_immutable = {|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,5 +5,5 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export {default as textContent} from './textContent.js';
|
export {default as textContent} from './textContent.tsx';
|
||||||
export {getStringFromErrorLike} from './errors.tsx';
|
export {getStringFromErrorLike} from './errors.tsx';
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type {Node} from 'react';
|
import {ReactNode, ReactElement} from 'react';
|
||||||
|
|
||||||
function isReactElement(object: any) {
|
function isReactElement(object: any) {
|
||||||
return (
|
return (
|
||||||
@@ -19,9 +19,9 @@ function isReactElement(object: any) {
|
|||||||
* Recursively walks through all children of a React element and returns
|
* Recursively walks through all children of a React element and returns
|
||||||
* the string representation of the leafs concatenated.
|
* the string representation of the leafs concatenated.
|
||||||
*/
|
*/
|
||||||
export default (node: Node): string => {
|
export default (node: ReactNode): string => {
|
||||||
let res = '';
|
let res = '';
|
||||||
const traverse = (node: Node) => {
|
const traverse = (node: ReactNode) => {
|
||||||
if (typeof node === 'string' || typeof node === 'number') {
|
if (typeof node === 'string' || typeof node === 'number') {
|
||||||
// this is a leaf, add it to the result string
|
// this is a leaf, add it to the result string
|
||||||
res += node;
|
res += node;
|
||||||
@@ -30,8 +30,7 @@ export default (node: Node): string => {
|
|||||||
node.forEach(traverse);
|
node.forEach(traverse);
|
||||||
} else if (isReactElement(node)) {
|
} else if (isReactElement(node)) {
|
||||||
// node is a react element access its children an recursively stringify them
|
// node is a react element access its children an recursively stringify them
|
||||||
// $FlowFixMe
|
const {children} = (node as ReactElement).props;
|
||||||
const {children} = node.props;
|
|
||||||
if (Array.isArray(children)) {
|
if (Array.isArray(children)) {
|
||||||
children.forEach(traverse);
|
children.forEach(traverse);
|
||||||
} else {
|
} else {
|
||||||
Reference in New Issue
Block a user