Top 10 Basic TypeScript Interview Questions

Top 10 Basic TypeScript Interview Questions

3 mins read673 Views Comment
Vikram
Vikram Singh
Assistant Manager - Content
Updated on Dec 15, 2022 15:47 IST

TypeScript is among the top 10 programming languages. This article, will discuss the basic typescript questions in the most simplified way that are usually asked during interview process.

2022_04_TypeScript-interview-question.jpg

Introduction

In this article, we will discuss the top 10 basic TypeScript Interview Question

According to PYPL(Popularity of Programming Language), in 2022 TypeScript is among the top 10 programming languages. It has more than 13M of lines of code on GitHub with more than 290 thousand repositories.

In this article, we will discuss the top 10 basic TypeScript Interview Question

Click Here: Getting started with TypeScript

Recommended online courses

Best-suited Interview preparation courses for you

Learn Interview preparation with these high-rated online courses

4.96 K
2 months
8.81 K
3 weeks
2.8 K
1 week
Free
1 week
Free
1 hours
14.6 K
3 months
1.35 K
4 weeks
5.13 K
45 hours
5.13 K
67 hours
3.3 K
22 hours

Table of Content

  1. What is TypeScript?
  2. What are the main features of TypeScript?
  3. What are Generics in TypeScript?
  4. What are the different data types in TypeScript?
  5. What are the different components in TypeScript?
  6. How to declare a variable in TypeScript?
  7. What are the different object-oriented terms supported by TypeScript?
  8. What are the different features of classes in TypeScript?
  9. What are the advantages and disadvantages of TypeScript?
  10. What is the difference between JavaScript and TypeScript?
  11. What are the different keywords that are used to declare variables in TypeScript?
  12. What is undefined in TypeScript?

Top 10 Basic TypeScript Interview Questions

Q1. What is TypeScript?

A1. TypeScript is the superset of JavaScript. The typeScript was created in response to the limitation of JavaScript for constructing large scale applications within Microsoft and its external resource. It has more advanced features than JavaScript. It is used for both frontend and backend.

Some of the top companies like Storybook, Grafana, and TurboLinks use it.

Q2. What are the main features of TypeScript?

A2. 

  • Object-oriented Language
  • Cross-Platform
  • Static Type Checking
  • DOM Manipulations
  • Optional Static Typing
  • ES 6 Features

Q3. What are Generics in TypeScript?

A3. Generic are tolls that have the ability to abstract types. It is used to create reusable code components that work with a wide range of types instead of a single type.

Q4. What are the different data types in TypeScript?

A4. Data types in TypeScript are divided into 2 parts: Builtin and user-defined

  • Builtin
    • String
    • Number
    • Boolean
    • Void
    • Symbol
    • Null & Undefined
  • User-Defined
    • Arrays
    • Enums
    • Classes
    • Interfaces

Q5. What are the different components of TypeScript?

A5. There are 3 different types of components in TypeScript:

  • Language
    • Comprises of Syntax, keyword and type annotations
  • Complier
    • Converts instructions to JavaScript that is written in TypeScript
  • Language Services
    • Exposes an additional layer around the core compiler pipeline

Q6. How to declare a variable in TypeScript?

A6. Variables are namespaces in memory used to store a particular value.

let and const are the two methods to declare variables in TyoeScript.

  • Variable should contain alphabets and numeric digits
  • Variables can’t contain spaces and special characters except for underscore (_).
  • Variable names should not start with a number.

Q7. What are the different object-oriented terms supported by TypeScript?

A7. TypeScript supports the following object-oriented terms:

  • Modules
  • Classes
  • Interfaces
  • Inheritance
  • Data Types
  • Member Function

Q8. What are the different features of classes in TypeScript?

A8. A Class is a blueprint or template for creating objects. TypeScript supports OOPs programming features like classes, and interfaces similar to Javascript.

Feature of classes in TypeScript:

  • Inheritance
  • Encapsulation
  • Polymorphism
  • Abstraction

Q9. What are the advantages and disadvantages of TypeScript?

Advantage Disadvantage
Problems are highlighted throughout development and at compilation time. Takes a long time to compile
Similar to JavaScript Doesn’t support abstract classes
Run in any browser Converting TypeScript to JavaScript requires an additional step for compilation
Fast, simple and easy to learn Quality of the type definition file is a must
advantages and disadvantages of TypeScript

Q10. What is the difference between JavaScript and TypeScript?

TypeScript JavaScript
Object-oriented Language Scripting Language
Supports ES 6 Doesn’t support ES 6
Support Modules Doesn’t support Modules
Supports Generic Doesn’t support Generic
Source file is in “.ts” extension Source file is in “.js” extension
TypeScript vs JavaScript

Q11. What are the different keywords used to declare variable in TypeScript?

There are three different keywords (var, let, and const) are used to declare variable in TypeScript.

  • var – Used to declare a global variable, and values can be optionally set during declaration.
  • let – Declares block-scoped local variable
  • const – Declares a block code constant value that can’t be changed after initialization.

Q12. What is undefined in TypeScript?

When the variables are initialized without defining the values, then the typescript automatically assign the undefined value to that variable.

 

Conclusion

In this article, we tried to answer Top 10 Basic TypeScript Interview Question in complete details.

About the Author
author-image
Vikram Singh
Assistant Manager - Content

Vikram has a Postgraduate degree in Applied Mathematics, with a keen interest in Data Science and Machine Learning. He has experience of 2+ years in content creation in Mathematics, Statistics, Data Science, and Mac... Read Full Bio