Mega 2560 WiFi - error: 'PinStatus' does not name a type

This library allows you to use the Arduino UNO WiFi Rev.2, Arduino NANO 33 IoT, Arduino MKR 1010 and Arduino MKR VIDOR 4000 WiFi capabilities
Arduino - WiFiNINA

You are using the wrong library

Use WiFiEsp