Project not compiling after new class added? Help!

It seems completely unrelated but it is somehow connected. After adding new c++ class (and not adding any code to it) compilation failed but it failed on something unrelated to new class?

The actor itself is an AActor descendant which we can call MercusItemStorage but it isn’t relevant (it happens on new class that I add class of any descendance). If I remove this new file the project compiles without issues.

If I keep it and try to compile manually through VS (or on adding any other new class) it fails on :

GENERATED_BODY() macro in a class that already existed (lets call it UItemData that is UObject descendant) for months - citing errors of (and compiles fine if this new class MercusItemStorage is removed) :

"use of undefined type ‘UTextProperty’ "
‘TCppType’: undeclared identifier

Several other places report errors of not knowing what “USceneComponent” and “USkeletalMeshComponend” being undefined etc. it appears engine is having a complete meltdown of sorts and no longer knows it own macros or classes that it knew full well without any extra includes before new class is added.

Here are some actual errors, i changed the path to ChangedManually due to NDA’s and other things:

CompilerResultsLog: Error: C:\ChangedManually\Source\Interactable/Items/ItemData.h(100) : error C2027: use of undefined type 'UTextProperty'
CompilerResultsLog: Error: C:\UE4\UE_4.19\Engine\Source\Runtime\CoreUObject\Public\Templates/Casts.h(348) : note: see declaration of 'UTextProperty'
CompilerResultsLog: Error: C:\ChangedManually\Source\Interactable/Items/ItemData.h(100) : error C2065: 'TCppType': undeclared identifier
CompilerResultsLog: Error: C:\ChangedManually\Source\Interactable/Items/ItemData.h(100) : error C2146: syntax error: missing ';' before identifier 'Z_Param_name'
CompilerResultsLog: Error: C:\ChangedManually\Source\Interactable/Items/ItemData.h(100) : error C2065: 'Z_Param_name': undeclared identifier
CompilerResultsLog: Error: C:\ChangedManually\Source\Interactable/Items/ItemData.h(100) : error C3861: 'GetDefaultPropertyValue': identifier not found

line 100 in ItemData.h :

GENERATED_BODY()

Problem seems to be fixed if I add :

#include "TextProperty.h" 

to ItemData.h

and specific components (Skeletal and Static Mesh refrences to header files) of other classes that had issues, but they weren’t needed yesterday (engine version is the same, and no other classes were added) - same issue is appearing on other developer machines as well - what could be the cause - IWYU related issue or what?

Just ran into a similar issue. I added a new class to my project for the first time since upgrading to 4.20 and everything worked fine, until I tried to add a second class and suddenly the project wouldn’t compile anymore. I had to include Engine/World.h in some unrelated classes. I guess compiling the code from the editor changed something.

Seems to have been an IWYU issue but it is unclear why it appeared randomly. (The way we utilize the code as developers is different so it could be that some editor based recompile could have been the initial cause of it but we haven’t had any issues since.)