Skip to content

Adding indexer to global Object makes other interfaces incompatible with Object #835

Closed
@csnover

Description

@csnover

Between 0.9.1 and 0.9.5 the explicit indexer was removed from Object. Between 1.0 and 1.1, code that adds the indexer back to Object causes type comparison failures:

interface Object {
    [key:string]:any;
}

interface Foo {}

function a(b:Object) {}

var foo:Foo;
a(foo); // error TS2345: Argument of type 'Foo' is not assignable to parameter of type 'Object'.

Putting an indexer on Foo makes it work.

This is probably an OK error since adding back the indexer like this to Object should probably be considered an anti-pattern, and since in ES5 you can create inheritance patterns that don’t extend from Object, but it should at least be documented as a known breaking change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions