Skip to content

Commit 165e911

Browse files
committed
Adjust Type Definition
Fix several problems with the type definition: 1. Initializing a `const` in a type declaration is not allowed and results in the error "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.ts(1254)". 2. The returned reducer had no strongly typed dispatch, losing type-safety. 3. The returned reducer did not accept dispatch without any action, which is a supported use case.
1 parent 0073544 commit 165e911

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module "use-reducer-logger" {
22
type Reducer<State = any, Action = any> = (state: State, action: Action) => State;
3-
const logger = <State>(reducer: Reducer<State, Action>): Reducer<State, Action> => Reducer;
4-
export default logger
3+
const logger: <R extends Reducer>(reducer: R) => R;
4+
export default logger;
55
}

0 commit comments

Comments
 (0)