Skip to content

Comparison operator on types with indexer signatures returning object types #401

@danquirk

Description

@danquirk
class Base {
        public a: string;
}

class Derived extends Base {
        public b: string;
}



var a4: { [index: number]: Base };
var b4: { [index: string]: Derived }; 

var r1a1 = a4 < b4;

Actual: no error
Expected: Operator '<' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: string]: Derived; }'.

The current behavior matches the old compiler because fixing this would be a breaking change we aligned them. Worth considering whether to just take the break since it's unlikely someone would take an intentional dependeny on this undefined behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptBy DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions