Import svg image into typescript

Using the following code as an example, which works great, the typescript compiler cries for " import logo from './images/logo.svg';". The application works fine when it works in the browser, so I have no problems with the functionality. I would just like to get rid of the red-red line so that I can clear my catalog viewer. Any help would be greatly appreciated.

import * as React from 'react';
import logo from './images/logo.svg';

interface Property {}
interface State {} 

export default class App extends React.Component<Property, State> { 
    render() {
        return (
            <div className="App">
                <div className="App-header">
                    <img src={logo} className="App-logo" alt="logo" />                        
                </div>      
            </div>
        );
    }
}
+6
source share
1 answer

add declare module '* .svg' to any of your input files. (.d.ts)

+1
source

Source: https://habr.com/ru/post/1016254/


All Articles