React:create-react-appでテンプレートをTypeScriptにする方法

スポンサーリンク

create-react-appでテンプレートをTypeScriptにする方法

create-react-appでテンプレートをTypeScriptにするには--template typescriptオプションを指定します。

 

--template typescriptオプションを指定した場合

$ npx create-react-app my-react-app --template typescript 
$ cd my-react-app
$ npm list
my-react-app@0.1.0 /home/testuser/my-react-app
├── @testing-library/jest-dom@5.16.1
├── @testing-library/react@12.1.2
├── @testing-library/user-event@13.5.0
├── @types/jest@27.4.0
├── @types/node@16.11.21
├── @types/react-dom@17.0.11
├── @types/react@17.0.38
├── react-dom@17.0.2
├── react-scripts@5.0.0
├── react@17.0.2
├── typescript@4.5.5
└── web-vitals@2.1.4

 

--template typescriptオプションを指定しない場合

$ npx create-react-app my-react-app
$ cd my-react-app
$ npm list
my-react-app@0.1.0 /home/testuser/my-react-app
├── @testing-library/jest-dom@5.16.1
├── @testing-library/react@12.1.2
├── @testing-library/user-event@13.5.0
├── react-dom@17.0.2
├── react-scripts@5.0.0
├── react@17.0.2
└── web-vitals@2.1.4