I want to change the text color of an Annotation Layer based on layer visibility.
Annotation Text shown here in yellow.

The yellow text does not change. I can change certain properties, like minScale, but I cannot add a labelingInfo class.
some info about the layer
Display Field: TEXTSTRING
Type: Annotation Layer
Has Labels: false
Can Modify Layer: false
Can Scale Symbols: true
Type ID Field: AnnotationClassID
Fields:
- OBJECTID ( type: esriFieldTypeOID , alias: OBJECTID )
- FEATUREID ( type: esriFieldTypeInteger , alias: FEATUREID )
- ZORDER ( type: esriFieldTypeInteger , alias: ZORDER )
- ANNOTATIONCLASSID ( type: esriFieldTypeInteger , alias: ANNOTATIONCLASSID )
- ELEMENT ( type: esriFieldTypeBlob , alias: ELEMENT )
- SYMBOLID ( type: esriFieldTypeInteger , alias: SYMBOLID )
- STATUS ( type: esriFieldTypeSmallInteger , alias: STATUS , Coded Values: [0: Placed] , [1: Unplaced] )
- TEXTSTRING ( type: esriFieldTypeString , alias: TEXTSTRING , length: 255 )
- FONTNAME ( type: esriFieldTypeString , alias: FONTNAME , length: 255 )
- FONTSIZE ( type: esriFieldTypeDouble , alias: FONTSIZE )
- BOLD ( type: esriFieldTypeSmallInteger , alias: BOLD , Coded Values: [1: Yes] , [0: No] )
- ITALIC ( type: esriFieldTypeSmallInteger , alias: ITALIC , Coded Values: [1: Yes] , [0: No] )
- UNDERLINE ( type: esriFieldTypeSmallInteger , alias: UNDERLINE , Coded Values: [1: Yes] , [0: No] )
- VERTICALALIGNMENT ( type: esriFieldTypeSmallInteger , alias: VERTICALALIGNMENT , Coded Values: [0: Top] , [1: Center] , [2: Baseline] , ...1 more... )
- HORIZONTALALIGNMENT ( type: esriFieldTypeSmallInteger , alias: HORIZONTALALIGNMENT , Coded Values: [0: Left] , [1: Center] , [2: Right] , ...1 more... )
- XOFFSET ( type: esriFieldTypeDouble , alias: XOFFSET )
- YOFFSET ( type: esriFieldTypeDouble , alias: YOFFSET )
- ANGLE ( type: esriFieldTypeDouble , alias: ANGLE )
- FONTLEADING ( type: esriFieldTypeDouble , alias: FONTLEADING )
- WORDSPACING ( type: esriFieldTypeDouble , alias: WORDSPACING )
- CHARACTERWIDTH ( type: esriFieldTypeDouble , alias: CHARACTERWIDTH )
- CHARACTERSPACING ( type: esriFieldTypeDouble , alias: CHARACTERSPACING )
- FLIPANGLE ( type: esriFieldTypeDouble , alias: FLIPANGLE )
- OVERRIDE ( type: esriFieldTypeInteger , alias: OVERRIDE )
- SHAPE_AREA_1 ( type: esriFieldTypeDouble , alias: SHAPE_AREA_1 )
- SHAPE_LEN_1 ( type: esriFieldTypeDouble , alias: SHAPE_LEN_1 )
- SHAPE ( type: esriFieldTypeGeometry , alias: SHAPE )
- SHAPE.AREA ( type: esriFieldTypeDouble , alias: SHAPE.AREA )
- SHAPE.LEN ( type: esriFieldTypeDouble , alias: SHAPE.LEN )
Here is my map
var mapLayerAndLabels = new MapImageLayer({
url: mapLayerAndLabelsUrl,
legendEnabled: true,
visible: true,
title: "Map Layers & Labels"
}); // end mapLayerAndLabels
map.add(mapLayerAndLabels);
Here is my basic labelClass that will be added on layer visibility
const labelClass = {
// autocasts as new LabelClass()
symbol: {
type: "text", // autocasts as new TextSymbol()
color: "green"
},
font: { // autocast as new Font()
size: 20,
family: "sans-serif",
weight: "bold"
}
};
The target layer. labelingInfo is null

watch event to add the labelClass
watchUtils.whenFalse(item, "visible", function (newVal) {
switch (item.title) {
case "Latest Aerial":
if (!item.visible) {
if (item.layer.parent.allLayers && item.layer.parent.allLayers.length > 0) {
item.layer.parent.allLayers.forEach(function (item) {
if (item.title === "Map Layers & Labels") {
if (item.sublayers && item.sublayers.length > 0) {
item.sublayers.forEach(function (item) {
if (item.title === "Parcel Dimensions") {
item.minScale = 55555; // this changes
item.labelingInfo = [labelClass]; // not working
}
});
}
}
});
}
}
} // end switch
}); // end whenFalse