This video is available to students only

What is TypeScript? A Beginner's Guide

JavaScript is considered a weakly typed language. In this lesson, we'll go through a simple example of why that can be an issue in development and where TypeScript falls in the picture.

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

Introducing TypeScript

📝 This lesson's quiz can be found - here.
🗒️ Solutions for this lesson's quiz can be found - here.

JavaScript is considered a weakly typed language which means that in JavaScript, we have the ability to assign one data type to a variable and later on assign another data type to that same variable.

Let's see an example of this in our index.js file. We'll look to replicate what we've done before by creating two variables, one and two, and attempt to show the summation of these two variables.

In the src/index.js of our server project, we'll create constant variables labeled one and two and provide numerical values of 1 and 2 respectively.

const one = 1;
const two = 2;

In the callback function of our app.get() method for the index route, we'll send an interpolated string that says 1 plus 2 is equal to the sum of the variables one and two.

server/src/index.js
app.get("/", (req, res) => res.send(`1 + 2 = ${one + two}`));

When we launch our app in http://localhost:9000/, we'll see an output of 1 + 2 = 3.

Newline Image

This lesson preview is part of the The newline Guide to Building Your First GraphQL Server with Node and TypeScript course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

Unlock This Course

Get unlimited access to The newline Guide to Building Your First GraphQL Server with Node and TypeScript, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course The newline Guide to Building Your First GraphQL Server with Node and TypeScript