Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs create react app--typescript:当'--隔离模块';提供旗帜_Reactjs_Typescript - Fatal编程技术网

Reactjs create react app--typescript:当'--隔离模块';提供旗帜

Reactjs create react app--typescript:当'--隔离模块';提供旗帜,reactjs,typescript,Reactjs,Typescript,我用npx create react app my app ts--typescript, 然后我在src/下创建了两个文件,sw build.js和sw.js sw build.js和sw.js的代码来自() 有一个错误: Cannot compile namespaces when the '--isolatedModules' flag is provided. 我该怎么办?对于可能会出现在这里的其他人,在上面列出的github问题上发布了一个可能的答案: karannagupta发表

我用npx create react app my app ts--typescript,
然后我在
src/
下创建了两个文件,
sw build.js
sw.js

sw build.js
sw.js
的代码来自()

有一个错误:

Cannot compile namespaces when the '--isolatedModules' flag is provided.


我该怎么办?

对于可能会出现在这里的其他人,在上面列出的github问题上发布了一个可能的答案:

karannagupta发表评论

我排除了
tsconfig.json
中的软件文件,如下所示:

{
 "compilerOptions": {
  ...
  },
  "include": [
    "src/*"
  ],
  "exclude": [
    "node_modules",
    "**/*.spec.ts",
    "src/sw-*.js",
    "src/idb.js"
  ]
}
编辑: 其他选择:

  • /@ts ignore
    添加到出错行上方的行中
  • 添加一个无输出(例如,
    export const='';
    ),以便该文件是一个模块()
有点黑,但可能是所有人需要的