How does typescript define that the return value of a function is one of several fixed values

when using typescript, for the first time, suppose that a function may return one of more than 12345 digits, how should the return value of the function be defined?

Apr.02,2021

type Result = 1|2|3|4|5;
declare function foo(): Result;
Menu