question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`UseDataFunctionReturn<T>` omits properties of `T` defined as `never`

See original GitHub issue

What version of Remix are you using?

1.6.5

Steps to Reproduce

I’ve put together a minimal reproduction case available here: https://codesandbox.io/s/heuristic-shockley-t1ks84?file=%2Fapp%2Froutes%2Findex.tsx

Expected Behavior

The useActionData<ActionData>() hook should contain all of the properties typed in ActionData

Actual Behavior

The useActionData<ActionData>() hook doesn’t have the properties typed as never in ActionData

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
kilimancommented, Jul 20, 2022

@rossipedia here’s wrapper function to get typed fetchers

type TypedFetcherWithComponents<T> = Omit<FetcherWithComponents<T>, "data"> & {
  data: UseDataFunctionReturn<T> | null;
};
export function useTypedFetcher<T>(): TypedFetcherWithComponents<T> {
  return useFetcher<T>() as TypedFetcherWithComponents<T>;
}
image
1reaction
kilimancommented, Jul 20, 2022

Not sure. But note: to get the Date type, you have to use the superjson helper. Otherwise, you’ll get the JSON serialized type. So in that screenshot, it will be today: string if you’re using standard json on v1.6.5+

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found