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

Const with non-widening type as dynamic object literal key #12884

Closed
arusakov opened this issue Dec 13, 2016 · 3 comments
Closed

Const with non-widening type as dynamic object literal key #12884

arusakov opened this issue Dec 13, 2016 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@arusakov
Copy link
Contributor

arusakov commented Dec 13, 2016

TypeScript Version: master (c76a3a6)

Code

const x: 'x' = 'x';
const y: 'y' = 'y';

const z = {
  [x]: y
};

Expected behavior:
z has type { x: "y" }

Actual behavior:
z has type { [x: string]: 'y' }. It's inconsistency.

@arusakov arusakov changed the title Const with non-widening type as dynamic object key Const with non-widening type as dynamic object literal key Dec 13, 2016
@NN---
Copy link

NN--- commented Dec 13, 2016

Did you mean "z has type"?;)

@arusakov
Copy link
Contributor Author

@NN--- thank you

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Dec 13, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Dec 14, 2016

This is a duplicate of #5579.
The issue here is that the compiler does things in phases. the first phase, binding, it setts the names of properties on a type/symbol. the second is type resolution, that is when it knows about types of symbols. this change requires these two phases to be interleaved in a way, which is not a small change.

@mhegazy mhegazy added Duplicate An existing issue was already created and removed Bug A bug in TypeScript labels Dec 14, 2016
@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

4 participants