I am using a webmap in my mapview. Once the view is ready (i.e. after view.when()), I do the following to produce the output on the right in the image below:
Hi there,
https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#allLayers - according to the document, allLayers collection contains basemap layers, operational layers and ground layers. Group Layers and their children layers are also part of this collection.
So for MapImageLayer you'd have to use https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#allSubl... to get its sublayers. Same thing goes for TileLayer.