Believe in the power of hope to assist others.
After attempting all the outlined steps diligently, it is crucial to note that the creation of a custom.d.ts file within the designated SVG import folder is essential.
Here is an excerpt from the ts config file:
{
"compilerOptions": {
"target": "ES6",
"jsx": "react",
"module": "ESNext",
"moduleResolution": "Node",
"baseUrl": "./",
"paths": {
"@components/*": ["src/components/*"],
"@styles/*": ["src/styles/*"],
"@static/*": ["src/static/*"]
},
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"isolatedModules": true
},
"include": ["src/**/*", "src/static/optional.d.ts"],
"exclude": ["node_modules", "build"]
}
Include this code snippet in your optional.d.ts file:
declare module '*.svg' {
import * as React from 'react';
export const ReactComponent: React.FunctionComponent<
React.SVGProps<
SVGSVGElement
> & { title?: string }>;
const src: string;
export default src;
}
Lastly, here's the consolidated export file for convenience:
import Logo from './images/logo.svg';
import BellDot from './images/bell-dot.svg';
import Logout from './images/logout.svg';
import pageNotFound from './images/page-not-found.png';
export {
Logo,
BellDot,
pageNotFound,
Logout
}
For further insights, refer to this image link.