Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Randy_Johnson's avatar

Inertia Svelte - Could not find a declaration

import { createInertiaApp } from '@inertiajs/inertia-svelte'

createInertiaApp({
    resolve: name => require(`./Pages/${name}.svelte`),
    setup({ el, App, props }) {
        new App({ target: el, props })
    },
})
Could not find a declaration file for module '@inertiajs/inertia-svelte'. 'c:/Users/jdh/Documents/My Documents/Developement/laravel/Inertia/inertia-svelte/node_modules/@inertiajs/inertia-svelte/src/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/inertiajs__inertia-svelte` if it exists or add a new declaration (.d.ts) file containing `declare module '@inertiajs/inertia-svelte';`ts(7016)

I tried the first suggestion of npm i --save-dev @types/inertiajs__inertia-svelte with the return message of 404 Not Found - GET https://registry.npmjs.org/@types%2finertiajs__inertia-svelte - Not found, as well as the second suggestion to no avail.

Also when I run npm run dev no page is shown, but the browser just keep loading and return the error Unable to connect but I guess this has to do with the modules not being seen withing app.js.

Please help!

0 likes
13 replies
thinkverse's avatar

There is no TypeScript support for Inertia and Svelte currently, you will have to use regular JavaScript until support has been added. There is currently an issue opened for it.

1 like
thinkverse's avatar
Level 15

@Randy_Johnson, it has been a while since I messed with Svelte. But I believe it tries to use TypeScript if it finds a tsconfig.json file and if you're using .ts files. Might be other things that makes it think you're using TypeScript, but that's just at the top of my head.

1 like
Randy_Johnson's avatar

@Sinnbeck It looks like am going to have to use Vue, I cannot get Svelte to work at all. Even the pingcrm which I posted before form github is vue, trying the svelte require an older version of PHP which is pointless to go back too.

Gutted, really wanted to use svelte, looked dang good.

Randy_Johnson's avatar

@Sinnbeck I tried it requires an older version of php. I will just go with react since it has the best job availability.

thinkverse's avatar

@joshcirre I messed with it for fun, @randy_johnson might be interested though. 🙂 Did solve my broken header slot thanks to you though, I'm not that familiar with Svelte so I was going it wrong. 😂

Please or to participate in this conversation.