Skip to content

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

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 };

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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