"does not name a type" error when I have multiple *.ino files and ALL of the code is moved into one

@J-M-L moving the code as you suggested works.

Previously I was having loop and setup in my last tab/file as well and it was working just fine.

I experimented a lot more with this example and this is what is required to have in main file:

#include <ESP8266WiFi.h>
#include <Ticker.h>
#include <AsyncMqttClient.h>

WiFiEventHandler wifiConnectHandler;
WiFiEventHandler wifiDisconnectHandler;

void setup() {
  st();
}

void loop() {}

I put rest of the stuff into 2nd file and i put st() method into 3rd file, which has everything that previously was in setup().

I couldn't compile it with any possible combination of code split when setup wasn't in main file so I guess in some circumstances is a must.

I will try to learn working with .cpp + .h files, it looks tedious a bit, because I'm basically repeating myself in the header files and I need to update two places when I update my a function or something. Working with *.ino files I was able to define a class inside single file and modify it when I want to change something and use it in other files.