Have you ever seen a Magento 2 issue that reads:
Type Error Occurred When Creating Object
When an object is created, this error indicates a problem. This error typically occurs when you give arguments from the calling method but the called function does not get those arguments.
For instance, when a function is called with four parameters and only receives three arguments, one of the arguments is missing. It causes a Type Error Occurred When Creating an Object Magento 2.
I've built that object on occasion, however, the object is occasionally not formed in the generator due to a compilation problem. In general, I've seen that many programmers have a tendency to remove the entire produced folder to fix this problem.
It's hazardous to delete the folder repeatedly because it could result in data loss. As a result, I've developed a workaround for this problem rather than deleting the folder.
Look at the answer,
https://meetanshi.com/blog/solution-type-error-occurred-when-creating-object-in-magento-2/