create-react-app for Typescript

create-react-app for Typescript

3 minutes 28s
A simple example of how to run create react app with Typescript options. No steps omitted.

If you did not yet, install Nodejs,npm,npx, as in create-react-app

Run create-react-app for Typescript


npx create-react-app my-new-ts-app --template typescript
cd my-new-ts-app
# confirm
npm start


Check source files

We confirm that the soruce files are, indeed, in Typescript


cd my-new-ts-app
ls -all src


Output


f02f@computer:~/my-new-ts-app$ ls -al src
total 44
drwxr-xr-x 2 f02f f02f 4096 Apr 22 10:50 .
drwxr-xr-x 5 f02f f02f 4096 Apr 22 10:50 ..
-rw-r--r-- 1 f02f f02f  564 Apr 22 10:50 App.css
-rw-r--r-- 1 f02f f02f  273 Apr 22 10:50 App.test.tsx
-rw-r--r-- 1 f02f f02f  556 Apr 22 10:50 App.tsx
-rw-r--r-- 1 f02f f02f  366 Apr 22 10:50 index.css
-rw-r--r-- 1 f02f f02f  500 Apr 22 10:50 index.tsx
-rw-r--r-- 1 f02f f02f 2632 Apr 22 10:50 logo.svg
-rw-r--r-- 1 f02f f02f   40 Apr 22 10:50 react-app-env.d.ts
-rw-r--r-- 1 f02f f02f  425 Apr 22 10:50 reportWebVitals.ts
-rw-r--r-- 1 f02f f02f  241 Apr 22 10:50 setupTests.ts
f02f@computer:~/my-new-ts-app$ 

Npm start


npm start


The output npm start


Compiled successfully!

You can now view my-new-ts-app in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://172.17.0.2:3000

Note that the development build is not optimized.
To create a production build, use npm run build.