2

I'm not sure why I'm getting the title error on both default imports below:

// ./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.

I see that the flag is set to true, is another setting conflicting below?

./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
}
Sean D
  • 3,810
  • 11
  • 45
  • 90
  • 1
    Searching on the error found [What does “can only be default-imported using the 'esModuleInterop' flag” mean?](https://stackoverflow.com/q/57960016/215552) – Heretic Monkey Feb 03 '20 at 20:29

1 Answers1

0

Solved by substituting from with = require syntax, and moving the named export to a new line. https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require

import admin = require("firebase-admin");
import {firestore } from "firebase-admin";
import firebase = require("firebase");
Sean D
  • 3,810
  • 11
  • 45
  • 90