I use Webpack to build my React project with Flow types. I have configured Webpack to import SVG files using svg-sprite-loader as such:
{
test: /\.svg$/,
loader: ['svg-sprite-loader']
}
This allows me to "import" SVG files as such:
import letterCellSymbol from '../styles/icons/tool-letter.svg'
Then I can use the files in my React components like this:
<svg className="icon">
<use xlinkHref={`#${letterCellSymbol.id}`} />
</svg>
This causes problems with Flow type checking, of course:
Error: src/components/Toolbox.jsx:70
70: <use xlinkHref={`#${letterCellSymbol.id}`} />
^^ property `id`. Property not found in
70: <use xlinkHref={`#${letterCellSymbol.id}`} />
^^^^^^^^^^^^^^^^ String
What's the proper way to tell Flow that these SVG files export objects with the type {id: string} or simply ignore these errors entirely?