TypeScript Version: 2.1.4
Code
// Type with index signaturetypeStringToNumber={[id: string]: number};// This works!typeShouldBeNumber=StringToNumber[keyofStringToNumber];letx: ShouldBeNumber=<number>0;lety: number=x;// This doesn't work.classPred<XextendsStringToNumber>{test(value: X[keyofX]){// error TS2322: type 'X[keyof X]' is not assignable to type 'number'letslot: number=value;// error TS2352: Type 'X[keyof X]' cannot be converted to type 'number'.letslot2=<number>value;}}Expected behavior:
If I understand the spec correctly, all of X's properties must be subtypes of their corresponding properties in StringToNumber. All of StringToNumber's properties are of type number, so X[keyof X] should be a subtype of / assignable to number.
Actual behavior:
As far as I can tell, no relationship is inferred between the types X[keyof X] and number.
TypeScript Version: 2.1.4
Code
Expected behavior:
If I understand the spec correctly, all of
X's properties must be subtypes of their corresponding properties inStringToNumber. All ofStringToNumber's properties are of typenumber, soX[keyof X]should be a subtype of / assignable tonumber.Actual behavior:
As far as I can tell, no relationship is inferred between the types
X[keyof X]andnumber.