Typescript esModuleInterop:是的,但TSLint的错误是:";只能使用';esModuleInterop';旗;
我不确定为什么在以下两个默认导入上都出现标题错误:Typescript esModuleInterop:是的,但TSLint的错误是:";只能使用';esModuleInterop';旗;,typescript,Typescript,我不确定为什么在以下两个默认导入上都出现标题错误: // ./src/classes/FirestoreConnection.ts import admin, {firestore} from "firebase-admin"; import firebase from "firebase"; // TS1259: Module '"/home/owner/PhpstormProjects/shopify/project/node_modules/firebase/index"' can o
// ./src/classes/FirestoreConnection.ts
import admin, {firestore} from "firebase-admin";
import firebase from "firebase";
// TS1259: Module '"/home/owner/PhpstormProjects/shopify/project/node_modules/firebase/index"' can only be default-imported using the 'esModuleInterop' flag index.d.ts(8790, 1): This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
TS1259: Module '"/home/owner/PhpstormProjects/shopify/buyUsedCloudRun/node_modules/firebase/index"' can only be default-imported using the 'esModuleInterop' flag index.d.ts(8790, 1): This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
我看到标志设置为true,下面的另一个设置是否冲突
./tsconfig.json
{
"compilerOptions" : {
"module" : "commonjs",
"target" : "es5",
"sourceMap" : true,
"esModuleInterop" : true,
"types" : ["jest", "node"],
"outDir" : "build",
"allowSyntheticDefaultImports" : true,
"moduleResolution" : "Node"
},
"exclude" : [
"node_modules"
, ".idea"
, "build"
, "**/*.test.ts"
],
"include" : ["src/*"],
"lib" : ["dom", "es2015", "es2017"],
"skipLibCheck": false,
"strict": false,
"noEmit": false,
"resolveJsonModule": true,
"isolatedModules": false
}
通过使用
=require
语法替换from
,并将命名导出移动到新行来解决
正在搜索找到的错误
import admin = require("firebase-admin");
import {firestore } from "firebase-admin";
import firebase = require("firebase");