It really has nothing to do with the if/else expression. The peer types are being resolved correctly. The same error can be produced with something as simple as: var foo = 5;