-
-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
enhancementNew feature or requestNew feature or requestinvestigateNot sure about somethingNot sure about something
Description
Is it possible to infer
the types returned form inertia.render()
. This would be a huge value proposition I think for inertia with adonis.
As a quick example say I have a controller like so
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
export default class FooController {
public async index({ inertia }: HttpContextContract) {
return inertia.render('Foo', {
title: "This is the title",
})
}
}
With React and Typescript I currently do something like this
interface FooPageProps {
title: string
}
const FooPage = ({ title }: FooPageProps) => {
return <div>{title}</div>
}
The problem here is that we aren't really getting good types because we are basically just telling the component what it has not what it will actually receive. It would be extremely valuable to do something like the following
const FooPage = ({ title }: InertiaResponse<FooController['show']>) => {
return <div>{title}</div>
}
I am not a Typescript expert but I really wonder if this could be possible using some combination of ReturnType
and infer
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestinvestigateNot sure about somethingNot sure about something