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

Issue with mapped types and enums #17288

Closed
blocka opened this issue Jul 19, 2017 · 3 comments
Closed

Issue with mapped types and enums #17288

blocka opened this issue Jul 19, 2017 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@blocka
Copy link

blocka commented Jul 19, 2017

TypeScript Version: 2.4.1 /

Code

enum Things {
	ONE = "one",
	TWO = "two"
}

type ThingMap = { [TKey in Things]: any };

const thingMap: ThingMap = {
	one: null,
	two: null
};

function setThing(thing: Things, something: any) {
	thingMap[thing] = something;
}

Expected behavior:
Just like I can do thingMap[Things.ONE] = 'blah' without any errors, this should not throw an error.
Actual behavior:
src/test.ts(14,2): error TS7017: Element implicitly has an 'any' type because type 'ThingMap' has no index signature.

@Jessidhia
Copy link

Seems related to #16687

@blocka
Copy link
Author

blocka commented Jul 19, 2017

I encountered that too but it's not quite the same thing.

@mhegazy mhegazy added the Needs Investigation This issue needs a team member to investigate its status. label Aug 29, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Aug 30, 2017

Actually duplicate of #16760, and should be fixed by #18029

@mhegazy mhegazy closed this as completed Aug 30, 2017
@mhegazy mhegazy added Duplicate An existing issue was already created and removed Needs Investigation This issue needs a team member to investigate its status. labels Aug 30, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 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