Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
-
Adding the vendor alias produces the following result:
Changing the import to
Neither method works in TypeScript, there is no The workaround I ended up using was to just write the ZiggyVue plugin in a TypeScript module as so: import type { App } from 'vue'
import route from 'ziggy-js'
import './ziggy'
type Options = Exclude<Parameters<typeof route>[3], undefined>
const ziggyPlugin = {
install: (app: App, options?: Options | undefined) => {
const wrapper = (...parameters: Parameters<typeof route>) => {
const [name, params, absolute, config = options] = parameters
return route(name, params, absolute, config)
}
app.mixin({
methods: {
route: wrapper
}
})
if (Number.parseInt(app.version) > 2) {
app.provide('route', wrapper)
}
app.config.globalProperties.$route = route
app.config.globalProperties.route = route
}
}
declare module 'vue' {
interface ComponentCustomProperties {
route: typeof route
$route: typeof route
}
}
export default ziggyPlugin |
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.
-
Ziggy version
1.8.1
Laravel version
10.41.0
Description
After install Ziggy's Composer and NPM package, everything seems to be resolvable by TypeScript except for ZiggyVue.
Additional info
vite.config.ts
tsconfig.json
Note: Adding the path alias to the composer version breaks things further since it can't seem to find the
index.d.ts
file of that package. A similar issue exists attempting toimport { Ziggy } from './ziggy'
Ziggy call and context
N/A, unable to build front-end code.
Ziggy configuration
N/A, unable to build front-end code.
Route definition
N/A, unable to build front-end code.
Beta Was this translation helpful? Give feedback.
All reactions