Merge pull request #12632 from JacekJagiello/react-hot-loader

Added type definitions for react-hot-loader
This commit is contained in:
Andy
2016-11-15 13:02:32 -08:00
committed by GitHub
3 changed files with 66 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
// Type definitions for react-hot-loader 3.0
// Project: https://github.com/gaearon/react-hot-loader
// Definitions by: Jacek Jagiello <https://github.com/jacekjagiello/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as React from "react"
interface ErrorReporterProps {
error: any
}
export interface AppContainerProps {
children?: React.ReactElement<any>,
errorReporter?: React.ComponentClass<ErrorReporterProps> | React.StatelessComponent<ErrorReporterProps>
}
export class AppContainer extends React.Component<AppContainerProps, {}> {}
@@ -0,0 +1,29 @@
import * as React from 'react'
import { AppContainer } from 'react-hot-loader'
interface ErrorReporterProps {
error: any
}
class ErrorReporterComponent extends React.Component<ErrorReporterProps, any> {
public render() {
return <p>{this.props.error.message}</p>
}
}
const DummyComponent = () => <p>Dummy component</p>
const ErrorReporter = ({ error } : ErrorReporterProps) => <ErrorReporterComponent error={error} />
class AppContainerTest extends React.Component<any, any> {
public render() {
return (
<div>
<AppContainer errorReporter={ErrorReporterComponent}>
<DummyComponent />
</AppContainer>
</div>
)
}
}
export default AppContainerTest
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-hot-loader-tests.tsx"
]
}