Typescript: Enforce a type to be “string literal” and not <string>
问题 Problem Is there a way in Typescript to define a type that is only a string literal, excluding string itself? Note that I am not talking about a certain list of string literal; for which, a simple union of "Value1" | "Value2" , or an enum type would work. I am talking about any string literal, but not string itself. Example Code type OnlyStringLiterals = ...; // <--- what should we put here? const v1: OnlyStringLiterals = "hi"; // should work const v2: OnlyStringLiterals = "bye"; // should