sveltefire icon indicating copy to clipboard operation
sveltefire copied to clipboard

svelte with typescript. cannot find moudle

Open shriharip opened this issue 4 years ago • 6 comments

Hi Jeff,

Svelte typescript with lang="ts". I get the "Cannot find module 'sveltefire' or its corresponding type declarations."

thanks

shriharip avatar Jul 23 '20 13:07 shriharip

The next release will have better support for TypeScript, but currently you can solve this issue by creating a file named main.d.ts with this line:

declare module 'sveltefire';

codediodeio avatar Jul 31 '20 22:07 codediodeio

Oh of course. Thanks. Forgot about that.

shriharip avatar Aug 01 '20 07:08 shriharip

The main.d.ts does not seem to get picked up by svelte-check? 🤔 And inline data binds don't work. let:data={myItem} yields the following error:Property 'key' does not exist on type 'unknown'.ts(2339). Any way to work around this?

guidobouman avatar Nov 28 '20 10:11 guidobouman

@guidobouman could you share your file organization? We have just been struggling with the same issue but have solved it also with a xyz.d.ts file in the code source.

@deemetree-at-satelligence https://github.com/Q42/hack-for-good/tree/main/web

The Svelte project sits in a web folder. The main.d.ts file is next to the main.ts file.

A run of npm run validate gives a lot of errors. This includes Error: Cannot find module 'sveltefire' or its corresponding type declarations. (ts), which declare module 'sveltefire'; should solve, right?

guidobouman avatar Dec 07 '20 13:12 guidobouman

For beginners in typescript that are using sveltekit I'd just like to add that you can also add that declare module 'sveltefire'; to your src/global.d.ts file to make the warning go away for now.

cupofjoakim avatar Sep 11 '21 11:09 cupofjoakim