TypeScript · Senior · Question 50 of 75
What is declare module '*.svg' used for?
declare module '*.svg' {
const src: string;
export default src;
}- ✓Correct answer: To describe the import type of assets handled by the bundler
- 2To load all of the project's SVG files at runtime as one bundle
- 3To forbid importing SVG files in the project's TypeScript code
Explanation
Wildcard module declarations describe what importing bundler-handled files returns (images, CSS Modules, ?raw). Frameworks usually ship such declarations themselves (next-env.d.ts, vite/client).