I had this API function call with optional parameters

updateTags(title: string) {
...

and got this error:

error TS2345: Argument of type 'null' is not assignable to parameter of type 'string |  undefined'.

Solution

The solution is to properly set the accepted types: string OR null:

updateTags(title: string|null) {
...

 

 

Saved you some valuable time?

Buy me a drink 🍺