Let's talk about useState, because useState in react has some interesting behaviors depending on what you pass it, and there's four configurations.
If you pass useState nothing and you don't pass a type argument either, then the thing that it creates will be undefined. You can't set anything else to it. You can say setUndefinedThing as 123 or something. This actually will work surprisingly, but it's not going to do what you want it to do. This thing is always going to be undefined.
If you don't pass it an argument but you do pass it a type argument, then this is going to be typed as string or undefined, because technically the thing that you've passed in here is undefined. If you pass it in here, then it's not going to work. If you don't pass anything it will be string or undefined, which is useful for a lot of cases.
If you pass it just an argument but with no type argument then it might infer it incorrectly. If you pass it like a string, if you say this, this, this whatever, then it will infer correctly because it's time to string and that's the thing you passed in. Whereas if you pass in just emptyArray, it's not going to have fun.
If you try to set anything to it, so setEmptyArray like with an array of id '123', this is first of all going to error because it's not assignable to type 'never' because this array should never contain anything according to your types. You're still going to get never array for it.
With arrays especially, or objects, or things that don't contain anything yet, you need to pass in a type argument and a real argument. This means that then arrayOfIds is typed as array string, and you can set the arrayOfIds properly.