Skip to content

Numeric enums as key types in mapped types#31784

Merged
ahejlsberg merged 6 commits into
masterfrom
numericEnumMappedType
Jun 6, 2019
Merged

Numeric enums as key types in mapped types#31784
ahejlsberg merged 6 commits into
masterfrom
numericEnumMappedType

Conversation

@ahejlsberg
Copy link
Copy Markdown
Member

This PR fixes a minor issue related to numeric enums as key types in mapped types. We now generate a numeric index signature when a numeric enum type occurs in the key type of a mapped type. Previously we wouldn't generate anything which was inconsistent.

The PR also fixes a crash that is triggered by the following code:

declare enum E { ONE, TWO, THREE = 'x' }
const e: E = E.ONE;
const x: E.ONE = e;

Fixes #31771.

Comment thread tests/cases/compiler/numericEnumMappedType.ts
@ahejlsberg ahejlsberg requested a review from weswigham June 6, 2019 16:44
@ahejlsberg ahejlsberg merged commit 4ae3a54 into master Jun 6, 2019
@ahejlsberg ahejlsberg deleted the numericEnumMappedType branch June 6, 2019 22:00
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Index signature error for mapped type when keyed on declare enum

2 participants