-
-
Notifications
You must be signed in to change notification settings - Fork 421
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
Adding typescript gives a error with resolvePageComponent #1372
Comments
You can cast the import { createApp, h, DefineComponent } from "vue"
import { createInertiaApp } from "@inertiajs/vue3"
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers"
createInertiaApp({
resolve: (name: string) =>
resolvePageComponent(
`./Pages/${name}.vue`,
import.meta.glob("./Pages/**/*.vue")
) as Promise<DefineComponent>,
}) |
Thanks, I'll try it out. Would be nice to add a section about typescript in the inertia docs and examples😀 And since vite is the default in laravel now, it would also be good to have some examples with that setup |
Would be nice if the return type for That being said, adding the |
I'm not sure what we can do with the return type of An alternative might be to do something like this (untested): import { createApp, h, DefineComponent } from "vue"
import { createInertiaApp } from "@inertiajs/vue3"
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers"
createInertiaApp({
resolve: (name: string) =>
resolvePageComponent(
`./Pages/${name}.vue`,
import.meta.glob("./Pages/**/*.vue") as Record<string, () => Promise<DefineComponent>>
),
}) Assuming this works, the benefit is that it casts the |
@jessarcher import { createApp, h, DefineComponent } from "vue"
import { createInertiaApp } from "@inertiajs/vue3"
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers"
createInertiaApp({
resolve: (name: string) =>
resolvePageComponent(
`./Pages/${name}.vue`,
import.meta.glob<DefineComponent>("./Pages/**/*.vue")
)
}) |
Hey! Thanks so much for your interest in Inertia.js and for sharing this issue/suggestion. In an attempt to get on top of the issues and pull requests on this project I am going through all the older issues and PRs and closing them, as there's a decent chance that they have since been resolved or are simply not relevant any longer. My hope is that with a "clean slate" me and the other project maintainers will be able to better keep on top of issues and PRs moving forward. Of course there's a chance that this issue is still relevant, and if that's the case feel free to simply submit a new issue. The only thing I ask is that you please include a super minimal reproduction of the issue as a Git repo. This makes it much easier for us to reproduce things on our end and ultimately fix it. Really not trying to be dismissive here, I just need to find a way to get this project back into a state that I am able to maintain it. Hope that makes sense! ❤️ |
Version:
@inertiajs/vue3
version: 0.6.0Describe the problem:
I started a fresh project today with the latest laravel. Installed Inertia via npm and set up app.js. When I added typescript I get this red squigly error in app.ts. The app works though.
My tsconfig.json file looks like this
{ "compilerOptions": { "target": "ESNext", "useDefineForClassFields": true, "module": "ESNext", "moduleResolution": "node", "strict": true, "jsx": "preserve", "sourceMap": true, "resolveJsonModule": true, "isolatedModules": true, "esModuleInterop": true, "lib": ["ESNext", "DOM"], "skipLibCheck": true, "allowJs": true, "paths": { "@/*": ["./resources/js/*"] }, "types": [ "vite/client", ], }, "include": [ "resources/js/**/*.ts", "resources/js/**/*.tsx", "resources/js/**/*.d.ts", "resources/js/**/*.vue", ] }
Steps to reproduce:
Start a new project with Laravel + Vue + Vite + Typescript
The text was updated successfully, but these errors were encountered: