Skip to content

Type inference lacking on index signature types #5089

@alexeagle

Description

@alexeagle

The compiler gives an error on the last line:

function s(p: {[k:string]:string}) {
    console.log(p);
}

let t: {[k:string]:string} = {thing: 'otherthing'};
s(t);

let t2 = {thing: 'otherthing'}; 
s(t2);

Index signature is missing in type '{thing: 'otherthing'}'

Which is very sad since I'm refactoring all of angular to use string index signatures instead of our hacky StringMap (angular/angular#4483)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions