Skip to content

value literals act differently than literal type constants as indexes in index expressions #11820

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

Closed
zpdDG4gta8XKpMCd opened this issue Oct 24, 2016 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@zpdDG4gta8XKpMCd
Copy link

zpdDG4gta8XKpMCd commented Oct 24, 2016

nightly build Oct 24, 2016

const values: [number, string] = [1, 'a'];

const one = values[0]; // number, OK

const index = 0; // index is `0` (not just a number)
const another = values[index]; // expected number, actual: string | number <-- WHY?
@zpdDG4gta8XKpMCd zpdDG4gta8XKpMCd changed the title literal type literals act differently than literal type expressions as indexes in index expressions value literals act differently than literal type constants as indexes in index expressions Oct 24, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Oct 24, 2016

duplicate of #6678

@mhegazy mhegazy added the Duplicate An existing issue was already created label Oct 24, 2016
@zpdDG4gta8XKpMCd
Copy link
Author

zpdDG4gta8XKpMCd commented Oct 24, 2016

no, i don't agree it's a dup

now we have constant primitives as literal types, wheras that item doens't say anything about it

in other words, at that time it was a big deal to do
now with literal types it should be trivial (already works for literal values)

@RyanCavanaugh
Copy link
Member

This issue needs to be open because the other one hasn't been implemented yet? Please help me understand this

@zpdDG4gta8XKpMCd
Copy link
Author

the other one was created a year ago and asking for something that didn't have a chassis to be made
this one just states the fact that 2 expressions of the exact same type give different results

@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