Typescript bug when using with vue-final-modal
#2702
Replies: 10 comments 1 reply
-
|
Wait, could it be related to the import order ? :O This works: import { createVfm } from 'vue-final-modal';
import { createInertiaApp } from '@inertiajs/vue3';This gives error: import { createInertiaApp } from '@inertiajs/vue3';
import { createVfm } from 'vue-final-modal';But ESLint / Prettier are sorting the import in alphabetical order or something... |
Beta Was this translation helpful? Give feedback.
-
|
You can fin a reproduction inside the linked issue |
Beta Was this translation helpful? Give feedback.
-
|
Isn't there a problem with declaring the |
Beta Was this translation helpful? Give feedback.
-
|
@pascalbaljet What do you mean ? It should merge them, not overwrite them, no ? |
Beta Was this translation helpful? Give feedback.
-
|
@pascalbaljet The The starter-kit has changed a little since I started this project, so here are the direct link to the files: |
Beta Was this translation helpful? Give feedback.
-
In the example in your first post, you have two blocks of: declare module 'vue' {
interface ComponentCustomProperties {
}
}Maybe you should just merge them and use the import type { Vfm } from 'vue-final-modal'
declare module 'vue' {
interface ComponentCustomProperties {
$inertia: typeof Router;
$page: Page;
$headManager: ReturnType<typeof createHeadManager>;
route: typeof route;
$vfm: Vfm;
}
} |
Beta Was this translation helpful? Give feedback.
-
|
Ok, let's recap. The first The third |
Beta Was this translation helpful? Give feedback.
-
|
I meant merging in your project in |
Beta Was this translation helpful? Give feedback.
-
|
Again, that's not a real fix, just a workaround. There is clearly a bug with Inertia.js or vue-final-modal (or even TypeScript 🤔). |
Beta Was this translation helpful? Give feedback.
-
|
Looking at the Vue documentation, Inertia's TypeScript module augmentation implementation seems correct. I've also tried the laravel-vue-i18n library (which has similar type declarations) in combination with Laravel's Vue Starter Kit and that seems to work fine. Looks like a TypeScript/Vue issue (maybe with the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
@inertiajs/vue3 Version
2.2.15
Backend stack (optional)
Laravel v12.31.1
PHP 8.2
Describe the problem
Hey,
I'm not sure if the issue is with Vue-final-modal or Inertia.js, but I've already opened an issue in the vue-final-modal repo (vue-final/vue-final-modal#472).
I'm observing a very strange behavior with Types when I import
vue-final-modalinside an Inertia.js app (using Vue.js). As soon as I import anything fromvue-final-modal, some global types seem to stop working.For example, in Inertia you can access
$page,$inertiaandroute()globally in the templates, but withvue-final-modalimported I get errors in VS Code.If I remove any vue-final-modal imports, everything is back to normal:
Here are the types, pretty much unchanged from the Laravel https://github.com/laravel/vue-starter-kit, which is what their CLI use to scafold a new Inertia.js (using Vue.js) project.
Steps to reproduce
Add
import { createVfm } from 'vue-final-modal'at the end of the import list insideapp.tsSee: vue-final/vue-final-modal#472
Beta Was this translation helpful? Give feedback.
All reactions