Skip to content

Mapped Types の as の解説を追加する #1003

@suin

Description

@suin

const options = ["Fill", "Zoom", "Minimize", "DoNothing"] as const;

type Option = (typeof options)[number];
const mappings = {
  Fill: "Fill",
  Zoom: "Maximize",
  Minimize: "Minimize",
  DoNothing: "None",
} as const satisfies Record<Option, string>;

type Mapping = typeof mappings;

const reverseMappings = Object.fromEntries(
  Object.entries(mappings).map(([key, value]) => [value, key])
) as { [K in keyof Mapping as Mapping[K]]: K };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions