mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-10 11:40:16 +08:00
Merge remote-tracking branch 'remotes/upstream/master'
Conflicts: react-router/react-router-tests.ts
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
/// <reference path="react-redux.d.ts" />
|
||||
/// <reference path="../react/react.d.ts"/>
|
||||
/// <reference path="../react/react-dom.d.ts"/>
|
||||
/// <reference path="../redux/redux.d.ts" />
|
||||
/// <reference path="../react-router/react-router-0.13.3.d.ts" />
|
||||
/// <reference path="../object-assign/object-assign.d.ts" />
|
||||
|
||||
import { Component } from 'react';
|
||||
import { Component, ReactElement } from 'react';
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as Router from 'react-router';
|
||||
import { Route, RouterState } from 'react-router';
|
||||
import { Store, Dispatch, bindActionCreators } from 'redux';
|
||||
@@ -23,13 +25,13 @@ interface CounterState {
|
||||
declare var increment: Function;
|
||||
|
||||
class Counter extends Component<any, any> {
|
||||
render() {
|
||||
return (
|
||||
<button onClick={this.props.onIncrement}>
|
||||
{this.props.value}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<button onClick={this.props.onIncrement}>
|
||||
{this.props.value}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps(state: CounterState) {
|
||||
@@ -65,7 +67,7 @@ class App extends Component<any, any> {
|
||||
|
||||
const targetEl = document.getElementById('root');
|
||||
|
||||
React.render((
|
||||
ReactDOM.render((
|
||||
<Provider store={store}>
|
||||
{() => <App />}
|
||||
</Provider>
|
||||
@@ -100,7 +102,7 @@ declare var addTodo: () => { type: string; };
|
||||
declare var todoActionCreators: { [type: string]: (...args: any[]) => any; };
|
||||
declare var counterActionCreators: { [type: string]: (...args: any[]) => any; };
|
||||
|
||||
React.render(
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
{() => <MyRootComponent />}
|
||||
</Provider>,
|
||||
@@ -108,7 +110,7 @@ React.render(
|
||||
);
|
||||
|
||||
Router.run(routes, Router.HistoryLocation, (Handler, routerState) => { // note "routerState" here
|
||||
React.render(
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
{/*
|
||||
//TODO: error TS2339: Property 'routerState' does not exist on type 'RouteProp'.
|
||||
@@ -121,7 +123,7 @@ Router.run(routes, Router.HistoryLocation, (Handler, routerState) => { // note "
|
||||
|
||||
//TODO: for React Router 1.0
|
||||
//TODO: error TS2604: JSX element type 'Router' does not have any construct or call signatures.
|
||||
//React.render(
|
||||
//ReactDOM.render(
|
||||
// <Provider store={store}>
|
||||
// {() => <Router history={history}>...</Router>}
|
||||
// </Provider>,
|
||||
@@ -242,3 +244,37 @@ connect(mapStateToProps2, actionCreators, mergeProps)(TodoApp);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
interface TestProp {
|
||||
property1: number;
|
||||
someOtherProperty?: string;
|
||||
}
|
||||
interface TestState {
|
||||
isLoaded: boolean;
|
||||
state1: number;
|
||||
}
|
||||
class TestComponent extends Component<TestProp, TestState> { }
|
||||
const WrappedTestComponent = connect()(TestComponent);
|
||||
|
||||
// return value of the connect()(TestComponent) is of the type TestComponent
|
||||
let ATestComponent: typeof TestComponent = null;
|
||||
ATestComponent = TestComponent;
|
||||
ATestComponent = WrappedTestComponent;
|
||||
|
||||
let anElement: ReactElement<TestProp>;
|
||||
<TestComponent property1={42} />;
|
||||
<WrappedTestComponent property1={42} />;
|
||||
<ATestComponent property1={42} />;
|
||||
|
||||
class NonComponent {}
|
||||
// this doesn't compile
|
||||
//connect()(NonComponent);
|
||||
|
||||
// connect()(SomeClass) has the same constructor as SomeClass itself
|
||||
class SomeClass extends Component<any, any> {
|
||||
constructor(public foo: string) { super() }
|
||||
public bar: number;
|
||||
}
|
||||
let bar: number = new (connect()(SomeClass))("foo").bar;
|
||||
|
||||
|
||||
Vendored
+2
-1
@@ -10,8 +10,9 @@ declare module "react-redux" {
|
||||
import { Component } from 'react';
|
||||
import { Store, Dispatch, ActionCreator } from 'redux';
|
||||
|
||||
export class ElementClass extends Component<any, any> { }
|
||||
export interface ClassDecorator {
|
||||
<TFunction extends Function>(target: TFunction): TFunction|void;
|
||||
<T extends (typeof ElementClass)>(component: T): T
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user