Interface with typed indexer fails to compile for typed arrays.


Consider an interface that only declares a typed indexer [index: number] : number. Casting from number[] to this interface fails at compile time saying that the types are invalid.

The details and specifics of this issue is on my SO post: http://stackoverflow.com/questions/13074851/possible-to-define-indexer-interface-for-number
Closed Jun 13, 2013 at 7:15 PM by RyanCavanaugh
Fixed in develop branch


RyanCavanaugh wrote Nov 6, 2012 at 1:22 AM

Thanks for reporting this issue! Marking it as 'Active' (to be fixed).

dtebbs wrote Nov 16, 2012 at 8:43 AM

Another issue related to this bug is:


Declaring arguments that can be any[], Array or ArrayBufferView objects.

MizardX wrote Nov 26, 2012 at 4:02 AM

An array-type is only compatible with other array-types, with compatible element-types1. A type is only considered an array-type if it has an element-type2. The element-type is only set for types defined with a "[]"-suffix3. Thus, interface-types with indexers are not considered array-types, and are not compatible with array-types.

omidkrad wrote Jan 28, 2013 at 6:38 PM