See conversation in: https://github.com/facebook/create-react-app/issues/5628
I have not tested this, but it should be something like:
.flowconfig
[options]
module.name_mapper.extension='svg' -> '
SVGModule.js.flow:
declare export default { ReactComponent: React$Node }
The above was resulting in imports being typed any for me, I was able to get the following to work:
// @flow
declare export var ReactComponent: React$Node;
Unfortunately it did not work for me...
I have this configuration:
[options]
module.name_mapper.extension='svg' -> '<PROJECT_ROOT>/flow-typed/custom/ReactComponent.js.flow'
and module file:
declare export var ReactComponent: React$Node;
After the Flow execution I got this error:
Error โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ src/modules/Layout/LogoVertical.js:5:10
Cannot import ReactComponent because there is no ReactComponent export in ../../assets/images/logo_vertical.svg. Did you
mean import ReactComponent from "..."? [missing-export]
2โ import React, { type Element } from 'react';
3โ import type { ClassNamePropType } from '../../types';
4โ import { MEDIA_QUERY_BREAKPOINTS } from './constants';
5โ import { ReactComponent as LogoVerticalSvg } from '../../assets/images/logo_vertical.svg';
So, I tried change the module.system=haste and got this one:
Error โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ src/modules/Layout/LogoVertical.js:5:51
Cannot resolve module /Users/hurvajs/Sites/private/agm-platform/Client/flow-typed/custom/ReactComponent.js.flow.
[cannot-resolve-module]
Most helpful comment
I have not tested this, but it should be something like:/SVGModule.js.flow'
.flowconfig
[options]
module.name_mapper.extension='svg' -> '
SVGModule.js.flow:
declare export default { ReactComponent: React$Node }