Urgent.News

What's breaking now, across hundreds of outlets.

Tech

What Is TypeScript? Explained Simply for Beginners

Originally published on CodingCush . TypeScript is JavaScript with syntax for types. That is the official one line definition. You write normal JavaScript, you add small labels that say what kind of value each variable holds, and a tool called the TypeScript compiler checks those labels before your code ever runs. The result is still plain JavaScript, so it runs anywhere JavaScript runs: in a…

What Is TypeScript? Explained Simply for Beginners

TypeScript is JavaScript augmented with a powerful type system. It enables developers to label variables with their expected data types, such as string, number, or boolean. This is achieved by adding small type annotations using the colon ( : ) symbol. After writing TypeScript code, it is compiled into plain JavaScript, which can then be executed in any environment where JavaScript is supported, like browsers, Node.js, or mobile apps.

TypeScript is not a replacement for JavaScript; instead, it provides an additional layer of safety and readability to the language. It does this by catching errors during the development process, long before the code is executed. This early detection of issues helps developers write more robust and maintainable code.

Getting Started with TypeScript

To begin with TypeScript, you first need to install Node.js, a JavaScript runtime environment, as TypeScript relies on it for its tooling. Once Node.js is installed, you can install TypeScript globally through npm (Node Package Manager) using the command: npm install -g typescript. After installation, you can check if TypeScript is correctly installed by running tsc -v in your terminal.

TypeScript files have a .ts extension, and you can write TypeScript code just like normal JavaScript. For example, you can create a file called hello.ts with the following content:

const message : string = "Hello, TypeScript!" ;

console . log ( message ) ;

The : string part is a type annotation that tells TypeScript that the message variable will always hold a string value. To compile the TypeScript file into JavaScript, you run the tsc command followed by the TypeScript file name: tsc hello.ts. This creates a JavaScript file with the same name but without the .ts extension. You can then run the compiled JavaScript file using Node.js by running node hello.js, which outputs: Hello, TypeScript!

Benefits of TypeScript

One of the main advantages of TypeScript is its ability to catch errors early in the development process. For instance, if you attempt to assign a number to a variable expected to hold a string, TypeScript will immediately flag this as an error, rather than allowing the code to compile and run with potentially incorrect behavior. This early feedback is invaluable for writing cleaner, less error-prone code.

Additionally, TypeScript's type system is highly customizable and can be tailored to fit the specific needs of a project. It supports interfaces for describing the structure of objects, unions for specifying that a variable can be one of several types, and generics for creating reusable components that work with any type. These features make TypeScript a powerful tool for building large-scale applications that are easy to maintain and scale.

In summary, TypeScript is a superset of JavaScript that adds static types to the language. It compiles down to plain JavaScript, ensuring that the output remains fully compatible with any JavaScript runtime. With its emphasis on early error detection and type safety, TypeScript has become a popular choice for developers looking to enhance the quality and maintainability of their JavaScript code.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

CoreWCF: Move WCF Services to .NET 10, gRPC or Web API

Server-side WCF never made it into .NET Core or modern .NET. CoreWCF, a Microsoft-supported port, runs existing WCF services on .NET 10 with the same contracts, so callers keep working.

  • CoreWCF allows existing WCF services to run on .NET 10 with same contracts.
  • Alternative options for redesigning WCF services are gRPC and ASP.NET Core Web API.

What Is a Chatbot? Explained Simply for Beginners

Originally published on CodingCush . It is 11 at night. You message a small tea shop to ask the price of a cup of chai, and a reply pops up in two seconds. No one is awake at the shop.

  • Chatbot is a computer program communicating through messages
  • Simple bot uses rule-based approach with keyword matching
  • AI chatbots learn patterns from extensive example conversations

One Proxy Timeout Took Out Our Entire Search Console Pipeline

For three days we could not read our own Search Console data. The API was fine. The credentials were fine. Our laptop could not reach Google at all — every TLS handshake to www.googleapis.com timed…

  • Proxy client halted TLS connections to Google properties
  • Search Console pipeline disrupted for three days
  • Data pipeline moved to stable server in Hong Kong

Deterministic 60–144Hz Rotating-Pin Collision & Zero-Ghosting 2P Input in HTML5 Canvas

Building fast, deterministic timing and local 2-player games in vanilla HTML5 looks deceptively simple—until a player on a 144Hz ProMotion display experiences double-speed rotation, or two players…

  • Developers solved three physics and input bugs in HTML5 Canvas 2P games without external libraries
  • Stored rotating pins as polar angle θ to prevent drifting due to floating-point errors

More from Saturday, 28 November 2026 →