mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types for redux-cablecar (#38944)
* Add types for redux-cablecar * Make payload for the perform function optional
This commit is contained in:
parent
84d4755cb5
commit
4c52cecef4
30
types/redux-cablecar/index.d.ts
vendored
Normal file
30
types/redux-cablecar/index.d.ts
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
// Type definitions for redux-cablecar 3.0
|
||||
// Project: https://github.com/ndhays/redux-cablecar#readme
|
||||
// Definitions by: Christoph Flick <https://github.com/ChFlick>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
import { Action, Middleware, Store } from 'redux';
|
||||
|
||||
export interface Options {
|
||||
connected?: () => void;
|
||||
disconnected?: () => void;
|
||||
params?: object;
|
||||
prefix?: string;
|
||||
optimisticOnFail?: boolean;
|
||||
}
|
||||
|
||||
export interface CableCar {
|
||||
changeChannel: (channel: string, options?: Options) => void;
|
||||
getChannel: () => string;
|
||||
getParams: () => object;
|
||||
perform: (method: string, payload?: any) => void;
|
||||
send: (action: string) => void;
|
||||
}
|
||||
|
||||
declare var middleware: Middleware & {
|
||||
connect: (store: Store, channel: string, options?: Options) => CableCar;
|
||||
setProvider: (actionCableProvider: string) => void;
|
||||
};
|
||||
|
||||
export default middleware;
|
||||
6
types/redux-cablecar/package.json
Normal file
6
types/redux-cablecar/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"redux": "^4.0.4"
|
||||
}
|
||||
}
|
||||
18
types/redux-cablecar/redux-cablecar-tests.ts
Normal file
18
types/redux-cablecar/redux-cablecar-tests.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import cablecar, { Options } from 'redux-cablecar';
|
||||
import { applyMiddleware, createStore } from 'redux';
|
||||
|
||||
const store = createStore(() => null, applyMiddleware(cablecar));
|
||||
|
||||
cablecar.setProvider('testProvider');
|
||||
|
||||
const car = cablecar.connect(store, 'testChannel');
|
||||
|
||||
const options: Options = {
|
||||
connected: () => { },
|
||||
prefix: 'ASDF'
|
||||
};
|
||||
|
||||
const anotherCar = cablecar.connect(store, 'secondeTestChannel', options);
|
||||
|
||||
car.perform('activate', { data: 'something' });
|
||||
anotherCar.send('noice_action');
|
||||
23
types/redux-cablecar/tsconfig.json
Normal file
23
types/redux-cablecar/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"redux-cablecar-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/redux-cablecar/tslint.json
Normal file
1
types/redux-cablecar/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user