nathanoy
nathanoy
Explore posts from servers
TTCTheo's Typesafe Cult
Created by nathanoy on 5/6/2024 in #questions
Array.pop() cant be undefined after if check, but typescript doenst know.
Hi, i have this snipped in my code:
if (x.length > 1) {
let entry = x.pop();
this.setSelected(0);
}
if (x.length > 1) {
let entry = x.pop();
this.setSelected(0);
}
x is of type Entry[] And pop returns Entry | undefined My question is: How can i tell typescript that it can not be the undefined branch?
6 replies