Created
December 19, 2022 07:00
-
-
Save isimmons/e718f344a8c0ba5e858f2d0a6ddce10c to your computer and use it in GitHub Desktop.
TS module declarations for css and images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// react specific css modules | |
declare module '*.module.css' { | |
const content: Record<string, string>; | |
export default content; | |
} | |
// react specific for direct svg import | |
declare module '*.svg' { | |
import React = require('react'); | |
export const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>; | |
const src: string; | |
export default src; | |
} | |
// these should work regardless of framework | |
declare module '*.jpg' { | |
const path: string; | |
export default path; | |
} | |
declare module '*.jpeg' { | |
const path: string; | |
export default path; | |
} | |
declare module '*.gif' { | |
const path: string; | |
export default path; | |
} | |
declare module '*.png' { | |
const path: string; | |
export default path; | |
} | |
declare module '*.webp' { | |
const path: string; | |
export default path; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I need to add more as I learn for React, Vue, and plain ole Typescript projects