Recall & Review
beginner
What is excess property checking in TypeScript?
Excess property checking is a TypeScript feature that warns you when you provide extra properties in an object literal that are not expected by the target type.
Click to reveal answer
intermediate
Why does TypeScript perform excess property checking only on object literals?
TypeScript checks object literals for extra properties to catch typos or mistakes early. It does not check variables or objects assigned from elsewhere to allow flexibility.
Click to reveal answer
intermediate
How can you avoid excess property checking errors when passing objects with extra properties?
You can assign the object to a variable first, or use type assertions to tell TypeScript to trust your object shape and skip excess property checks.
Click to reveal answer
beginner
What happens if you pass an object literal with an extra property to a function expecting a specific type?
TypeScript will give an error about the extra property because it does excess property checking on object literals to prevent mistakes.
Click to reveal answer
advanced
Can excess property checking be bypassed by using index signatures in TypeScript interfaces?
Yes, if an interface has an index signature like [key: string]: any, excess property checking is relaxed because extra properties are allowed.
Click to reveal answer
When does TypeScript perform excess property checking?
✗ Incorrect
TypeScript performs excess property checking only on object literals directly assigned to variables or passed as parameters.
What error will TypeScript give if you pass an object literal with an unexpected property to a function expecting a specific type?
✗ Incorrect
TypeScript will report an excess property error to warn about unexpected properties in object literals.
How can you avoid excess property checking errors when you want to pass extra properties?
✗ Incorrect
Assigning the object to a variable first disables excess property checking on that variable.
What effect does an index signature have on excess property checking?
✗ Incorrect
An index signature allows extra properties, so excess property checking is relaxed.
Which of these is a common reason for excess property checking errors?
✗ Incorrect
Typos in property names cause extra properties that TypeScript flags during excess property checking.
Explain what excess property checking is and why TypeScript uses it.
Think about how TypeScript helps catch typos in object properties.
You got /3 concepts.
Describe two ways to avoid excess property checking errors when passing objects with extra properties.
Consider how you can tell TypeScript to trust your object shape.
You got /3 concepts.