Why is "UUserWidget is not a type name" when I try to declare the variable?

You would never need to copy paste this one (InventoryWidget.generated.h)
Its either automatically added for you if that’s the name of your class, or you don’t need it.