Recall & Review
beginner
What does type compatibility mean in TypeScript classes?
It means one class type can be used where another is expected if their structures match, even if they are different classes.Click to reveal answer
beginner
How does TypeScript check compatibility between two classes?
TypeScript compares the properties and methods of the classes. If one class has at least the same members with compatible types, it is compatible.Click to reveal answer
intermediate
Can private or protected members affect class compatibility in TypeScript?Yes. If classes have private or protected members, they must come from the same declaration to be compatible.
Click to reveal answer
beginner
Given two classes with the same public properties, are they compatible?
Yes. If their public properties and methods match in type, they are compatible regardless of class names.Click to reveal answer
intermediate
Why does TypeScript use structural typing for classes instead of nominal typing?
Because it focuses on the shape of data (members) rather than the class name, making code more flexible and reusable.Click to reveal answer
In TypeScript, when are two classes considered compatible?
✗ Incorrect
TypeScript checks if the public members match in type, not the class name or file location.
What happens if two classes have private members with different declarations?
✗ Incorrect
Private members must come from the same declaration to be compatible.
Which typing system does TypeScript use for class compatibility?
✗ Incorrect
TypeScript uses structural typing, meaning compatibility depends on member structure.
If class A has extra public members not in class B, can A be assigned to B?
✗ Incorrect
Extra members do not prevent compatibility as long as required members match.
Why might TypeScript's class compatibility be helpful in real projects?
✗ Incorrect
Structural typing lets you use different classes interchangeably if their shapes match.
Explain how TypeScript determines if two classes are compatible.
Think about comparing the shape of the classes, not their names.
You got /4 concepts.
Describe a situation where two classes with the same public properties are not compatible.
Consider private members and their declarations.
You got /3 concepts.