css - SCSS 模块给出流错误

标签 css reactjs sass flowtype

已更新为 Create React App 2,它通过以下导入语句支持 css 模块:

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)

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

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

我还尝试添加以下行:

module.file_ext=.module.scss

最佳答案

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

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

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

在 SCSSFlowStub.js.flow 中

export default Object;

关于css - SCSS 模块给出流错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50053928/

相关文章:

javascript - Next.js:如何将外部仅客户端 React 组件动态导入到开发的服务器端渲染应用程序中?

css - 在已编译的 SASS css 文件上处理 merge 冲突的最有效方法是什么?

javascript - SASS (CSS) 逻辑与 JQuery(Javascript) 逻辑

reactjs - 从项目的 node_modules 添加到模块的符号链接(symbolic link)

image - 如何在 CSS 中为图像着色?

css - 固定双标题,可滚动内容(移动应用程序)

html - 如何使用 CSS 设置圆形背景颜色?

javascript - 当我将状态保存到变量时会发生什么?

javascript - Gatsby 1 类组件

css - 如何在 Extjs 4.1.3 中更改一行网格单元格的 css