-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: 2.4.0
Code
export interface PureAction <ACTION_TYPE> extends Redux.Action {
readonly type: ACTION_TYPE
}
export interface PayloadAction <ACTION_TYPE, PAYLOAD> extends Redux.Action {
readonly type: ACTION_TYPE
readonly payload: PAYLOAD
}
export type Action = PureAction<any> | PayloadAction<any, any>
export function createActionCreator <ACTION extends PayloadAction<ACTION['type'], ACTION['payload']>>(type: ACTION['type']): (payload: ACTION['payload']) => ACTION
export function createActionCreator <ACTION extends PureAction<ACTION['type']>>(type: ACTION['type']): () => ACTION
export function createActionCreator <ACTION extends PayloadAction<ACTION['type'], ACTION['payload']>>(type: ACTION['type']): (payload: ACTION['payload']) => ACTION {
return (payload: any) => {
if (payload == null) {
return ({
type,
} as ACTION)
}
return ({
type,
payload,
} as ACTION)
}
}
type Reducer<STATE, ACTION> = (state: STATE, action: ACTION) => STATE
/**
*
* test
*
* @export
* @class MappedReducer
* @template STATE
* @template ACTION
* @template Action
* @template ACTION_TYPE
* @template ACTION
*/
export class MappedReducer<STATE, ACTION extends Action = Action, ACTION_TYPE extends ACTION['type'] = ACTION['type']> {
}
Expected behavior:
No errors
Actual behavior:
[ts] Type '"type"' cannot be used to index type 'ACTION'.
error occurred twice on Line 41:
export class MappedReducer<STATE, ACTION extends Action = Action, ACTION_TYPE extends
ACTION['type']
=
ACTION['type']
>
It works well if I delete all comment lines with @~~
like @export
and @template
.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created