codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🔷

TypeScript

5 / 60 topics
1Getting Started with TypeScript2Installation of TypeScript3TypeScript Syntax4Variables in TypeScript5Data Types in TypeScript6Arrays in TypeScript7Objects in TypeScript
Tutorials/TypeScript/Data Types in TypeScript
🔷TypeScript

Data Types in TypeScript

Updated 2026-05-15
10 min read

Data Types in TypeScript

Introduction

TypeScript is a statically typed programming language that builds on JavaScript by adding optional static typing. One of the core features of TypeScript is its type system, which helps developers write more reliable and maintainable code by catching errors at compile time rather than runtime.

In this tutorial, we'll explore the basic data types available in TypeScript: number, string, and boolean. Understanding these fundamental types will provide a solid foundation for working with TypeScript.

Concept

Number

The number type represents numeric values. In JavaScript (and therefore TypeScript), numbers are always floating-point values. This means that integers and decimals are both represented by the same type.

Examples

Here are some examples of using the number type:

TypeScript
1let age: number = 25;
2let height: number = 5.9;
3let pi: number = 3.14159;
4
5console.log(age); // Output: 25
6console.log(height); // Output: 5.9
7console.log(pi); // Output: 3.14159

String

The string type represents textual data. Strings can be defined using either single quotes (') or double quotes (").

Examples

Here are some examples of using the string type:

TypeScript
1let name: string = "Alice";
2let greeting: string = 'Hello, World!';
3let message: string = `The value of pi is ${pi}`;
4
5console.log(name); // Output: Alice
6console.log(greeting); // Output: Hello, World!
7console.log(message); // Output: The value of pi is 3.14159

Boolean

The boolean type represents a logical entity and can have only two values: true or false. It is often used in conditional statements.

Examples

Here are some examples of using the boolean type:

TypeScript
1let isStudent: boolean = true;
2let hasGraduated: boolean = false;
3
4console.log(isStudent); // Output: true
5console.log(hasGraduated); // Output: false

What's Next?

In the next section, we will delve into more complex data structures in TypeScript, starting with Arrays in TypeScript. Understanding how to work with arrays is crucial for handling collections of data efficiently.

Stay tuned!


PreviousVariables in TypeScriptNext Arrays in TypeScript

Recommended Gear

Variables in TypeScriptArrays in TypeScript