Open webdevnerdstuff opened 8 months ago
Don't think this is an issue with Inertia, as Inertia does have the correct types. The issue is the glob call you're using, since it doesn't have any type, I guess Vite/TS basically doesn't know what is supposed to be imported. IIRC you'd add a generic to the glob import, something like import.meta.glob<DefineComponent>('./Pages/**/*.vue')
I already put the solution in my initial post.
The issue is that straight out of the box, users are going to get this error which will require spending time looking into what is wrong. I personally had this error quite a while ago, but didn't find a solution initially so made a note to come back to it later in the hopes Inertia would add some kind of typescript documentation on their site, or finding it buried into the Issues here. A package/product should start with no errors on a clean project, not require spending time problem solving something with an easy solution to implement (update the docs).
Again this is something that could be easily solved without code changes by having this in the documentation. which from the looks of it hasn't been updated in quite a while. When a large backend like Laravel is pushing it, the documentation should get at least a little bit of attention when it comes to typescript.
The reason for that TS error are the incorrect types which the above PR fixes.
Version:
@inertiajs/vue3
version: 1.0.14Describe the problem:
Typescript errors on createInertiaApp resolve.
Steps to reproduce:
This will replicate in a new app (ex pnpm create vite).
createInertiaApp({ resolve: name => { const pages = import.meta.glob('./Pages/*/.vue', { eager: true }); return pages[;
},
setup({ el, App, props, plugin }) {
createApp({ render: () => h(App, props) })
.use(plugin)
.mount(el);
},
});
./Pages/${name}.vue
] as Promise