Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EuiErrorBoundary: converted to Typescript #2690

Merged
merged 11 commits into from
Dec 26, 2019
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Added `nested` glyph to `EuiIcon` ([#2707](https://github.com/elastic/eui/pull/2707))
- Added `tableLayout` prop to `EuiTable`, `EuiBasicTable` and `EuiInMemoryTable` to provide the option of auto layout ([#2697](https://github.com/elastic/eui/pull/2697))
- Converted `EuiErrorBoundary` to Typescript ([#2690](https://github.com/elastic/eui/pull/2690))

**Bug fixes**

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
import React, { Component } from 'react';
import React, { Component, HTMLAttributes } from 'react';
import { CommonProps } from '../common';
import PropTypes from 'prop-types';

import { EuiText } from '../text';

export class EuiErrorBoundary extends Component {
interface EuiErrorBoundaryState {
hasError: boolean;
error?: Error;
}

export type EuiErrorBoundaryProps = CommonProps &
HTMLAttributes<HTMLDivElement>;

export class EuiErrorBoundary extends Component<
EuiErrorBoundaryProps,
EuiErrorBoundaryState
> {
static propTypes = {
children: PropTypes.node,
};

constructor(props) {
constructor(props: EuiErrorBoundaryProps) {
super(props);

this.state = {
const errorState: EuiErrorBoundaryState = {
hasError: false,
error: undefined,
};

this.state = errorState;
}

componentDidCatch(error) {
componentDidCatch(error: Error) {
// Display fallback UI
this.setState({
hasError: true,
Expand Down
9 changes: 0 additions & 9 deletions src/components/error_boundary/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/error_boundary/index.js

This file was deleted.

1 change: 1 addition & 0 deletions src/components/error_boundary/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { EuiErrorBoundary, EuiErrorBoundaryProps } from './error_boundary';
1 change: 0 additions & 1 deletion src/components/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference path="./code/index.d.ts" />
/// <reference path="./combo_box/index.d.ts" />
/// <reference path="./date_picker/index.d.ts" />
/// <reference path="./error_boundary/index.d.ts" />
/// <reference path="./filter_group/index.d.ts" />
/// <reference path="./form/index.d.ts" />
/// <reference path="./modal/index.d.ts" />
Expand Down