3

For me, the React + TypeScript starter project gives me this warning and nothing I can think of makes it go away permanently.

The first line of index.tsx is

import React, { FC } from 'react';

Which draws the warning

Module '"stackblitz:/node_modules/@types/react/index"' can only be default-imported using the 'esModuleInterop' flag(1259)
index.d.ts(65, 1): This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
import React

I created a tsconfig.json file:

{
  "compilerOptions": {
    "module": "ES2022",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "sourceMap": true,
    "strict": true,
    "strictNullChecks": true,
    "strictBindCallApply": true,
    "strictFunctionTypes": true
  }
}

And that worked for a day or so but now the error has returned. One of the most infuriating things about this — besides its utter pointlessness — is that it must happen (must it not?) to everyone who uses this perfectly common starter, yet I find nothing about it online.

Michael Lorton
  • 43,060
  • 26
  • 103
  • 144

0 Answers0