I have implemented a widget tool for our ArcGIS Enterprise solution, similar to the SelectLayerByAttribute tool from ArcGIS Pro, however, I am having trouble trying to get the information regarding the fields. The provided information in the documentation and the forums are not up to date, as all suggested answers do not work, despite any service url that is being provided.
I can see, that the information is there, but hidden by a proxy object. If the web map is using a FeatureServer REST service, we are able to fetch the '_fields' and deconstruct the proxy object, but if the web map is using a MapServer REST service, we are not able to even call the property and store it in a variable. Any solutions to this?

Code:
this.layerStructure.traversal((layerNode) => {
let featureLayerUrl = layerNode?._layerInfo?.layerObject?.url;
let featureLayer = new FeatureLayer(featureLayerUrl);
console.log("featureLayer._fields", featureLayer._fields);
} Exception:
ReferenceError: _fields is not defined
at dno_presenter.js?wab_dv=2.20:215
at LayerNode.js?wab_dv=2.20:127
at Object.traversal (LayerInfo.js?wab_dv=2.20:156)
at Object.traversal (LayerNode.js?wab_dv=2.20:126)
at Object._traversal (LayerStructure.js?wab_dv=2.20:124)
at Object.traversal (LayerStructure.js?wab_dv=2.20:146)
at Object.initLayers (dno_presenter.js?wab_dv=2.20:212)
at Object.initializeLayersWithFields (dno_presenter.js?wab_dv=2.20:508)
at Object.initComponents (dno_presenter.js?wab_dv=2.20:80)
at Object.initPresenter (Widget.js?wab_dv=2.20:22)