mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
Change React.Component<P, S> to React.Component<P, S = {}>
This commit is contained in:
@@ -38,7 +38,7 @@ This problem manifests itself in two ways. It should be fixed in [TypeScript 2.0
|
||||
```ts
|
||||
import * as React from "react";
|
||||
|
||||
class MyComponent extends React.Component<Props, {}> {
|
||||
class MyComponent extends React.Component<Props> {
|
||||
static contextTypes = {
|
||||
someValue: React.PropTypes.string
|
||||
};
|
||||
|
||||
Vendored
+6
-6
@@ -38,7 +38,7 @@ declare namespace React {
|
||||
|
||||
type Key = string | number;
|
||||
type Ref<T> = string | ((instance: T) => any);
|
||||
type ComponentState = {} | void;
|
||||
type ComponentState = {};
|
||||
|
||||
interface Attributes {
|
||||
key?: Key;
|
||||
@@ -184,10 +184,10 @@ declare namespace React {
|
||||
// Component API
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type ReactInstance = Component<any, any> | Element;
|
||||
type ReactInstance = Component<any> | Element;
|
||||
|
||||
// Base component for plain JS classes
|
||||
interface Component<P, S> extends ComponentLifecycle<P, S> { }
|
||||
interface Component<P, S = {}> extends ComponentLifecycle<P, S> { }
|
||||
class Component<P, S> {
|
||||
constructor(props?: P, context?: any);
|
||||
setState<K extends keyof S>(f: (prevState: S, props: P) => Pick<S, K>, callback?: () => any): void;
|
||||
@@ -208,9 +208,9 @@ declare namespace React {
|
||||
};
|
||||
}
|
||||
|
||||
class PureComponent<P, S> extends Component<P, S> { }
|
||||
class PureComponent<P, S = {}> extends Component<P, S> { }
|
||||
|
||||
interface ClassicComponent<P, S> extends Component<P, S> {
|
||||
interface ClassicComponent<P, S = {}> extends Component<P, S> {
|
||||
replaceState(nextState: S, callback?: () => any): void;
|
||||
isMounted(): boolean;
|
||||
getInitialState?(): S;
|
||||
@@ -2741,7 +2741,7 @@ declare namespace React {
|
||||
declare global {
|
||||
namespace JSX {
|
||||
interface Element extends React.ReactElement<any> { }
|
||||
interface ElementClass extends React.Component<any, any> {
|
||||
interface ElementClass extends React.Component<any> {
|
||||
render(): JSX.Element | null | false;
|
||||
}
|
||||
interface ElementAttributesProperty { props: {}; }
|
||||
|
||||
@@ -130,7 +130,7 @@ class ModernComponent extends React.Component<Props, State>
|
||||
}
|
||||
}
|
||||
|
||||
class ModernComponentNoState extends React.Component<Props, void> { }
|
||||
class ModernComponentNoState extends React.Component<Props> { }
|
||||
|
||||
interface SCProps {
|
||||
foo?: number;
|
||||
@@ -282,7 +282,7 @@ myComponent.reset();
|
||||
interface RCProps {
|
||||
}
|
||||
|
||||
class RefComponent extends React.Component<RCProps, {}> {
|
||||
class RefComponent extends React.Component<RCProps> {
|
||||
static create = React.createFactory(RefComponent);
|
||||
refMethod() {
|
||||
}
|
||||
@@ -704,7 +704,7 @@ const formEvent:InputFormEvent = changeEvent;
|
||||
prop2: string;
|
||||
prop3?: string;
|
||||
}
|
||||
class ComponentWithDefaultProps extends React.Component<ComponentProps, void> {
|
||||
class ComponentWithDefaultProps extends React.Component<ComponentProps> {
|
||||
static defaultProps = {
|
||||
prop3: "default value",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user