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
{{ message }}
Repository navigation
Bug report about keyof with class implements. #17822
index.ts(23,14): error TS2420: Class 'Class' incorrectly implements interface 'IClass'.
Types of property 'config' are incompatible.
Type '<T extends IOptions, K extends keyof T>(key: K, value: T[K]) => void' is not assignable to type '<T extends IOptions, K extends keyof T>(key: K, value: T[K]) => void'. Two different types with this name exist, but they are unrelated.
Types of parameters 'key' and 'key' are incompatible.
Type 'K' is not assignable to type '"name"'.
Type 'keyof T' is not assignable to type '"name"'.
This is working as intended and is an effect of #16368. When relating the config methods in the example it isn't possible for the checker to conclude that the T type parameters are related because no parameters use T in a manner from which inferences can be made. This also means that in calls to config it isn't possible to infer type arguments for T, so such calls will always just default to the IOptions bound unless type arguments are explicitly specified--which in turn means the T type argument is pretty much pointless.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Activity
aluanhaddad commentedon Aug 16, 2017
This seems to work in 2.3.3 and error in nightly.
ahejlsberg commentedon Aug 18, 2017
This is working as intended and is an effect of #16368. When relating the
configmethods in the example it isn't possible for the checker to conclude that theTtype parameters are related because no parameters useTin a manner from which inferences can be made. This also means that in calls toconfigit isn't possible to infer type arguments forT, so such calls will always just default to theIOptionsbound unless type arguments are explicitly specified--which in turn means theTtype argument is pretty much pointless.I suggest changing the declarations to:
mhegazy commentedon Sep 18, 2017
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.