Literal Types

Literal types allow you to specify the exact value an object must have. In many cases, they can be combined with union types to express a finite set of possible values.

type ButtonSizes = "small" | "medium" | "large";


Define a function that accepts a parameter with a literal type of either "ascending" or "descending", and returns a corresponding message.

Copyright © Read our Terms of Use and Privacy Policy