Migrating create-react-app from javascript to typescript

前端 未结 4 1424
迷失自我
迷失自我 2020-12-12 22:24

I started a react project using create-react-app few months ago and I\'m interesting in migrating the project from Javascript to Typescript.

I saw that there is a wa

4条回答
  •  春和景丽
    2020-12-12 22:52

    Create React App v2.1.0 was released today with TypeScript support today. That means you no longer need to eject or use the react-scripts-ts fork; all you need to do if you have an existing Create React App project is install the required packages:

    $ npm install --save typescript @types/node @types/react @types/react-dom @types/jest
    $ # or
    $ yarn add typescript @types/node @types/react @types/react-dom @types/jest
    

    You can then simply rename .js files to .ts files to start using TypeScript.

    (If you have an existing app using the create-react-app-typescript fork, here's a tutorial on how to port it to regular Create React App.)

提交回复
热议问题