An array of strings (holder.positions) is stored in Holder. The main purpose of this function is to add the ID of the position parameter to the array.
Below is the function used:
function updateHolder(holder: Holder, position: Position): void {
if(holder.positions == null){
const positions: string[] = [];
holder.positions = positions;
}
holder.positions.push(position.id);
}
An error occurs:
ERROR TS2322: Type '~lib/array/Array<~lib/string/String> | null' is not assignable to type '~lib/array/Array<~lib/string/String>'.
holder.positions.push(position.id);
~~~~~~~~~~~~~~~~
This error message suggests that "the value being pushed onto the array is either a string array or null, but it must be a string array." This explanation is not clear to me.