You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeScript Version: 2.6.1
also tested and fails on 2.7.0
also tested and fails on 2.7.0-dev.20180119 (@next)
Code
typeMyType<T>={[KinkeyofT]: string|true|PromiseLike<string|true>};functionMapObject<T,TOut>(value: T,map: <KextendskeyofT>(value: T[K],key: K)=>TOut) : {[KinkeyofT] : TOut}{returnnullasany;}//MyFunction//2.5.3 compiles//2.6.1 do not compiles since ret variable is not compatible with the function return value//@next do not compiles since ret variable is not compatible with the function return valuefunctionMyFunction<T>(value: MyType<T>) : {[KinkeyofT] : Promise<string|undefined>}{consta=MapObject(value,x=>x);//B should be { [K in keyof T ]: Promise<string | undefined>}constb=MapObject(a,asyncx=>{//myVal type://(correct) 2.5.3: string | true//(incorrect) 2.6.1: { [K in keyof T]: MyType<T>[any] }[K]//(incorrect) @next: { [K in keyof T]: MyType<T>[any] }[K]constmyVal=awaitx;//ret type should be string | undefined//(correct) 2.5.3: string | undefined //(incorrect) 2.6.1: { [K in keyof T]: MyType<T>[any] }[K] | undefined//(incorrect) @next: { [K in keyof T]: MyType<T>[any] }[K] | undefinedconstret=myVal===true ? undefined : myVal;returnret;})returnb;}
Expected behavior: myVal variable inferred type to be string | true ret variable inferred type to be string | undefined
The code should compile since the return value of the function type and the return expression is the same
Actual behavior: myVal variable inferred type is { [K in keyof T]: MyType<T>[any] }[K] ret variable inferred type is { [K in keyof T]: MyType<T>[any] }[K] | undefined
The code does not compile since the return type does not match the return expression
The text was updated successfully, but these errors were encountered:
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.6.1
also tested and fails on
2.7.0
also tested and fails on
2.7.0-dev.20180119
(@next)Code
Expected behavior:
myVal
variable inferred type to bestring | true
ret
variable inferred type to bestring | undefined
The code should compile since the return value of the function type and the return expression is the same
Actual behavior:
myVal
variable inferred type is{ [K in keyof T]: MyType<T>[any] }[K]
ret
variable inferred type is{ [K in keyof T]: MyType<T>[any] }[K] | undefined
The code does not compile since the return type does not match the return expression
The text was updated successfully, but these errors were encountered: