If you just installed Visual Studio, it is likely that you are using the latest MSVC toolchain (14.39) which has a compiler bug and Unreal will complain if you try to compile using that.
To fix that, open the Visual Studio 2022 installer, click “Modify” on your Visual Studio 2022 install, select the v14.38 toolchain, and hit “Modify”