JOBSEEKER?

TypeScript Interview Questions

Practice for TypeScript interviews by solving TestDome questions. Our interview questions are used by more than 7,000 companies and 450,000 individual test takers.

Jobseekers: Certify Your Knowledge

Take a Certification Test

Companies: Use Our Tests for Screening

Buy a Pack Of Candidates

Need to practice your TypeScript programming skills for an upcoming job interview? Try solving these TypeScript interview questions that test knowledge of TypeScript programming concepts such as types, mixins, OOP, and other skills. We’ll provide feedback on your answers, and you can use a hint if you get stuck.

These TypeScript interview questions are examples of real tasks used by employers to screen job candidates such as TypeScript developers, JavaScript developers, front-end developers, and others that require knowledge of the TypeScript programming language and the benefits it offers in web page scalability and encapsulation.

1. Color Type

Easy  
TypeScript Arrays OOP Public

The following code initializes three types representing the colors: red, green and blue.

type ColorType = [string, number, number, number];
let red: ColorType = ['Red', 1, 0, 0];
let green: [string, number, number, number] = ['Green', 0, 1, 0];
let blue = ['Blue', 0, 0, 1];

Select the statements that are correct.

(Select all acceptable answers.)

Solve Question

2. Uppercase Types

Easy  
TypeScript OOP Types Public

The following code initializes strings as three different types and attempts to make them uppercase. Which statements about the behavior of the typescript compiler are correct?

let stringType: string = "string type";
stringType.toUpperCase();

let anyType: any = "any type";
anyType.toUpper();
anyType.toUpperCase();

let objectType: Object = "object type";
objectType.toUpperCase();

(Select all acceptable answers.)

Solve Question

3. Circle Inheritance

Easy  
TypeScript Inheritance OOP New Public

The Circle class is used in a prototype for a game engine. Finish the class so that:

  • It inherits from the GameObject class
  • It has one more public field, radius
  • It has only one constructor, that sets the radius, and sets the x and y fields using the GameObject class

For example, executing the following code:

let circle = new Circle(10, 50, 8);
console.log(circle.x, circle.y, circle.radius);

should print "10 50 8".

Solve Question

4. Check Digit

Easy  
TypeScript Strings New Public

Your company assigns each customer a membership ID, and you are implementing a check digit for those IDs.

The check digit should be calculated by adding up all digits in each membership ID. If the result of the sum is a number with more than a single digit, another iteration is required, and the digits of the result should also be added together. This process should repeat until a single-digit number is calculated.

For example, for the membership ID "55555" the sum of all digits is 25. Because this is not a single-digit number, 2 and 5 would be added, and the result, 7, would be the check digit.

Solve Question

5. Permission Enum

Easy  
TypeScript Enum Enum Flags New Public

Extend the Permission enum so that it has the following fields:

  • Read, which should have a value of 1
  • Write, which should have a value of 2
  • Execute, which should have a value of 4

Extend the getPermissionList function so that it accepts a combination of several Permission enums and returns an array of strings which are the names of the Permissions.

For example, executing:

getPermissionList(Permission.Read | Permission.Write);

should return [ 'Read', 'Write' ] in any order.

Solve Question

6. Positionable

Hard  
TypeScript Mixins OOP Public

Consider the following code:

class Positionable {
  locationX: number = 0;
  locationY: number = 0;
  moveTo(toX: number, toY: number) {
    this.locationX = toX;
    this.locationY = toY;
  }
}

class Rotatable {
  orientation: number = 0;
  rotate(orientation: number) {
    this.orientation += orientation;
  }
}

class MovingObject {
  locationX: number = 0;
  locationY: number = 0;
  orientation: number = 0;
  printPosition(){
    console.log(this.locationX, this.locationY);
  }
}

function applyMixins(derivedCtor: any, baseCtors: any[]) {
  baseCtors.forEach(baseCtor => {
    Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
      derivedCtor.prototype[name] = baseCtor.prototype[name];
    });
  });
}

applyMixins(MovingObject, [Positionable, Rotatable]);
let mover = new MovingObject();

Select the statements that are correct.

(Select all acceptable answers.)

Solve Question

If you feel ready, take one of our timed public TypeScript Interview Questions tests:
HTML/CSS

HTML/CSS, Angular, TypeScript, and Node.js Online Test (Easy / Hard)

HTML/CSS, Angular, TypeScript, Node.js, and SQL Online Test (Easy / Hard)

Angular

Angular and TypeScript Online Test (Easy / Hard)

TypeScript

TypeScript and JavaScript Online Test (Easy / Hard)

Not exactly what you are looking for? Go to our For Jobseekers section.
Dashboard Start Trial Sign In Home Tour Tests Questions Pricing For Jobseekers