Skip to content

[Errors] Empty object contextually typed by type with indexer #48

Closed
@mhegazy

Description

@mhegazy
interface Foo { a }
interface Bar { b }

interface Object {
    [n: number]: Foo;
}

interface Function {
    [n: number]: Bar;
}

var o = {};
var f = () => { };

var v1: {
    //!!! Cannot convert '{}' to '{ [x: number]: Foo; }':
    //!!!   Numeric index signature is missing in type '{}'.
    [n: number]: Foo
} = o;  
var v2: {
    //!!! Cannot convert '() => void' to '{ [x: number]: Bar; }':
    //!!!   Numeric index signature is missing in type '() => void'.
    [n: number]: Bar
} = f;  

Expected: no errors

Actual: errors in the comments above

Verify test case:
tests/cases/compiler/augmentedTypeBracketAccessIndexSignature.ts
tests/cases/conformance/types/members/objectTypeWithCallSignatureHidingMembersOfExtendedFunction.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeBugA bug in TypeScriptFixedA PR has been merged for this issueSpecIssues related to the TypeScript language specification

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions