TypeScript and JavaScript

Patrick OkaforPatrick Okafor
2 min read

Table of contents

As a beginner in TypeScript, I loved everything about it, including its type-system and how VSCode supports it. I am a bit conservative, highly-aware, and security-conscious, and TypeScript naturally satisfies these preferences.

TypeScript is a strictly typed version of JavaScript. It doesn't provide the same freedom or the bugs that JavaScript often does.
I have been building with JavaScript for years, but I have been curious and excited about using TypeScript.
Before sharing this article, I wanted to build a real-time messaging application with Node.js and JavaScript. Then I thought, why not use Node.js and TypeScript?

This thought also brought about a series of other thoughts:

Q1. Which one runs at last in the environment? TypeSrcipt or JavaScript.

JavaScript runs last in the environment. TypeScript is a superset of JavaScript that gets transpiled (converted) into JavaScript before it is executed.

Q2. If we build with Typescript, do we push the TypeScript to the server (or production) environment?

Nope, typically you do not push the TypeScript files to the server. Instead, you transpile TypeScript into JavaScript and then push the resulting JavaScript files to the production environment. (TypeScript never leaves your development environment 👀).

Q3. If we push the transpiled JavaScript, surely we don’t have any need of the TypeScript?

Correct, once you have transpiled TypeScript into JavaScript and pushed the JavaScript to production, you generally do not need the TypeScript files in the production environment. However, you may still keep the TypeScript files in your source code repository for development purposes, as they provide type safety and other development-time features.

Typescript is transpiled into JavaScript, and it is the transpiled JavaScript that gets pushed and ultimately runs in the environment(whether that’s a browser or a Node.js server).

Summary:

Just for fun, you can use this media as a mnemonic tool to understand the irrevocable destiny between TypeScript and JavaScript.

TypeScript to JavaScript:

JavaScript to TypeScript:

0
Subscribe to my newsletter

Read articles from Patrick Okafor directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Patrick Okafor
Patrick Okafor

As a software developer and technical writer, I specialize in creating informative articles on software development, computer programming, and various other technology-related subjects. I focus on providing clear and concise explanations, particularly tailored for beginners in the field. I will make complex concepts accessible and enjoyable to learn for all readers.