Skip to content

Index signature incorrectly treats object properties #13421

Closed

Description

TypeScript Version: 2.1.4 - Windows version tsc.cmd
Description: Index signature bug.

var foo: { bar?: 0; [key: string]: any } = {};
foo.newProp   = '';  // Error: Property 'newProp' does not exist on type of foo
foo['newProp']= ''   // NO error!!! Same code!

How is it possible? 😕

Expected behavior: NO error.
Actual behavior: Error exists.

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