TS satisfies documentation wrong?

  Kiến thức lập trình

I was reading the docs on the satisfies operator and I just copied the third code snippet and it didn’t work:

type Colors = "red" | "green" | "blue";
type RGB = [red: number, green: number, blue: number];
const palette = {
    red: [255, 0, 0],
    green: "#00ff00",
    blue: [0, 0, 255]
} satisfies Record<Colors, string | RGB>;

const redComponent = palette.red.at(0); // Property 'at' does not exist on type '[number, number, number]'.(2339)
const greenNormalized = palette.green.toUpperCase();

LEAVE A COMMENT