diff --git a/types/draft-js/draft-js-tests.tsx b/types/draft-js/draft-js-tests.tsx index dae23b90ef..87172d9471 100644 --- a/types/draft-js/draft-js-tests.tsx +++ b/types/draft-js/draft-js-tests.tsx @@ -30,7 +30,7 @@ type SyntheticKeyboardEvent = React.KeyboardEvent<{}>; class RichEditorExample extends React.Component<{}, { editorState: EditorState }> { constructor() { - super(); + super({}); const sampleMarkup = 'Bold text, Italic text

' + @@ -182,9 +182,17 @@ function getBlockStyle(block: ContentBlock) { } } -class StyleButton extends React.Component<{key: string, active: boolean, label: string, onToggle: (blockType: string) => void, style: string}> { - constructor() { - super(); +interface Props { + key: string + active: boolean + label: string + onToggle: (blockType: string) => void + style: string +} + +class StyleButton extends React.Component { + constructor(props: Props) { + super(props); } onToggle: (event: Event) => void = (event: Event) => { diff --git a/types/jasmine-enzyme/jasmine-enzyme-tests.tsx b/types/jasmine-enzyme/jasmine-enzyme-tests.tsx index 53ee972ed3..6246618d86 100644 --- a/types/jasmine-enzyme/jasmine-enzyme-tests.tsx +++ b/types/jasmine-enzyme/jasmine-enzyme-tests.tsx @@ -254,7 +254,7 @@ describe('toHaveRef', () => { describe('toHaveState', () => { class Fixture extends React.Component { constructor() { - super(); + super({}); this.state = { foo: false, }; diff --git a/types/material-ui-pagination/material-ui-pagination-tests.tsx b/types/material-ui-pagination/material-ui-pagination-tests.tsx index 09246a2646..a7f85d8184 100644 --- a/types/material-ui-pagination/material-ui-pagination-tests.tsx +++ b/types/material-ui-pagination/material-ui-pagination-tests.tsx @@ -18,7 +18,7 @@ interface PagerState { class Pager extends React.Component<{}, PagerState> { constructor() { - super(); + super({}); this.state = { pageIndex: 0 }; diff --git a/types/material-ui/material-ui-tests.tsx b/types/material-ui/material-ui-tests.tsx index 987c6dd030..ab1abc4577 100644 --- a/types/material-ui/material-ui-tests.tsx +++ b/types/material-ui/material-ui-tests.tsx @@ -7004,7 +7004,7 @@ class BottomNavigationExample extends Component<{}, { index?: number }> { constructor() { - super(); + super({}); this.state = { index: 0 }; diff --git a/types/react-datepicker/react-datepicker-tests.tsx b/types/react-datepicker/react-datepicker-tests.tsx index 5a29b38149..a92446371d 100644 --- a/types/react-datepicker/react-datepicker-tests.tsx +++ b/types/react-datepicker/react-datepicker-tests.tsx @@ -4,7 +4,7 @@ import DatePicker from 'react-datepicker'; class ReactDatePicker extends React.Component<{}, { startDate: moment.Moment; displayName: string; }> { constructor(props: {}) { - super(); + super(props); this.state = { startDate: moment(), displayName: 'Example' diff --git a/types/react-dom/test-utils/index.d.ts b/types/react-dom/test-utils/index.d.ts index 05362460d4..caa5605ef5 100644 --- a/types/react-dom/test-utils/index.d.ts +++ b/types/react-dom/test-utils/index.d.ts @@ -59,7 +59,7 @@ export interface SyntheticEventData extends OptionalEventProperties { export type EventSimulator = (element: Element | Component, eventData?: SyntheticEventData) => void; export interface MockedComponentClass { - new (): any; + new (props: {}): any; } export interface ShallowRenderer { diff --git a/types/react-lazyload/react-lazyload-tests.tsx b/types/react-lazyload/react-lazyload-tests.tsx index e6f0f9bc81..f673652ef5 100644 --- a/types/react-lazyload/react-lazyload-tests.tsx +++ b/types/react-lazyload/react-lazyload-tests.tsx @@ -7,7 +7,7 @@ interface State { class Normal extends React.Component<{}, State> { constructor() { - super(); + super({}); const arr: string[] = []; for (let i = 0; i < 200; i++) { arr.push(`${i}`); diff --git a/types/react-native-material-kit/react-native-material-kit-tests.tsx b/types/react-native-material-kit/react-native-material-kit-tests.tsx index 4cb415d791..e26abfe5fc 100644 --- a/types/react-native-material-kit/react-native-material-kit-tests.tsx +++ b/types/react-native-material-kit/react-native-material-kit-tests.tsx @@ -141,7 +141,7 @@ class MKRadioButtonTest extends React.Component { radioGroup: MKRadioButton.Group; constructor() { - super(); + super(null); this.radioGroup = new MKRadioButton.Group(); setTheme({radioStyle: { @@ -165,7 +165,7 @@ class MKRadioButtonTest extends React.Component { /// Checkbox class MKCheckboxTest extends React.Component { constructor() { - super(); + super(null); setTheme({checkboxStyle: { fillColor: MKColor.Teal, diff --git a/types/react-native-material-ui/react-native-material-ui-tests.tsx b/types/react-native-material-ui/react-native-material-ui-tests.tsx index 4f875c59a3..4acb9db12e 100644 --- a/types/react-native-material-ui/react-native-material-ui-tests.tsx +++ b/types/react-native-material-ui/react-native-material-ui-tests.tsx @@ -68,7 +68,7 @@ const DialogExample = () => class BottomNavigationExample extends React.Component { constructor() { - super(); + super(null); this.state = { active: 'today' diff --git a/types/react-native-modalbox/react-native-modalbox-tests.tsx b/types/react-native-modalbox/react-native-modalbox-tests.tsx index c8ae1785e7..6a167791f4 100644 --- a/types/react-native-modalbox/react-native-modalbox-tests.tsx +++ b/types/react-native-modalbox/react-native-modalbox-tests.tsx @@ -24,7 +24,7 @@ class Example extends React.Component<{}, State> { modal6: Modal; constructor() { - super(); + super({}); this.state = { isOpen: false, diff --git a/types/react-native-tab-navigator/react-native-tab-navigator-tests.tsx b/types/react-native-tab-navigator/react-native-tab-navigator-tests.tsx index d343a7b84e..18a6ae62ba 100644 --- a/types/react-native-tab-navigator/react-native-tab-navigator-tests.tsx +++ b/types/react-native-tab-navigator/react-native-tab-navigator-tests.tsx @@ -10,7 +10,7 @@ const tabBarImage = 'https://assets-cdn.github.com/images/modules/logos_page/Git class TabTest extends React.Component { constructor() { - super(); + super({}); this.state = { selectedTab: 'home' diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx index b6adf8d8c6..4e1fe13e8a 100644 --- a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -43,9 +43,9 @@ class Example extends React.Component { } } -class TabTest extends React.Component { +class TabTest extends React.Component<{}, { selectedTab: string }> { constructor() { - super(); + super({}); this.state = { selectedTab: 'tab1' @@ -85,7 +85,7 @@ class TabTest extends React.Component { class TestCustomIcon extends React.Component { constructor() { - super(); + super({}); } handleButton() { diff --git a/types/react-onclickoutside/index.d.ts b/types/react-onclickoutside/index.d.ts index b342e98529..ad61a418a0 100644 --- a/types/react-onclickoutside/index.d.ts +++ b/types/react-onclickoutside/index.d.ts @@ -26,7 +26,7 @@ export interface OnClickOutProps { export type ComponentConstructor

= React.ComponentClass

| React.StatelessComponent

; export interface ClickOutComponentClass

extends React.ComponentClass

{ - new (props?: P, context?: any): React.Component & HandleClickOutside; + new (props: P, context?: any): React.Component & HandleClickOutside; } export default function OnClickOut

( diff --git a/types/react-onsenui/react-onsenui-tests.tsx b/types/react-onsenui/react-onsenui-tests.tsx index 33c3e7943c..c3c9486e88 100644 --- a/types/react-onsenui/react-onsenui-tests.tsx +++ b/types/react-onsenui/react-onsenui-tests.tsx @@ -9,7 +9,7 @@ class AppState { interface AppProps {} // tslint:disable-line no-empty-interface export class App extends React.Component { - constructor(props?: AppProps) { + constructor(props: AppProps) { super(props); this.state = new AppState(); } diff --git a/types/react-redux-toastr/react-redux-toastr-tests.ts b/types/react-redux-toastr/react-redux-toastr-tests.ts index f675bf5c78..ac49d2dcdd 100644 --- a/types/react-redux-toastr/react-redux-toastr-tests.ts +++ b/types/react-redux-toastr/react-redux-toastr-tests.ts @@ -18,7 +18,7 @@ function test() { toastr.confirm("Test", { onOk: callback, onCancel: callback }); toastr.error("Error", "Error message"); toastr.info("Info", "Info test", { timeOut: 1000, removeOnHover: true, onShowComplete: callback }); - toastr.success("Test", "Test message", { component: new React.Component() }); + toastr.success("Test", "Test message", { component: new React.Component({}) }); } test(); diff --git a/types/react-sortable-hoc/react-sortable-hoc-tests.tsx b/types/react-sortable-hoc/react-sortable-hoc-tests.tsx index af742734bf..db08db3e0e 100644 --- a/types/react-sortable-hoc/react-sortable-hoc-tests.tsx +++ b/types/react-sortable-hoc/react-sortable-hoc-tests.tsx @@ -50,7 +50,7 @@ class SortableComponent extends React.Component<{}, SortableComponentState> { } public constructor() { - super(); + super({}); this.state = { items: ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6'], axis: 'x' diff --git a/types/react-swf/react-swf-tests.ts b/types/react-swf/react-swf-tests.ts index 11c79c9940..ff42eed6f0 100644 --- a/types/react-swf/react-swf-tests.ts +++ b/types/react-swf/react-swf-tests.ts @@ -1,6 +1,8 @@ var version = ReactSWF.getFPVersion(); var isFPVersionSupported = ReactSWF.isFPVersionSupported('5'); -var reactSWF = new ReactSWF(); -reactSWF.props = { - src:'',pluginspage:'',width:20,height:20 -} +var reactSWF = new ReactSWF({ + src:'', + pluginspage:'', + width:20, + height:20, +}); diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 7d6fe7014f..9134406735 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -277,7 +277,7 @@ declare namespace React { // tslint:disable-next-line:no-empty-interface interface Component

extends ComponentLifecycle { } class Component { - constructor(props?: P, context?: any); + constructor(props: P, context?: any); // Disabling unified-signatures to have separate overloads. It's easier to understand this way. // tslint:disable:unified-signatures @@ -327,7 +327,7 @@ declare namespace React { } interface ComponentClass

{ - new (props?: P, context?: any): Component; + new (props: P, context?: any): Component; propTypes?: ValidationMap

; contextTypes?: ValidationMap; childContextTypes?: ValidationMap; @@ -336,7 +336,7 @@ declare namespace React { } interface ClassicComponentClass

extends ComponentClass

{ - new (props?: P, context?: any): ClassicComponent; + new (props: P, context?: any): ClassicComponent; getDefaultProps?(): P; } @@ -347,8 +347,8 @@ declare namespace React { */ type ClassType, C extends ComponentClass

> = C & - (new (props?: P, context?: any) => T) & - (new (props?: P, context?: any) => { props: P }); + (new (props: P, context?: any) => T) & + (new (props: P, context?: any) => { props: P }); // // Component Specs and Lifecycle diff --git a/types/react/test/index.ts b/types/react/test/index.ts index 10b4585e00..a22f480a60 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -262,7 +262,7 @@ class RefComponent extends React.Component { } } -let componentRef: RefComponent | null = new RefComponent(); +let componentRef: RefComponent | null = new RefComponent({}); RefComponent.create({ ref: "componentRef" }); // type of c should be inferred RefComponent.create({ ref: c => componentRef = c }); @@ -609,8 +609,8 @@ if (TestUtils.isElementOfType(emptyElement2, StatelessComponent)) { if (TestUtils.isDOMComponent(container)) { container.getAttribute("className"); -} else if (TestUtils.isCompositeComponent(new ModernComponent())) { - new ModernComponent().props; +} else if (TestUtils.isCompositeComponent(new ModernComponent({ hello: 'hi', foo: 3 }))) { + new ModernComponent({ hello: 'hi', foo: 3 }).props; } //