Add type definitions for react-redux-epic (#23823)

* Add type definitions for react-redux-epic

* Require TS 2.6

* Add package.json

* Trigger CI

* Address feedback

* Add tests

* Remove unnecessary type paramerters

* Fix lint issues

* Re-add generics
This commit is contained in:
Muhammad Fawwaz Orabi 2018-02-26 21:41:38 +02:00 committed by Andy
parent bf37dfddd2
commit 317dfc327a
6 changed files with 82 additions and 0 deletions

7
types/react-redux-epic/client.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
import * as React from 'react';
import { Observable } from 'rxjs/Observable';
export function render(
element: React.ReactElement<any>,
container: Element
): Observable<undefined>;

22
types/react-redux-epic/index.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
// Type definitions for react-redux-epic 1.1
// Project: https://github.com/BerkeleyTrue/react-redux-epic#readme
// Definitions by: forabi <https://github.com/forabi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
import * as React from 'react';
import { Observable } from 'rxjs/Observable';
import { Epic } from 'redux-observable';
export interface Action {
type: string;
}
export function wrapRootEpic<T, S, D, O extends T>(
epic: Epic<T, S, D, O>
): Epic<T, S, D, O>;
export function renderToString(
element: React.ReactElement<any>,
wrappedEpic: Epic<any, any>
): Observable<{ markup: string }>;

View File

@ -0,0 +1,7 @@
{
"private": true,
"dependencies": {
"rxjs": "^5.5.5",
"redux-observable": "^0.18.0"
}
}

View File

@ -0,0 +1,26 @@
import * as React from 'react';
import { Epic } from 'redux-observable';
import { renderToString, wrapRootEpic } from 'react-redux-epic';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/ignoreElements';
interface Action {
type: string;
payload: any;
}
const rootEpic: Epic<Action, {}> = action$ => {
return action$
.do(action => {
// Action dispatched
})
.ignoreElements();
};
const wrappedRootEpic = wrapRootEpic(rootEpic);
renderToString(<div>Hello, world</div>, wrappedRootEpic).subscribe({
next({ markup }) {
// Done
}
});

View File

@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"jsx": "React",
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "client.d.ts", "react-redux-epic-tests.tsx"]
}

View File

@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}