Debugging SpawnActor failed because no class was specified

I had the message SpawnActor failed becaus no class was specified when building a C++ based game project just now.

It turned out to be because I had used forward declarations for a type needed in the spawn.

eg

class MyActor;

UCLASS()
class MYGAME_API ACoolActor : public AActor
{
	GENERATED_BODY()
	
public:	
	ACoolActor();

	/* stuff here */

	/*  Oops, I am not completely defined - I'm just a pointer */
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	TSubclassOf< MyActor> CameraActorToSpawn;
};