Skip to content

Commit 3b1315c

Browse files
committed
feat(types): add InertiaPage type helper
1 parent 3024d46 commit 3b1315c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

adonis-typings/inertia.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ declare module '@ioc:EidelLev/Inertia' {
33
import { ResponseContract } from '@ioc:Adonis/Core/Response';
44

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

89
/**
910
* Shared data types
@@ -31,7 +32,7 @@ declare module '@ioc:EidelLev/Inertia' {
3132
* @param {string} component Page component
3233
* @param {ResponseProps} responseProps Props
3334
*/
34-
render(component: string, responseProps?: ResponseProps, pageOnlyProps?: ResponseProps): RenderResponse;
35+
render<T extends ResponseProps>(component: string, responseProps?: T, pageOnlyProps?: ResponseProps): RenderResponse<T>;
3536

3637
/**
3738
* Redirect back with the correct HTTP status code

0 commit comments

Comments
 (0)