找出命令注册表里的 bug

来自 satisfies 操作符
TypeScript 6 进阶 4分钟 找出 2处问题

找出这个生成的命令注册表为何无法保证声明的命令集合。

TypeScript
type Command = { label: string; run(): void };
type CommandName = "build" | "deploy";

const commands = {
  build: { label: "Build", run: () => console.log("building") },
  delpoy: { label: "Deploy", run: () => console.log("deploying") },
} satisfies Record<string, Command>;

function execute(name: CommandName): void {
  commands[name].run();
}

execute("deploy");
在试验场中打开
报告错误