Lesson 10 of 10 15 min +125 XP
🧠 Quiz: TypeScript Mastery
Answer all questions to complete the quiz and earn 125 XP.
1
What TypeScript type should you use for a product price?
2
What's wrong with this code? interface Product { name: string; price: number; } const laptop: Product = { name: 'MacBook Pro', price: '1999' };
3
Which syntax makes a property optional in an interface?
4
What does a union type like 'card' | 'upi' | 'cod' allow?
5
What's the return type of: function findProduct(products: Product[], id: string) { return products.find(p => p.id === id); }
6
How do you type a function parameter that accepts any object with an 'id' property?
7
What does Partial<Product> do?
8
What's the correct way to type React useState for a product that starts as null?
9
Which is the correct type for a button click event handler in React?
10
What pattern is this? interface PhysicalProduct { type: 'physical'; weight: number; } interface DigitalProduct { type: 'digital'; downloadUrl: string; } type Product = PhysicalProduct | DigitalProduct;
correct