Why is --isolatedModules error fixed by any import?

后端 未结 3 1471
醉话见心
醉话见心 2020-12-13 08:14

In a create-react-app typescript project, I tried to write this just to test some stuff quickly:

// experiment.test.ts         


        
3条回答
  •  余生分开走
    2020-12-13 08:36

    The correct way is to tell TypeScript what you want. If you don't want isolatedModules create tsconfig.json inside your test directory and add:

    {
      "extends": "../tsconfig.json",
      "compilerOptions": {
        "isolatedModules": false
      },
    }
    

    Adding "isolatedModules": true to the config and then cheating TypeScript checker by adding empty export {} smells bad code to me.

提交回复
热议问题