Skip to content

Improve type checking of request data #1537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

7nohe
Copy link

@7nohe 7nohe commented Apr 28, 2023

I implemented the feature of #1536.

import { router } from '@inertiajs/vue3'
type RequestData = { message: string }
const onClick = () => {
  router.post<RequestData>(url, { title: 'hello' }, options) // <- TypeScript Error
  router.post<RequestData>(url, { message: 'hello' }, options) // <- OK
}

In this PR, I have added improved type checking for request data.
The code snippet above demonstrates how the new feature works.
When posting data with an incorrect property, such as { title: 'hello' }, it will result in a TypeScript error.

@joetannenbaum joetannenbaum changed the base branch from master to v1 October 9, 2024 15:24
@joetannenbaum
Copy link
Contributor

Closing this as we're not adding any new features or non-emergency fixes for 1.x. But I do like this a lot, so I ported it over for 2.x here with credit to you, thank you!

#2304

@7nohe 7nohe deleted the improve-type-checking-of-request-data branch April 11, 2025 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants