首页 > 解决方案 > 打字稿文件为空导致问题

问题描述

我试图删除该文件,但错误消息并没有消失。我解决问题的唯一方法是导出文件,然后导入我的 app.tsx 文件。

Failed to compile
/Users/steven/react-typescript-todolist/src/components/Todo.tsx
TypeScript error in /Users/steven/react-typescript- 
todolist/src/components/Todo.tsx(undefined,undefined):
'Todo.tsx' cannot be compiled under '--isolatedModules' because it is considered a global 
 script file. Add an import, export, or an empty 'export {}' statement to make it a module. 
TS1208
 This error occurred during the build time and cannot be dismissed.

有人可以解释为什么会弹出这个错误以及为什么删除文件不能解决问题吗?

标签: typescript

解决方案


推荐阅读