Web Development TypeScript Subjective
Oct 04, 2025

Explain the basic types in TypeScript.

Detailed Explanation
TypeScript provides several built-in types for type safety. Primitive Types: • string: Text data • number: Numeric values (integers and floats) • boolean: True/false values • null: Intentional absence of value • undefined: Variable declared but not assigned let name: string = "John"; let age: number = 25; let isActive: boolean = true; let data: null = null; let value: undefined = undefined; Special Types: • any: Disables type checking • void: No return value (functions) • never: Values that never occur • unknown: Type-safe alternative to any function logMessage(): void { console.log("Hello"); } function throwError(): never { throw new Error("Something went wrong"); }
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback