-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better definition for mapDispatchToProps
- Loading branch information
Showing
6 changed files
with
49 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
import { Dispatch, AnyAction } from 'redux' | ||
import { ActionCreatorDefinition } from '..' | ||
import { AnyAction } from 'redux' | ||
import { MapDispatchToPropsFunction, MapStateToProps } from 'react-redux' | ||
|
||
export type Indexer<T = any> = { [key: string]: T } | ||
|
||
export interface StateToProps<TState = any> { | ||
<T extends { [key: string]: any } = {}, Town = {}>( | ||
map: (store: TState, own: Town) => T, | ||
): (store: TState, own: Town) => T | ||
<T extends Indexer, TOwn>( | ||
map: MapStateToProps<T, TOwn, TState>, | ||
): MapStateToProps<T, TOwn, TState> | ||
} | ||
|
||
export interface DispatchToProps< | ||
TDispatchAction extends AnyAction = AnyAction | ||
> { | ||
<T extends { [key: string]: (...params: any[]) => AnyAction }, Town>( | ||
map: T, | ||
own: Town, | ||
): (dispatch: Dispatch<TDispatchAction>, own: Town) => T | ||
export interface DispatchToProps { | ||
<T extends Indexer<(...params: any[]) => AnyAction>, TOwn>( | ||
map: T | MapDispatchToPropsFunction<T, TOwn>, | ||
): MapDispatchToPropsFunction<T, TOwn> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
const webpack = require("webpack") | ||
const nodeExternals = require("webpack-node-externals") | ||
const webpack = require('webpack') | ||
const nodeExternals = require('webpack-node-externals') | ||
|
||
module.exports = { | ||
externals: [nodeExternals()], | ||
entry: "./src/index.ts", | ||
entry: ['./src/index.ts'], | ||
resolve: { | ||
extensions: [".ts", ".tsx", ".js", ".jsx"] | ||
extensions: ['.ts', '.tsx', '.js', '.jsx'], | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
use: [ | ||
{ | ||
loader: "ts-loader", | ||
loader: 'ts-loader', | ||
options: { | ||
compilerOptions: { | ||
declaration: true, | ||
sourceMap: true | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
sourceMap: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
|
||
plugins: [ | ||
// new CopyWebpackPlugin(['./index.js']), | ||
// new webpack.DefinePlugin({ | ||
// "process.env.NODE_ENV": JSON.stringify(env) | ||
// }), | ||
// new webpack.SourceMapDevToolPlugin({ | ||
// filename: "[file].map" | ||
// }) | ||
] | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
const merge = require("webpack-merge") | ||
const common = require("./webpack.common.js") | ||
const merge = require('webpack-merge') | ||
const common = require('./webpack.common.js') | ||
|
||
module.exports = merge(common, { | ||
mode: "development", | ||
devtool: "source-map", | ||
mode: 'development', | ||
devtool: 'source-map', | ||
output: { | ||
filename: "redux-ts.js" | ||
} | ||
filename: 'redux-ts.development.js', | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters