Comments (11)
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.
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.
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.
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.
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
I am not sure what I am missing?
from sveltekit-svg.
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.
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.
Also looking for solutions. @coldino your workaround does work, indeed.
from sveltekit-svg.
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.ts
and that worked for me
declare module '*.svg?component' {
const content: ConstructorOfATypedSvelteComponent
export default content
}
from sveltekit-svg.
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 toapp.d.ts
and that worked for medeclare 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.
Oh I see ! I didn't realize it had that thank you !
from sveltekit-svg.
Related Issues (20)
- Use events on components HOT 3
- Modify the SVG doesn't hot reload HOT 2
- SSR true HOT 7
- Support alternative datauri encodings HOT 2
- Error: <Btn_Next> is not a valid SSR component. HOT 18
- Svelte 4 support HOT 1
- Import SVG component dynamically based on input that the component is getting HOT 2
- Using SVG as component is giving me an error? HOT 4
- Render the contents of the `<svg>` tag using `{@html}` in the component mode HOT 6
- Add a hook to allow plugin users to modify the resulting component HOT 3
- `Error: Cannot find module 'svgo'` HOT 4
- Simplify library usage for common usage HOT 7
- Sourcemap issues HOT 6
- Get SVGSVGElement from generated component HOT 2
- Not a valid SSR component HOT 2
- PSA: css selectors that target an imported `.svg` are considered `unused` and are pruned HOT 1
- `?url` + SVGO? HOT 11
- Svelte 5 Support HOT 8
- Error: Cannot find module '@rollup/pluginutils' HOT 6
- Fails to compile in Svelte 5: "Invalid compiler option: css: "none" is no longer a valid option" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sveltekit-svg.