JS Guide
HomeQuestionsSearchResources
Search

Built for developers preparing for JavaScript, React & TypeScript interviews.

ResourcesQuestionsSupport
HomeQuestionsSearchProgress
HomeQuestionstypescript
PrevNext
typescript
junior
types

What are the basic types in TypeScript?

types
primitives
arrays
tuples
any
unknown
void
never
Quick Answer

TypeScript includes primitive types (string, number, boolean, null, undefined, symbol, bigint), array types, tuple types, object types, and special types like any, unknown, void, and never.

Detailed Explanation

Primitive Types:

  • string: Text values
  • number: All numbers (integer and float)
  • boolean: true/false
  • null / undefined: Absence of value
  • symbol: Unique identifiers
  • bigint: Large integers

Array Types:

  • number[] or Array<number>
  • Can hold multiple values of same type

Object Types:

  • Inline objects with property types
  • Interfaces or type aliases for reuse

Special Types:

  • any: Opt-out of type checking
  • unknown: Type-safe any (must narrow before use)
  • void: No return value
  • never: Never returns (throws/infinite loop)

Code Examples

Basic and primitive types
// Primitive types
let name: string = 'Alice';
let age: number = 25;
let isActive: boolean = true;
let nothing: null = null;
let notDefined: undefined = undefined;

// Number includes all numeric types
let decimal: number = 10;
let float: number = 3.14;
let hex: number = 0xff;
let binary: number = 0b1010;

// BigInt for large integers
let bigNumber: bigint = 9007199254740991n;

// Symbol
const uniqueKey: symbol = Symbol('description');

Resources

TypeScript - Everyday Types

docs

TypeScript - More on Functions

docs

Related Questions

What is the difference between interfaces and type aliases in TypeScript?

junior
interfaces

What are union and intersection types in TypeScript?

junior
unions
Previous
What is TypeScript and what benefits does it provide over JavaScript?
Next
What is the difference between interfaces and type aliases in TypeScript?