Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index signature incorrectly treats object properties #13421

Closed
hinell opened this issue Jan 11, 2017 · 2 comments
Closed

Index signature incorrectly treats object properties #13421

hinell opened this issue Jan 11, 2017 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@hinell
Copy link

hinell commented Jan 11, 2017

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.

@normalser
Copy link

FYI #12596

@hinell
Copy link
Author

hinell commented Jan 12, 2017

@wallverb Ah, thanks.

@hinell hinell closed this as completed Jan 12, 2017
@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 12, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants