TypeScript Version: 2.9.2
Search Terms: index signature pipe generic lost dictionary
Code
declarefunctionpipe<V0,T1,T2,T3>(fn0: (x: V0)=>T1,fn1: (x: T1)=>T2,fn2: (x: T2)=>T3,): (x: V0)=>T3;declarefunctiongetStringDict(): {[index: string]: string};declarefunctionstringDictIdentity<T>(stringDict: {[index: string]: T;}): {[index: string]: T};/*Without strict enabled:Expected type (x: {}) => { [index: string]: string; }Actual type (x: {}) => { [index: string]: {}; }With strict enabled, unexpected type error:Argument of type '<T>(stringDict: { [index: string]: T; }) => { [index: string]: T; }' is not assignable to parameter of type '(x: {}) => { [index: string]: {}; }'. Types of parameters 'stringDict' and 'x' are incompatible. Type '{}' is not assignable to type '{ [index: string]: {}; }'. Index signature is missing in type '{}'. */constfn=pipe(getStringDict,x=>x,stringDictIdentity,);//// Workarounds//declarefunctionidentity<T>(a: T): T;constfn2=pipe(getStringDict,identity,stringDictIdentity,);constfn3=pipe(getStringDict,x=>x,x=>stringDictIdentity(x),);
TypeScript Version: 2.9.2
Search Terms: index signature pipe generic lost dictionary
Code