Home > Mobile >  Typescript errors when using a suffix (?raw, ?url etc
Typescript errors when using a suffix (?raw, ?url etc

Time:01-13

I get a typescript error in my vite project when I try to import an SVG with a suffix (?component). How can I configure typescript to ignore these suffixes?

TS2307: Cannot find module './desktop-mark.svg?component' or its corresponding type declarations.

import DesktopLogoMark from './desktop-mark.svg?component';

CodePudding user response:

You need to add module declaration: https://www.typescriptlang.org/docs/handbook/modules.html#wildcard-module-declarations

  •  Tags:  
  • Related