VSCode提示:Type annotations can only be used in TypeScript files

react native 16.13 版本,使用react官方cli创建的初始项目中,文件App.js 有一行代码:

const App: () => React$Node = () => {

会在vscode中,报语法错误:

Type annotations can only be used in TypeScript files

只需要在设置中配置一下,具体路径为:

  • Settings - User - Extentsions - TypeScript - JavaScript - Validate: Enable

取消勾选即可。

你可能感兴趣的:(VSCode提示:Type annotations can only be used in TypeScript files)