Coder Social home page Coder Social logo

Comments (11)

poppa avatar poppa commented on May 20, 2024 1

Tanks for the message @coldino, very much appreciated.

In my personal opinion there are too many moving parts when it comes to a project and how TS and type-resolution etc is setup, that it feels more or less like a guessing-game getting all these things to work πŸ˜‚

Now, if anyone makes a PR with more sensible defaults, I'll be the first to merge it ☺️

from sveltekit-svg.

woss avatar woss commented on May 20, 2024 1

i created the ./src/ambient.d.ts file then added the declare stuff inside and it worked without any issues. Having it in the app.d.ts doesn't work, I confirm.

from sveltekit-svg.

poppa avatar poppa commented on May 20, 2024

I have no idea of your setup, but try giving this a try. Change the *.svg?component-typing to this:

declare module '*.svg?component' {
  const content: ConstructorOfATypedSvelteComponent
  export default content
}

Let me know if that helps?

from sveltekit-svg.

poppa avatar poppa commented on May 20, 2024

I've made a new release where I think this issue may be solved.

Feel free to re-open this issue if the problem persists.

from sveltekit-svg.

tcherokee avatar tcherokee commented on May 20, 2024

Hello,

I am having a similar issue to this. I have added

declare module '*.svg?component' {
	const content: ConstructorOfATypedSvelteComponent
	export default content
}

but I am still getting an error with it
Screenshot 2022-11-15 at 13 00 44

I am not sure what I am missing?

from sveltekit-svg.

poppa avatar poppa commented on May 20, 2024

Hi @tcherokee. Perhaps you'r on an old version of SvelteKit? Either upgrade or change the type to any.

Hope that helps.

from sveltekit-svg.

coldino avatar coldino commented on May 20, 2024

I'm not sure why, but putting the declare module '*.svg?component' section in app.d.ts isn't working for me as I still get Cannot find module with an import like $lib/images/dev.svg?component. I have other things in the app.d.ts that DO work as expected - for example a session added to App.Locals.

Experimenting a little, I found putting it in a .d.ts beside the .svelte file works. In my case this is my global +layout.svelte and the declaration works if it lives in +layout.d.ts.

Of course this is unlikely to be caused by an issue in this library, but does anyone know the cause, and do the docs here need to be updated?

from sveltekit-svg.

miguelcobain avatar miguelcobain commented on May 20, 2024

Also looking for solutions. @coldino your workaround does work, indeed.

from sveltekit-svg.

Porter-smith avatar Porter-smith commented on May 20, 2024

i installed with bun add --dev @poppanator/sveltekit-svg and got this issue. I think maybe bun doesn't add the typing (idk). I just added the type to app.d.tsand that worked for me

declare module '*.svg?component' {
  const content: ConstructorOfATypedSvelteComponent
  export default content
}

from sveltekit-svg.

poppa avatar poppa commented on May 20, 2024

i installed with bun add --dev @poppanator/sveltekit-svg and got this issue. I think maybe bun doesn't add the typing (idk). I just added the type to app.d.tsand that worked for me

declare module '*.svg?component' {
  const content: ConstructorOfATypedSvelteComponent
  export default content
}

@Porter-smith Did you try this? https://github.com/poppa/sveltekit-svg/#typescript

from sveltekit-svg.

Porter-smith avatar Porter-smith commented on May 20, 2024

Oh I see ! I didn't realize it had that thank you !

from sveltekit-svg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.