mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[react-hot-loader] Upgraded to v4.1 (#25133)
* Updated to 4.1. * Removed from types. * Updated tslint. * Fixed lint errors.
This commit is contained in:
parent
4abbfb42ff
commit
c3257dd16c
24
types/react-hot-loader/index.d.ts
vendored
24
types/react-hot-loader/index.d.ts
vendored
@ -1,19 +1,25 @@
|
||||
// Type definitions for react-hot-loader 3.0
|
||||
// Type definitions for react-hot-loader 4.1
|
||||
// Project: https://github.com/gaearon/react-hot-loader
|
||||
// Definitions by: Jacek Jagiello <https://github.com/jacekjagiello>
|
||||
// MartynasZilinskas <https://github.com/MartynasZilinskas>
|
||||
// Dovydas Navickas <https://github.com/DovydasNavickas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from "react"
|
||||
import * as React from "react";
|
||||
import "node";
|
||||
|
||||
interface ErrorReporterProps {
|
||||
error: any
|
||||
export type ReactComponent<TProps> = React.ComponentClass<TProps> | React.StatelessComponent<TProps>;
|
||||
export type ExtractProps<TComponent> = TComponent extends ReactComponent<infer TProps> ? TProps : {};
|
||||
|
||||
export interface ErrorReporterProps {
|
||||
error: any;
|
||||
}
|
||||
|
||||
export interface AppContainerProps {
|
||||
children?: React.ReactElement<any>,
|
||||
errorReporter?: React.ComponentClass<ErrorReporterProps> | React.StatelessComponent<ErrorReporterProps>
|
||||
warnings?: boolean
|
||||
errorReporter?: ReactComponent<ErrorReporterProps>;
|
||||
warnings?: boolean;
|
||||
}
|
||||
|
||||
export class AppContainer extends React.Component<AppContainerProps, React.ComponentState> {}
|
||||
|
||||
export function hot(sourceModule: NodeModule): <TComponent>(component: TComponent) => ReactComponent<ExtractProps<TComponent>>;
|
||||
|
||||
@ -1,29 +1,59 @@
|
||||
import * as React from 'react'
|
||||
import { AppContainer } from 'react-hot-loader'
|
||||
import * as React from "react";
|
||||
import { AppContainer, hot, ReactComponent } from "react-hot-loader";
|
||||
|
||||
interface ErrorReporterProps {
|
||||
error: any
|
||||
}
|
||||
declare function describe(desc: string, f: () => void): void;
|
||||
declare function it(desc: string, f: () => void): void;
|
||||
|
||||
class ErrorReporterComponent extends React.Component<ErrorReporterProps> {
|
||||
public render() {
|
||||
return <p>{this.props.error.message}</p>
|
||||
}
|
||||
}
|
||||
it("Using AppContainer", () => {
|
||||
interface ErrorReporterProps {
|
||||
error: any;
|
||||
}
|
||||
|
||||
const DummyComponent = () => <p>Dummy component</p>
|
||||
const ErrorReporter = ({ error } : ErrorReporterProps) => <ErrorReporterComponent error={error} />
|
||||
class ErrorReporterComponent extends React.Component<ErrorReporterProps> {
|
||||
render() {
|
||||
return <p>{this.props.error.message}</p>;
|
||||
}
|
||||
}
|
||||
|
||||
class AppContainerTest extends React.Component {
|
||||
public render() {
|
||||
return (
|
||||
<div>
|
||||
<AppContainer errorReporter={ErrorReporterComponent}>
|
||||
<DummyComponent />
|
||||
</AppContainer>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
const DummyComponent = () => <p>Dummy component</p>;
|
||||
const ErrorReporter = ({ error }: ErrorReporterProps) => <ErrorReporterComponent error={error} />;
|
||||
|
||||
export default AppContainerTest
|
||||
class AppContainerTest extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<AppContainer errorReporter={ErrorReporterComponent}>
|
||||
<DummyComponent />
|
||||
</AppContainer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("Using hot", () => {
|
||||
interface Props {
|
||||
name: string;
|
||||
}
|
||||
|
||||
class Foo extends React.Component<Props> {
|
||||
render(): JSX.Element {
|
||||
return <div>Foo</div>;
|
||||
}
|
||||
}
|
||||
const FooSFC = (props: { surname: string }) => {
|
||||
return <div />;
|
||||
};
|
||||
|
||||
const Bar = hot(module)(Foo);
|
||||
const BarSFC = hot(module)(FooSFC);
|
||||
|
||||
const testRender = () => {
|
||||
return (
|
||||
<>
|
||||
<Bar name="Something" />
|
||||
<BarSFC surname="SomethingSFC" />
|
||||
</>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
@ -22,4 +22,4 @@
|
||||
"index.d.ts",
|
||||
"react-hot-loader-tests.tsx"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,79 +1 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user