简体   繁体   English

流类型警告:此模块仅具有默认导出

[英]Flowtype Warning: This module only has a default export

I have a utils/index.js file which looks something like this to give me quick access to all the utils within my app. 我有一个utils/index.js文件,看起来像这样,可以快速访问应用程序中的所有utils。

/**
 * @providesModule utils
 * @flow
 */

import isValidEmail from './isValidEmail';
import isWithinVersionRange from './isWithinVersionRange';

...more util functions

export {
  isValidEmail,
  isWithinVersionRange,
}

When I import one of these functions in another file like so... 当我将这些功能之一导入另一个文件时,就像这样...

import { isValidEmail } from 'utils';

Flow throws a warning saying This module only has a default export . Flow发出警告,说This module only has a default export

Am I doing something wrong? 难道我做错了什么?

I fixed this by changing my flow import to a capital and all references to it to a capital: 我通过将流导入更改为大写并将所有对它的引用更改为大写来解决此问题:

/**
 * @providesModule Utils
 * @flow
 */

And then did a find and replace for all 'utils' -> 'Utils' 然后找到并替换所有'utils' -> 'Utils'

import { isValidEmail, isWithinVersionRange } from 'Utils';

Then my flow errors were gone and our functions were properly flow typed. 然后我的流程错误消失了,我们的函数被正确地按流程键入了。

If someone knows why , that'd interesting. 如果有人知道为什么 ,那会很有趣。 But here's the fix. 但是,解决办法就在这里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 转换为Typescript后,模块没有默认导出 - Module has not default export after converting to Typescript 每个模块仅允许默认导出一次,但仅显示一个 - Only one default export allowed per module' but only one is presented Typescript - TS1192:模块没有默认导出 - Typescript - TS1192: Module has no default export jspm / jQuery / TypeScript - 模块“jquery”没有默认导出 - jspm / jQuery / TypeScript - module “jquery” has no default export Jest:当同一模块也命名为export时,如何模拟默认导出组件? - Jest: How to mock default export Component when same module also has named export? 无法从非 EcmaScript 模块导入命名导出“指令”(仅默认导出可用) - Can't import the named export 'Directive' from non EcmaScript module (only default export is available) Flowtype - 如何导出和导入类型? - Flowtype – how to export and import types? 无法从默认导出模块导入命名导出“XXX”(导入为“XXX”)(仅默认导出可用) - Can't import the named export 'XXX' (imported as 'XXX') from default-exporting module (only default export is available) 未找到导出默认值; 模块导出不起作用 - export default was not found; module export not working 从其他导出调用默认模块导出? - Call default module export from other export?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM