TypeScript Version: 2.5.3
Code
Playground example here
enum Topping {
Cheese = 'cheese',
Olives = 'olives',
}
type Pizza = {
toppings: Topping[];
};
const pizza = {
toppings: [Topping.Cheese]
};
function calculateToppingPrice(topping: Topping): number {
// ... whatever
return 0;
}
let pizzaCost = 10;
for (let topping in pizza.toppings) {
// Argument of type 'string' is not assignable to parameter of type 'Topping'.
pizzaCost += calculateToppingPrice(topping);
}
Expected behavior:
The let topping in the for..in loop is of type Topping
Actual behavior:
The let topping in the for..in loop is of type string
TypeScript Version: 2.5.3
Code
Playground example here
Expected behavior:
The let
toppingin the for..in loop is of typeToppingActual behavior:
The let
toppingin the for..in loop is of typestring