Counterintuitively but this will result into "B".
const test: any[] = [] if(!test){ console.log("A") }else{ console.log("B") }
I figure you want to loose negation (Since you probably only want to append data if there is already some).