Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

407
Views
Importación de SVG como componente React que da un error de mecanografiado

Tema

Estaba tratando de importar SVG como ReactComponent en un archivo .tsx de la aplicación React .


Error

Cannot find module '../icons/download.svg' or its corresponding type declarations. ingrese la descripción de la imagen aquí


Formas probadas

Obtuve algunas de las formas de resolverlo y las probé.

  1. usando svg.d.ts en src/ con la configuración dada

     declare module "*.svg" { import React from "react"; export const ReactComponent: React.FunctionComponent< React.SVGProps<SVGSVGElement> & { title?: string } >; const src: string; export default src; }

y

 declare module "*.svg" { import React from "react"; const content: React.FunctionComponent<React.SVGAttributes<SVGElement>>; export default content; }

uno por uno, y lo agregó al archivo ts.config

 "include": ["./src/components", "src/svg.d.ts"]

pero ninguno de ellos funcionó



  1. creó el archivo ./src/@types/assets/index.d.ts con la configuración
 declare module "*.svg" { import React = require("react"); export const ReactComponent: React.SFC<React.SVGProps<SVGSVGElement>>; const src: string; export default src; } declare module "*.jpg" { const content: string; export default content; } declare module "*.png" { const content: string; export default content; } declare module "*.json" { const content: string; export default content; }

y lo agregó a ts.config

 "typeRoots": [ "./src/@types", "./node_modules/@types" ]

esto tampoco funcionó.

Sugiera qué estoy haciendo mal o alguna otra forma de hacerlo.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!