Replies: 3 comments 2 replies
-
Hi, are you figuring out a solution, any share is helpful. |
Beta Was this translation helpful? Give feedback.
-
This worked for me. Not sure it's the optimal way but it's simple and it works. First install the ziggy types: yarn add -D @types/ziggy-js
# or
npm install -D @types/ziggy-js Then in Then paste this into the created file: import ziggyRouteFunction from "@types/ziggy-js";
// Defines the function in all TS files and the script tags in Vue SFC.
declare global {
const route: typeof ziggyRouteFunction;
}
// Defines the function in your vue templates.
// You can simply remove this if you are not using vue.
declare module "@vue/runtime-core" {
interface ComponentCustomProperties {
route: typeof ziggyRouteFunction;
}
} |
Beta Was this translation helpful? Give feedback.
-
This worked for me in PHPStorm with Laravel+Breeze+Vue. I created a global.d.ts file with the following: // default is already an alias, so this is an alias
import routeFunc from '../../vendor/tightenco/ziggy/src/js/index.d';
// Defines the function in all TS files and the script tags in Vue SFC.
declare global {
const route: typeof routeFunc ;
}
// Defines the function in your vue templates.
// You can simply remove this if you are not using vue.
declare module "@vue/runtime-core" {
interface ComponentCustomProperties {
route: typeof routeFunc
}
} |
Beta Was this translation helpful? Give feedback.
-
I would really love to know what the proper/nice way is, to add the global
route()
helper to Typescript. I don't want to install/import fromziggy-js
, but rather use the global object and not get Typescript errors. Has anyone ever done that?Beta Was this translation helpful? Give feedback.
All reactions