Skip to content

dot style assignment not works with indexed object interface #12611

Closed

Description

TypeScript Version: 2.1.1

Code

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

const plugins: Dictionary = {}

plugins.test = {}

const plugins2: {
    [key: string]: any;
} = {}

plugins2.test = {}

Expected behavior:
no error

Actual behavior:

Property 'test' does not exist on type 'Dictionary'.
any

See the playground example

IMHO, dot style assignment should infer the property name as string

I think it's related to #6041

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions