Skip to content

Mapped types regression with v3.6.2 #33210

Closed
@lemoustachiste

Description

@lemoustachiste

TypeScript Version: 3.6.2

Search Terms: Mapped Types, MappedTypes, MappedType

Code

export enum LayoutElementType {
  Image = 'image' as any
}

const layoutElementTypesMap: { [key in LayoutElementType]: string } = {
  'image': PLATFORM.moduleName('components/record/record-layout/element/image.html')
};

Expected behavior: as described here: #2491 (comment), this should be a work around to map an enum to object keys. We were using it successfully until v3.5.3 (I just installed v3.5.3 to double check and no error).

Actual behavior: Typescript complains:
Object literal may only specify known properties, and ''image'' does not exist in type '{ [x: number]: string; }'.
Looks similar to this: #2491 (comment)

Playground Link:

Related Issues: #2491

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions