Thank you very much for the support. It looks like the error occurs if AsyncWebServer is used in one of the translation units of the library, but the according header file is not included in main.cpp. This feels very strange for me…
But you said this kind of problem is known for the ESPAsyncWebserver library? Perhaps I will switch to another library.