Skip to content

Commit

Permalink
add optional response props type to render method
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuspoehls committed Jan 6, 2024
1 parent fc890a5 commit 7479f04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## [2.0.2](https://github.com/supercharge/inertia/compare/v2.0.1...v2.0.2) - 2023-xx-xx
## [2.1.0](https://github.com/supercharge/inertia/compare/v2.0.1...v2.1.0) - 2024-01-xx

### Added
- add optional response props type to render method: `response.inertia().render<ResponseProps = Record<string, unknown>>(…)`
- this is useful if you want to provide a contract between frontend and backend props

### Updates
- remove JSDoc blocks in comments because they are a duplicate of the TypeScript types
Expand Down
2 changes: 1 addition & 1 deletion src/inertia-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class InertiaResponse extends SharesData {
/**
* Render the inertia component.
*/
async render (component: string, responseProps?: Record<string, unknown>): Promise<string | Record<string, unknown> | HttpResponse> {
async render<ResponseProps = Record<string, unknown>> (component: string, responseProps?: ResponseProps): Promise<string | ResponseProps | HttpResponse> {
if (!component) {
throw new Error('Missing component name when calling "response.inertia().render(<component>)"')
}
Expand Down

0 comments on commit 7479f04

Please sign in to comment.