TypeScript Interview Questions

Want to become an expert in cracking TypeScript interview questions?

Start with practicing the questions below. Whether a question involves multiple choice or live coding, we will give you hints as you go and tell you if your answers are correct or incorrect.

After that, take our timed public TypeScript Interview Questions Test.

To use our service for testing candidates, buy a pack of candidates.


1. Color Type
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.

(multiple correct answers possible)

Easy  
2min
   

2. Uppercase Types
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();

(multiple correct answers possible)

Easy  
3min
   

3. Positionable
TypeScript Mixins OOP Public

Consider the following two base classes, Positionable and Rotatable, and MovingObject derived class:

class Positionable {
    locationX: number;
    locationY: number;
}

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

class MovingObject implements Positionable, Rotatable {
    locationX: number = 0;
    locationY: number = 0;
    orientation: number = 0;
    rotate: (orientation: number) => void;
}

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

let mover = new MovingObject(); 
mover.rotate(30);

Select the statements that are correct.

(multiple correct answers possible)

Hard  
5min
   

If you feel ready, take one of our timed public TypeScript Interview Questions tests:
  • Angular and TypeScript Online Test (Easy / Hard)
  • TypeScript and JavaScript Online Test (Easy / Hard)
Not exactly what you are looking for? Go to our For Jobseekers section.