Skip to content

Why error (about Indexable Types) #12486

@printjs

Description

@printjs

TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)

Code

// A *self-contained* demonstration of the problem follows...

interface test{
   [index: number]:number;
   length: number;
}

 let abc:test;
 abc[1] = 213;
 console.log(abc[1]);

error tip

abc[1] = 213;
TypeError:Cannot set property '1' of undefined

Expected behavior:

Actual behavior:

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions