VS2022 can't find header files when I was trying to create a new module

When I following the video https://www.youtube.com/watch?v=53W2Kacw6TE&list=PL-m4pn2uJvXHL5rxdudkhqrSRM5gN43YN&index=10, I’m trying to create a module by using my own component. I create the .ccp and .h file for the module and also changed the necessary files like .Target.cs, ...ModuleName.Build.cs. When I include Engine.h or UnrealEd.h or Modules/ModuleInterface.h or Modules/ModuleManager.h. The IDE can’t complie them casue it can’t find those headers. How to fix this?

UnrealEd is editor only. So when you compile it’s elements would be stripped out during the compile process.

Perhaps you can add editor conditions to not make the compiler go crazy

#if WITH_EDITOR
// editor code that uses unrealed module here
#endif
#if WITH_EDITORONLY_DATA

Same thing with including UnrealEd.h => it should also be encompassed by conditional WITH_EDITORONLY_DATA