Zaelot-Inc / use-reducer-logger

A very basic logger for the useReducer function in the React Hooks API.
https://www.npmjs.com/package/use-reducer-logger
MIT License
94 stars 16 forks source link

Task/fix type definition #8

Closed ahilke closed 4 years ago

ahilke commented 4 years ago

The type definitions for this package throw an error:

node_modules/use-reducer-logger/index.d.ts(3,20): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

Also, the dispatch type is incorrect. I came up with an example to show case two problems here: TypeScript Playground.

It shows that calling the dispatch function without any argument is not allowed by the type, which is allowed by React. Furthermore, the returned type for dispatch is too loose and does not check the action attributes properly.

I also added a call to useReducer in the example in the README, which I think was missing.