typescript - Visual Studio 代码 :[js] types can only be used in a . ts 文件

标签 typescript react-native visual-studio-code

是否可以在 vs code 的 typescript 项目中使用 .js 文件?我从 github 存储库中克隆了一个 react-native 项目,并在 visual studio code 中打开了它。当我添加 tsconfig.json 以开始使用 typescript 时, 我得到一长串错误。例如这里有一个 drawer.js 文件(具有 es6 特性):

enter image description here

这是我的 tsconfig.json 文件(如果我删除这个文件,那么一切正常,没有错误报告):

enter image description here

最佳答案

我重新启动了 VS 代码,错误消失了,以防万一

关于typescript - Visual Studio 代码 :[js] types can only be used in a . ts 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41320266/

相关文章:

reactjs - 在 typescript 中 react 懒惰

angular - 用于 HTML 模板的 IntelliSense

javascript - 如何使用 Prettier 在代码块之间添加多行?

git - 我应该 checkin VS Code 开发容器文件吗?例如,.devcontainer 文件夹或 .devcontainer.json 文件?

javascript - 开 Jest mock promise 方法调用错误次数

typescript - 你能在 Typescript 函数中有可选的解构参数吗?

typescript - Angular 2 - 手动实例化 (Http) 服务

javascript - 在 WebStorm 上的每个文件键上触发 React-native 热重载

react-native - React 导航 + React-navigation-material-bottom-tabs

javascript - 类型错误 : undefined is not an object gotten when using navigation. openDrawer()