#Import svg
36 messages · Page 1 of 1 (latest)
!hb declarations
wait no
!hb module declarations
ah
!hb wildcard module
unfortunate
How modules work in TypeScript
I don't inderstand
you can make a file like this one:
(ignore the rest of the repository, it's just a project I collaborate on)
in that file the *.inline.svg module declares that all files ending with .inline.svg will export a component as the default export, and the *.svg module declares that all files ending with just .svg will return a string as default export.
in your case it should probably be like this instead:
declare module "*.svg" {
import { ComponentType } from "react"
export const ReactComponent: ComponentType
}
this is an ambient declaration so you just need to place it in a location in your project folder where it gets picked up by the include config in your tsconfig
@sinful cove
oh weird
wait where are docs for the namedExport option?
@dusty saffron
Yes
I can load svg from tsc but not from esbuild, when creating bundle
Maybe It's better to delete Reactcomponent ?
is there a reason the default export wouldn't work for you?
Because if using the default export works just as well I wouldn't bother dealing with this clearly poorly supported namedExport feature