[3.x] Include SharedPageProps in createInertiaApp and event types#2956
Merged
Conversation
…types (#2931) * fix: include SharedPageProps in createInertiaApp and onSuccess types When users augment InertiaConfig with custom sharedPageProps, those types were not reflected in two key places: 1. The setup function's props.initialPage in createInertiaApp - the generic defaulted to plain PageProps, losing the augmented types. 2. The onSuccess callback's page parameter in ClientSideVisitOptions used an unparameterized Page type, so page.props had no awareness of shared props. This updates the default generic parameter for createInertiaApp in all three framework adapters (Vue 3, React, Svelte) from PageProps to PageProps & SharedPageProps. It also parameterizes the Page type in the onSuccess callback with SharedPageProps. Fixes #2925 * Fix code style * Tests * Update TypeScriptCreateInertiaApp.ts * wip --------- Co-authored-by: Pascal Baljet <pascal@pascalbaljet.nl>
* Use SharedPageProps in GlobalEventsMap event types The `beforeUpdate`, `navigate`, and `success` events in `GlobalEventsMap` use bare `Page` instead of `Page<SharedPageProps>`, which means augmented shared props are not available when listening to these global events. This updates those event type definitions to use `Page<SharedPageProps>` so that users who augment `SharedPageProps` via declaration merging get proper type inference in their event callbacks. Fixes #2925 Fixes #2930 * Added tests --------- Co-authored-by: Pascal Baljet <pascal@pascalbaljet.nl>
* Use SharedPageProps in GlobalEventsMap event types The `beforeUpdate`, `navigate`, and `success` events in `GlobalEventsMap` use bare `Page` instead of `Page<SharedPageProps>`, which means augmented shared props are not available when listening to these global events. This updates those event type definitions to use `Page<SharedPageProps>` so that users who augment `SharedPageProps` via declaration merging get proper type inference in their event callbacks. Fixes #2925 Fixes #2930 * Added tests --------- Co-authored-by: Pascal Baljet <pascal@pascalbaljet.nl>
…tiajs/inertia into 3.x-shared-page-props-types
…tiajs/inertia into 3.x-shared-page-props-types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #2931 and #2946 to the 3.x branch.