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
Search Terms:
mapped type, record, assignability, assignability compatibility, generic type, type parameter, generic mapped type, string index signature
Code
functionfoo<Textendsstring>(a1: Record<T,string>,a2: Record<string,string>,a3: {[PinT]: string}): Record<T,string>{a2=a1// no error, expecteda3=a2// error, expecteda1=a2// no error, not expected (!)returna2// no error, not expected (!)};
Expected behavior: a2: Record<string, string> is not assignable to a1: Record<T, string>. Also returned a2 is invalid.
Actual behavior: a1 = a2 compiles and returned value is assignable to declared return type.
The text was updated successfully, but these errors were encountered:
bela53
changed the title
Record<string, string> is assignable to Record<T, string>
Record<string, string> is assignable to Record<T, string>
Mar 25, 2020
TypeScript Version: 3.8.3-3.9.0-dev.20200324
Search Terms:
mapped type, record, assignability, assignability compatibility, generic type, type parameter, generic mapped type, string index signature
Code
Expected behavior:
a2: Record<string, string>
is not assignable toa1: Record<T, string>
. Also returneda2
is invalid.Actual behavior:
a1 = a2
compiles and returned value is assignable to declared return type.Playground Link:
here
Related Issues:
#28798
The text was updated successfully, but these errors were encountered: