Overheard conversation on the street:
Q: Can I assign an array literal to a tuple in TypeScript?
A: Yes, sometimes you can.
letvalue : [string,string];value=['hey','nay'];// <-- works, an array literal can be assigned to a tuple functionfold<a,r>(values: a[],result: r,fold: (result: r,value: a)=>r) : r{for(letvalueofvalues){result=fold(result,value);}returnresult;}functionappend<a>(values: a[],value: a) : a[]{values.push(value);returnvalues;}fold([1,2,3],<[string,string][]>[],(result,value)=>append(// <-- doesn't work, an array literal is not assignable to tuple result,['','']));
Overheard conversation on the street: