This package is a replacement for superjson to use in your Remix app. It handles a subset of types that `superjson` supports, but is faster and smaller.
MIT License
435
stars
19
forks
source link
Is it possible to have data parameter typed in meta function export? #6
Firstly, thank you for the awesome library and for bringing end-to-end type safety to Remix.
I have a problem that is specific to the exported meta function from a route.
Have a posts/$slug route which has a loader which exports few posts and rendered markdown in html format. With remix-typedjson it looks something like this:
export const loader = async ({ params }: LoaderArgs) => {
invariant(params.slug, "params.slug is required")
const post = await getPost(params.slug)
invariant(post, `Post not found: ${params.slug}`)
const html = marked(post.markdown)
return typedjson({
post,
html,
})
}
But when I want to access the returned data in the meta function to add a title for my page, I obviously don't get the types as MetaFunction by default has data set to any:
Firstly, thank you for the awesome library and for bringing end-to-end type safety to Remix.
I have a problem that is specific to the exported
meta
function from a route.Have a
posts/$slug
route which has aloader
which exports few posts and rendered markdown in html format. Withremix-typedjson
it looks something like this:But when I want to access the returned data in the
meta
function to add a title for my page, I obviously don't get the types asMetaFunction
by default hasdata
set toany
:Is it possible to type
data
returned fromloader
in themeta
function?