DEV Community

Cover image for Write your first TypeScript code today with this simple setup
akpamaboris
akpamaboris

Posted on

Write your first TypeScript code today with this simple setup

*Writing your first TypeScript code might feel intimidating. Don't worry, i got you! 🤝 *

1 - Create a folder

I name it tstest.
You can use the command mkdir like this or create it manually.
Capture d’écran 2021-07-11 à 12.08.04.png

2 - Open it and initialise your project

Run the command npm init -y  to initialise your project and create the package.json file.

3 - Install parcel

Run the command npm i -g parcel-bundler to install parcel globally

4 - Create a new file

-in your terminal type touch index.html

5 -Open Visual Studio Code

-in your terminal type the command code . to open the folder in vs code

6- Create a html document

-Use the emmet snippet like in the image below

image.png

7- Add a script tag with a source index.ts

image.png

8- Create the file index.ts

  • Create the file index.ts and write this in it

image.png

9- Then typescript can handle anything for us

10 - Type in the terminal parcel index.html

image.png

11- It will install typescript and start a server at port 1234

image.png

As you can see everything is working!!!

12- You can now try to experiment TypeScript : Have Fun 🤝

Top comments (0)