javascript - Flow type and merging json objects -


assume code of following kind (e.g. using lodash or explicitly here):

function extend(base, overwrite) {     (var key in overwrite)         base[key] = overwrite[key];     return base; }  var first = extend({     a: 1 }, {     b: 2 });  var second = extend({     c: 3 }, {     d: 4 });  console.log(first.a + first.b + second.c + second.d); 

how can explain flowtype fine?

try putting above function declaration:

declare function extend<a, b>(a: a, b: b): & b 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -