Skip to content

Index signature is assignable to weak type whose properties don't match the signature type #27144

Open
@mattmccutchen

Description

@mattmccutchen

From https://stackoverflow.com/q/52368008 . Based on #16047 (comment), it appears that @sandersn may have thought about the rule, but it still makes no sense to me and no rationale is stated.

TypeScript Version: master (394ee31)

Search Terms: weak type index signature

Code

interface Foo {
    a?: string;
}
interface Bar {
    [n: string]: number;
}
declare let b: Bar;
// No error; expected "Type 'Bar' has no properties in common with type 'Foo'."
let a: Foo = b;

Expected behavior: Error: "Type 'Bar' has no properties in common with type 'Foo'."

Actual behavior: No error.

Playground Link: link

Related Issues: Possibly #9900

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions