【发布时间】:2016-10-27 09:19:37
【问题描述】:
我在我的 typescript 项目中使用 lodash,并为 lodash 键入内容。 此外,我还有一些私有 npm 模块,其中包含我在不同项目中使用的实用程序。 它导出这样的方法:
export * from './src/stringStuff';
export * from './src/httpStuff';
我想做的是为 lodash 提供该 utils 存储库。所以它看起来像这样:
import {
forEach
} from '@foo/utils'
forEach 是一个 lodash 方法。
我的方法是在我的 index utils 文件中添加一个类似这样的 lodash 导出:
export * from 'utils';
export * from './src/stringStuff';
export * from './src/httpStuff';
现在我可以像上面的例子一样导入和使用例如forEach。
但问题是类型脚本编译器给了我一个错误 /files/@foo/utils/index.ts has no exportet member forEach:
ERROR in [default] /files/@foo/utils/index.ts:1:14
Module '"lodash"' uses 'export =' and cannot be used with 'export *'.
ERROR in [default] /files/@foo/utils/index.ts:24:4
Module '"/files/@foo/utils/index.ts"' has no exported member 'forEach'.
对我来说很奇怪,我可以使用forEach,但也会收到该错误消息。为什么会这样,我该如何解决?是导入/导出错误还是输入文件错误?
【问题讨论】:
标签: javascript node.js typescript