Skip to content

Commit

Permalink
feat(types): add InertiaPage type helper
Browse files Browse the repository at this point in the history
  • Loading branch information
codytooker committed Mar 6, 2023
1 parent 3024d46 commit 3b1315c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions adonis-typings/inertia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ declare module '@ioc:EidelLev/Inertia' {
import { ResponseContract } from '@ioc:Adonis/Core/Response';

export type ResponseProps = Record<string, unknown>;
export type RenderResponse = Promise<Record<string, unknown> | string | ResponseContract>;
export type RenderResponse<T extends ResponseProps> = Promise<T | string | ResponseContract>;
export type InertiaPage<T extends (...args: any) => any> = Exclude<Awaited<ReturnType<T>>, string | ResponseContract>;

/**
* Shared data types
Expand Down Expand Up @@ -31,7 +32,7 @@ declare module '@ioc:EidelLev/Inertia' {
* @param {string} component Page component
* @param {ResponseProps} responseProps Props
*/
render(component: string, responseProps?: ResponseProps, pageOnlyProps?: ResponseProps): RenderResponse;
render<T extends ResponseProps>(component: string, responseProps?: T, pageOnlyProps?: ResponseProps): RenderResponse<T>;

/**
* Redirect back with the correct HTTP status code
Expand Down

0 comments on commit 3b1315c

Please sign in to comment.