You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library clearly supports TypeScript, because I see types mentioned in the commit messages, eg.
fix(types): move types to optional peer dependencies
However, the word "type" doesn't even appear in your documentation or readme file. To be fair, types don't exactly require a ton of docs, but it'd be nice to at least mention how they're supposed to be used.
For instance:
// Error: Property 'foo' does not exist on type 'RenderHookResult<MyHook<object>, unknown>'.ts
const { foo } = renderHook(hook);
// Error: Expected 2-5 type arguments, but got 1.ts(2558)
const { foo } = renderHook<{ foo: any }>(hook);
So it seems renderHooks expects 2-5 type arguments ... surely you could spare a few lines in the docs to tell us what those arguments should be?
The text was updated successfully, but these errors were encountered:
the TProps, which appears to be the type of the arguments of the hook function being tests?
As a side note: that variable name might confuse some folks, as "props" are a component-only thing; the React folks just call hook arguments "parameters" (eg. see https://react.dev/reference/react/useState)
the TResult, which appears to be the type of what the hook being tested returns?
Even a single line of documentation:
This function takes two type parameters, the type of the hook's input and the type of its output.
would help clarify things.
(Also, the error message above mentioned "2-5" type arguments ... maybe another sentence could cover what those args are?)
It also takes a third TRenderer (although I'm unclear on what this is), so that (sort of) explains the 3rd type parameter (I'm still unclear on #4/#5).
This project is (probably) not going to be worked on further as evidences by the entire year of inactivity and README comments, and I don't think it's particularly useful (nor common amongst ts libs in my experience) to provide type documentation when typescript itself provides the self-documentation, if not your IDE.
For example, with the right LSP/tsserver setup, your IDE will likely tell you/fail compilation instantly as renderHook does not return your hook's return value outright, instead surfacing that at .result.current, as the docs & static types point out. Therefore, .foo cannot be accessed and your IDE should tell you as much (same goes for the <{foo: any}> type arg you wrote).
This library clearly supports TypeScript, because I see types mentioned in the commit messages, eg.
However, the word "type" doesn't even appear in your documentation or readme file. To be fair, types don't exactly require a ton of docs, but it'd be nice to at least mention how they're supposed to be used.
For instance:
So it seems renderHooks expects 2-5 type arguments ... surely you could spare a few lines in the docs to tell us what those arguments should be?
The text was updated successfully, but these errors were encountered: