Given this typescript (2.7.2) interface:
export interface A {
b?: string;
c?: boolean;
}
This will print boolean 'false' as expected:
let a: A = {b: ''};
if (a.b && a.b.length > 0) {
a.c = true;
} else {
a.c = false;
}
console.log(a.c);
However, this prints an empty '' string:
let a: A = {b: ''};
a.c = a.b && a.b.length > 0;
console.log(a.c);
I'm a bit confused here. The second example should behave like the first one, right? What am I missing?