Using SVGs in TS files
Answered
American Crocodile posted this in #help-forum
American CrocodileOP
I'm trying to use some SVGs in a page in appDir, but I get a TS error for my SVGs
The SVGs are just pure SVG files that I export from a index.ts file. I use them with Next Image like this
I know the SVG exists, but I have no idea how to type them. Do I have to write type definitions everywhere I use these SVGs? And what would those definitions be?
I've enabled SVGs for <Image>, from my next.config.js
Using NextJS 13.4.9
32:18 Error: Unsafe assignment of ananyvalue. @typescript-eslint/no-unsafe-assignmentThe SVGs are just pure SVG files that I export from a index.ts file. I use them with Next Image like this
import { ArrowRight } from "@/icons/index";
...
<Image
src={ArrowRight}
height={25}
width={25}
alt=""
/>
...I know the SVG exists, but I have no idea how to type them. Do I have to write type definitions everywhere I use these SVGs? And what would those definitions be?
I've enabled SVGs for <Image>, from my next.config.js
dangerouslyAllowSVG: true,
contentDispositionType: 'attachment',
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",Using NextJS 13.4.9
2 Replies
American CrocodileOP
It seems like I can use svgr, but it also seems like svgr is dependent on Webpack. I'd much prefer to stick with things that allow me to upgrade to turbopack down the road
@American Crocodile It seems like I can use svgr, but it also seems like svgr is dependent on Webpack. I'd much prefer to stick with things that allow me to upgrade to turbopack down the road
Masai Lion
its a question, why don't you do like this <ArrowRight />
Answer