gpt4 book ai didi

react-native - 默认 React Native 应用程序的 Typescript 注释错误?

转载 作者:行者123 更新时间:2023-12-04 01:27:48 24 4
gpt4 key购买 nike

当创建一个新的 React Native 项目并在 VSCode 中打开默认的 app.js 文件时,这一行;
const App: () => React$Node = () => {
返回
Type annotations can only be used in TypeScript files.
作为 VSCode 问题。

我是想用 React Native 安装 typescript ,还是 VSCode 或其他什么问题?当然,React Native 不会发布带有错误的默认 app.js 文件。

这是问题的内容。

{
"resource": "/d:/App/sw_lbi_app/App.js",
"owner": "typescript",
"code": "8010",
"severity": 8,
"message": "Type annotations can only be used in TypeScript files.",
"source": "ts",
"startLineNumber": 27,
"startColumn": 12,
"endLineNumber": 27,
"endColumn": 28
}

最佳答案

那是 Flow ,而不是 TypeScript。只需删除类型,您的代码就会毫无问题地运行。

关于react-native - 默认 React Native 应用程序的 Typescript 注释错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61564863/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com