I've come across what I believe to be a bug in ArcGIS Javascript API versions 4.16 or greater. I have a simple webscene with elevation layer, basemap and tiled aerial imagery layer. The elevation and aerial imagery were created in Pro using Manage Tiles Cache, then exported to .tpkx, shared with Portal and published through the Portal interface. The web scene works perfectly in the Scene Viewer:
https://gisportal.scc.qld.gov.au/portal/home/webscene/viewer.html?webscene=dd5e07c09fcc4ace9e4559e16e74d617
However when I load the same webscene using the Javascript API I get an Invalid layer item type 'Map Service', expected 'Image Service' error, and the aerial imagery does not display:

Here's a CodePen showing the error: https://codepen.io/TimMcG/pen/yLEXweG (just using the Load A Basic Web Scene sample, with config for my portal)
If you change the API version to 4.15 it works, but 4.16 or later shows the error.
ArcGIS Enterprise \ Portal version is 10.8.1.
Why it's a bug:
Well, the web scene works perfectly well in Scene Viewer. It's created in the standard way using Pro and Portal - I really can't do anything differently on my side of things. The fault is clearly with the Javascript API being unable to display my scene. And 10.8.1 and 4.16 were released in the same month, so they should work together.
Thanks for any assistance.