Skip to content

Access object with empty-string key #15209

@ikatyang

Description

@ikatyang

TypeScript Version: 2.3.0-dev.20170415

{
  "compilerOptions": {
    "strict": true
  }
}

Code

declare const x: {
  '': string;
  'a': string;
  'a-b': string;
}

x[''] // error TS7017: Element implicitly has an 'any' type because type '{ '': string; 'a': string; 'a-b': string; }' has no index signature.
x['a'] // fine
x['a-b'] // fine

Expected behavior:
no error

Actual behavior:
error TS7017: Element implicitly has an 'any' type because type '{ '': string; 'a': string; 'a-b': string; }' has no index signature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions