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
I was expecting this to work after #15473 was merged:
constmySymbol=Symbol('My Symbol');interfaceTypeA{[mySymbol]: Function;// OK[x: number]: number;}interfaceTypeB{[mySymbol]: Function;// ERROR: Property '[mySymbol]' is not assignable to string index type[x: string]: string;}leta: TypeA,b: TypeB;leta1=a[mySymbol];// a1 has type Functionleta2=a[42];// a2 has type numberletb1=b[mySymbol];// b1 has type Functionletb2=b['foo'];// b2 has type string
Expected behavior:
No compiler errors. mySymbol is a unique symbol as per #15473 and should not overlap either numeric index types or string index types.
Actual behavior:
Error in TypeB as shown in the code above. TSC rejects the unique symbol key because it is not compatible with the string index type, even though it is not a string property key.
Note that the types of a1, a2, b1 and b2 are all inferred correctly despite the compile error.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 2.7.0-dev.20171118
Code
I was expecting this to work after #15473 was merged:
Expected behavior:
No compiler errors.
mySymbol
is a unique symbol as per #15473 and should not overlap either numeric index types or string index types.Actual behavior:
Error in
TypeB
as shown in the code above. TSC rejects the unique symbol key because it is not compatible with the string index type, even though it is not a string property key.Note that the types of
a1
,a2
,b1
andb2
are all inferred correctly despite the compile error.The text was updated successfully, but these errors were encountered: