Meal Maker - Don't Understand Linter Suggestion

Link to exercise

To start, everything runs correctly and I get all the expected outputs. However the linter underlines the set properties (this also happens in VSCode) and I get the following suggestion:

Property ‘meal’ implicitly has type ‘any’, because its set accessor lacks a parameter type annotation.(7032)

The suggested fixes don’t really make sense to me and I’m not sure if this is something I should be addressing now to establish good habits or something that will be covered later.

Code for reference:

const menu = { _meal: "", _price: 0, set meal (mealToCheck) { if (typeof mealToCheck === 'string') { this._meal = mealToCheck; } else { return console.log('Meal data type must be a string.') } }, set price (priceToCheck) { if (typeof priceToCheck === 'number'){ this._price = priceToCheck; } else { return console.log('Price data type must be a number.') } }, get todaysSpecial (){ if(this._meal && this._price) { return `Today's special is ${this._meal} for $${this._price}!`; } else { return 'The meal or price are missing or have been enetered erroniously.'; } } } menu.meal = 4; menu.price = 'Salmon'; console.log(menu); console.log('\n(Above should print error conditions and unmutated object.)') console.log ('.............................. \n'); menu.meal = 'Tuna Melt'; menu.price = 4.99; console.log(menu) console.log('\n(Above should print only mutated menu object.)\n'); console.log(menu.todaysSpecial); console.log ('.............................. \n'); menu._meal = ''; console.log(menu.todaysSpecial + '\n') menu._meal = 'New York Strip Steak'; menu._price = 0; console.log(menu.todaysSpecial) console.log('\n(Both of the above should result in an error for falsy values.)')

Any feedback is much appreciated!

Your linter is suggesting that you provide an explicit type for the meal parameter by using TypeScript, and it is derived from the tsconfig.json file under a configuration option, noImplicitAny: "true". Unless you’re currently learning TypeScript, then there’s no need to worry.

1 Like

Perfect, thanks so much for the clarification!