SCSS Modules Giving Flow error

落爺英雄遲暮 提交于 2021-02-07 22:01:08

问题


Updated to Create React App 2 which supports css modules via the following import statement:

import styles from "./myStyles.module.scss";

However, flow is complaining saying this:

Importing from an untyped module makes it any and is not safe!
Did you mean to add // @flow to the top of ./myStyles.module.scss? (untyped-import)

This is what the [options] in my .flowconfig file looks like:

module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.scss

I've also tried adding the following line:

module.file_ext=.module.scss

回答1:


You probably want to use module.name_mapper.extension to get it to map your SCSS files to some mocked module. (The flowtype docs even have an example for doing this same thing with .css files).

So you might use this config:

module.name_mapper.extension='scss' -> '<PROJECT_ROOT>/SCSSFlowStub.js.flow'

and in SCSSFlowStub.js.flow

export default Object;


来源:https://stackoverflow.com/questions/50053928/scss-modules-giving-flow-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!