Generated types don't match generated routes when using Vue #702
Replies: 2 comments 1 reply
-
Can you share some more complete code examples so I can debug this?
I'm not sure that's what it means—it seems like an issue with your TypeScript setup or with the generated Are you using Ziggy's NPM package? If not, did you add the |
Beta Was this translation helpful? Give feedback.
-
I have the same exact problem. I get the following error in My files are what comes from the default Laravel Breeze package. As soon as I remove the ziggy.d.ts file, the error disappears. resources/js/app.tsx import '../css/app.css';
import './bootstrap';
import { createInertiaApp } from '@inertiajs/react';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { createRoot, hydrateRoot } from 'react-dom/client';
import { Ziggy } from './ziggy.js';
globalThis.Ziggy = Ziggy;
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) =>
resolvePageComponent(
`./Pages/${name}.tsx`,
import.meta.glob('./Pages/**/*.tsx'),
),
setup({ el, App, props }) {
if (import.meta.env.SSR) {
hydrateRoot(el, <App {...props} />);
return;
}
createRoot(el).render(<App {...props} />);
},
progress: {
color: '#4B5563',
},
}); resources/js/ziggy.d.ts /* This file is generated by Ziggy. */
declare module 'ziggy-js' {
interface RouteList {
"index": [],
"pro": []
}
}
export {}; resources/js/ziggy.js const Ziggy = {"url":"https:\/\/gitbybit.com.test","port":null,"defaults":{},"routes":{"index":{"uri":"\/","methods":["GET","HEAD"]},"pro":{"uri":"pro","methods":["GET","HEAD"]}}};
if (typeof window !== 'undefined' && typeof window.Ziggy !== 'undefined') {
Object.assign(Ziggy.routes, window.Ziggy.routes);
}
export { Ziggy }; tsconfig.json {
"compilerOptions": {
"allowJs": true,
"module": "ESNext",
"moduleResolution": "bundler",
"jsx": "react-jsx",
"strict": true,
"isolatedModules": true,
"target": "ESNext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"noEmit": true,
"paths": {
"@/*": ["./resources/js/*"],
"ziggy-js": ["./vendor/tightenco/ziggy"]
}
},
"include": ["resources/js/**/*.ts", "resources/js/**/*.tsx", "resources/js/**/*.d.ts"]
} vite.config.js
|
Beta Was this translation helpful? Give feedback.
-
Ziggy version
1.8.1
Laravel version
10.39.0
Description
When you run
php artisan ziggy:generate --types
, two files are generated:resources/js/ziggy.js
, which exports theZiggy
object.resources/js/ziggy.d.ts
, which defines theRouteList
interface in theziggy-js
namespace.Now in my
app.ts
file on the line where I import Ziggy (import { Ziggy } from './ziggy';
) it saysTS2305: Module './ziggy' has no exported member Ziggy
. This is—for as far as I understand—becauseziggy.d.ts
's definitions differ from the contents ofziggy.js
.Ziggy call and context
Ziggy configuration
Route definition
Beta Was this translation helpful? Give feedback.
All reactions