From 84092534ce136d9d2b18e09b514248db1f60b38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Tue, 20 Aug 2019 03:18:32 -0700 Subject: [PATCH] ErrorBoundary Summary: _typescript_ Reviewed By: bnelo12 Differential Revision: D16830532 fbshipit-source-id: 482d16194cfe8547b9926a0b9b08cfc9e2b46972 --- .../{ErrorBoundary.js => ErrorBoundary.tsx} | 27 ++++++++++--------- src/ui/index.js | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) rename src/ui/components/{ErrorBoundary.js => ErrorBoundary.tsx} (82%) diff --git a/src/ui/components/ErrorBoundary.js b/src/ui/components/ErrorBoundary.tsx similarity index 82% rename from src/ui/components/ErrorBoundary.js rename to src/ui/components/ErrorBoundary.tsx index 51aaebec7..caa778812 100644 --- a/src/ui/components/ErrorBoundary.js +++ b/src/ui/components/ErrorBoundary.tsx @@ -5,12 +5,13 @@ * @format */ -import ErrorBlock from './ErrorBlock.js'; +import ErrorBlock from './ErrorBlock'; import {Component} from 'react'; -import Heading from './Heading.tsx'; -import Button from './Button.js'; -import View from './View.tsx'; -import styled from '../styled/index.js'; +import Heading from './Heading'; +import Button from './Button'; +import View from './View'; +import styled from 'react-emotion'; +import React from 'react'; const ErrorBoundaryContainer = styled(View)({ overflow: 'auto', @@ -24,25 +25,25 @@ const ErrorBoundaryStack = styled(ErrorBlock)({ type ErrorBoundaryProps = { /** Function to dynamically generate the heading of the ErrorBox. */ - buildHeading?: (err: Error) => string, + buildHeading?: (err: Error) => string; /** Heading of the ErrorBox. Used as an alternative to `buildHeading`. */ - heading?: string, + heading?: string; /** Whether the stacktrace of the error is shown in the error box */ - showStack?: boolean, + showStack?: boolean; /** Code that might throw errors that will be catched */ - children?: React$Node, + children?: React.ReactNode; }; -type ErrorBoundaryState = {| - error: ?Error, -|}; +type ErrorBoundaryState = { + error: Error | null | undefined; +}; /** * Boundary catching errors and displaying an ErrorBlock instead. */ export default class ErrorBoundary extends Component< ErrorBoundaryProps, - ErrorBoundaryState, + ErrorBoundaryState > { constructor(props: ErrorBoundaryProps, context: Object) { super(props, context); diff --git a/src/ui/index.js b/src/ui/index.js index 6f62b1efc..7b19e579c 100644 --- a/src/ui/index.js +++ b/src/ui/index.js @@ -82,7 +82,7 @@ export {default as CodeBlock} from './components/CodeBlock.js'; // error export {default as ErrorBlock} from './components/ErrorBlock.js'; export {ErrorBlockContainer} from './components/ErrorBlock.js'; -export {default as ErrorBoundary} from './components/ErrorBoundary.js'; +export {default as ErrorBoundary} from './components/ErrorBoundary.tsx'; // interactive components export type {OrderableOrder} from './components/Orderable.tsx';