简体   繁体   English

你如何配置一个反应应用程序来使用 typescript?

[英]How do you configure a react app to use typescript?

I am trying to learn Typescript.我正在尝试学习 Typescript。

I have followed these instructions and added typescript to my new app (just created a few minutes ago).我已按照这些说明将 typescript 添加到我的新应用程序(几分钟前刚刚创建)。

I have also followed these instructions and replaced my empty (top-level) config file with:我也遵循了这些说明并将我的空(顶级)配置文件替换为:

{
    {
        "compilerOptions": {
            "jsx": "preserve"
        }
    }
}

There is still an error that says:仍然有一个错误说:

tsconfig.json(2,1): error TS1136: Property assignment expected. tsconfig.json(2,1):错误 TS1136:预期属性分配。

Does anyone know what it means or how to solve it?有谁知道这意味着什么或如何解决它?

The first instructions should work fine.一个指令应该可以正常工作。 Make sure you don't have an old version of create-react-app globaly installed.确保您没有安装旧版本的create-react-app globaly。

You can remove it with:您可以使用以下方法将其删除:

npm uninstall -g create-react-app

And than create you project again with:而不是再次创建你的项目:

npx create-react-app my-app --typescript

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM