Skip to content

Instantly share code, notes, and snippets.

@mkczarkowski
Created October 3, 2022 18:51
Show Gist options
  • Save mkczarkowski/899f8424e7a959520a4a48e45aeac92f to your computer and use it in GitHub Desktop.
Save mkczarkowski/899f8424e7a959520a4a48e45aeac92f to your computer and use it in GitHub Desktop.
type Colors = "red" | "green" | "blue";
type HSL = [hue: number, saturation: string, lightness: string];
type ColorPalette = Record<Colors, string | HSL>
const palette = (): Promise<ColorPalette> => new Promise((resolve, reject) => {
resolve({
red: [0, '100%', '50%'],
green: "#00ff00",
blue: [240, '100%', '50%']
})
});
const justAPalette = await palette() satisfies ColorPalette;
const blueHslCssFunction = `hsl(${justAPalette.blue.join('')})` // Property 'join' does not exist on type 'string | HSL'.
// Property 'join' does not exist on type 'string'.ts(2339)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment