I'm trying to learn Typescript with React, but this error got in my way. I don't understand why is it even happening. Here it is. Creating an array of strings that looks like colors array down there. I want to create types based on values of that array ("white" | "red" | "blue").
const colors = ["white", "red", "blue"] as const;
type Colors= typeof colors[number];
Run Code Online (Sandbox Code Playgroud)
If I do it like this, it works, Colors has wanted types
const colorsArr = …Run Code Online (Sandbox Code Playgroud)