SCSS module给出流程错误

IT技术 css reactjs sass flowtype
2021-05-18 00:47:51

Create React App 2通过以下导入语句更新为支持 css module:

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

然而,flow抱怨说的是:

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)

这是[options]我的.flowconfig文件中的样子:

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

我还尝试添加以下行:

module.file_ext=.module.scss
1个回答

您可能希望使用module.name_mapper.extension它来将您的 SCSS 文件映射到某个模拟module。(flowtype 文档甚至有一个使用 .css 文件做同样事情的例子)。

所以你可以使用这个配置:

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

并在 SCSSFlowStub.js.flow 中

export default Object;