类型约束,无解释

export enum MessageTypeEnum {
  TEXT = "text",
  IMG = "image",
  AUDIO = "audio",
  DELAY = "delay",
  INPUT = "input",
}

type MessageTypeDataMap = {
  [MessageTypeEnum.TEXT]: {
    text: string;
  };
  [MessageTypeEnum.IMG]: {
    uri: string;
  };
  [MessageTypeEnum.AUDIO]: {
    uri: string;
  };
  [MessageTypeEnum.DELAY]: {
    options: TimeOptionType;
  };
  [MessageTypeEnum.INPUT]: {
    text: any;
  };
};

type MessageType<T extends keyof MessageTypeDataMap, P> = {
  id: string;
  type: T;
  data: P;
};

export type SendMessageNodePayloadType = {
  messages: Array<
    {
      [K in keyof MessageTypeDataMap]: MessageType<K, MessageTypeDataMap[K]>;
    }[keyof MessageTypeDataMap]
  >;
};

//  测试
const a: NodeDataType<AutoMessage.NodeTypeEnum.SEND_MESSAGE> = {
  namespace: NodeNamespaceEnum.AUTO_MESSAGE,
  icon: "123",
  title: "123",
  type: AutoMessage.NodeTypeEnum.SEND_MESSAGE,
  payload: {
    messages: [
      {
        id: "123",
        type: MessageTypeEnum.IMG,
        data: {
          uri: "123",
        },
      },
    ],
  },
};