# React 18 for beginners

**URL:** <https://forum.codewithmosh.com/t/react-18-for-beginners/19210>\
**Category:** React\
**Created:** [March 29, 2023, 2:10am UTC](https://forum.codewithmosh.com/t/react-18-for-beginners/19210 "2023-03-29T02:10:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jorge](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@Jorge](https://forum.codewithmosh.com/u/Jorge)\
**Post date:** [March 29, 2023, 2:10am UTC](https://forum.codewithmosh.com/t/react-18-for-beginners/19210/1 "2023-03-29T02:10:50Z")

</div>

at the end of the form chapter, how can manage the add expense with no arrow function? I mean I would like to have a separate function to save new expense, if I try something like this:  
function addExpense (newExpense) {  
setExpenses([…expenses, { …newExpense, id: expenses.length + 1 }]);

ts show a warning “Parameter ‘newExpense’ implicitly has an ‘any’ type.”, works but this warning ???

---

<div class="post-metadata">

**Author:** ![SAM](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sam/32/167_2.png) [@SAM](https://forum.codewithmosh.com/u/SAM)\
**Post date:** [March 31, 2023, 5:35pm UTC](https://forum.codewithmosh.com/t/react-18-for-beginners/19210/2 "2023-03-31T17:35:20Z")

</div>

You need to give your `newExpense` parameter an explicit type:

```ts
function addExpense (newExpense: Expense)

```

Benefit: You get Intellisense help and type checks. Without the type the implicit type is `any` and the function behaves like JavaScript: In case you misspell something or perform invalid operations your function fails at run time instead of compile time.
