我正在尝试将此模块导入到我的 Typescript 文件中,但它会引发有关如何导入模块的错误。这是一个 Google Firebase 函数脚本,但我在我的项目代码的其他区域导入这个模块就好了。
10 const flamelinkApp = flamelink({
~~~~~~~~~
src/index.ts:3:1
3 import * as flamelink from 'flamelink/app';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.
NMy Typescript 配置文件在这里:
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"esModuleInterop": true,
"strict": true,
"target": "es2017"
},
"compileOnSave": true,
"include": [
"src"
]
}
您会看到该esModuleInterop
标志设置为 true,这应该可以解决此问题。
我也尝试过这样的导入:
import flamelink from 'flamelink/app';
并得到这个错误:
Module '"/Users/leeprobert/Documents/dev/PebbleStudios/Sciex/Grace/dev/pebble_sciex_grace_react/client/functions/node_modules/flamelink/public"' can only be default-imported using the 'esModuleInterop' flagts(1259)
public.d.ts(61, 1): This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
有任何想法吗?