Dive into TypeScript: Writing Your First Program

Omayer Ahmad
1 min readMay 5, 2024

--

Welcome back to our TypeScript journey! In this blog post, we’ll dive right into the exciting world of TypeScript programming by writing your first TypeScript program. Get ready to experience the power and simplicity of TypeScript syntax!

Writing Your First TypeScript Program

Let’s start with a simple “Hello, World!” program. Create a new file with a .ts extension (e.g., hello.ts) and add the following code:

function greet(name: string): string {
return "Hello, " + name + "!";
}

console.log(greet("World"));

Save the file and open your terminal. Navigate to the directory containing your TypeScript file and run the following command:

tsc hello.ts

This command will compile your TypeScript code into JavaScript. Once the compilation is successful, you’ll see a new file named hello.js in the same directory.

Now, let’s execute our program by running:

node hello.js

You should see the output:

Hello, World!

Congratulations! You’ve just written and executed your first TypeScript program.

What’s Next?

Now that you’ve got a taste of TypeScript, the possibilities are endless. In the next blog post, we’ll explore basic syntax and TypeScript features in more detail. Stay tuned for more TypeScript goodness!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Omayer Ahmad
Omayer Ahmad

Written by Omayer Ahmad

Teacher, Writer and Font End Developer

No responses yet

Write a response