Loading topic
string, number, and boolean. You should also be comfortable writing functions, object literals, and switch statements in JavaScript.2 min readswitch statements. This chapter shows how to combine literal types into a union that represents a fixed set of allowed values.2 min readswitch statements. This chapter explains how TypeScript infers types for variables whose values look like specific literals.2 min readswitch statements. You will learn how as const prevents TypeScript from widening specific values into general types.2 min readswitch statements. A numeric enum is useful when a program needs a named set of numeric values, such as priority levels, states, or protocol codes.2 min readswitch statements. It focuses on string enums, how they behave at runtime, and when they are a better choice than a union of string literals.2 min readswitch statements. The focus here is runtime behavior: what JavaScript TypeScript generates for enums and how numeric enums support reverse mapping.2 min readswitch statements. The goal is to choose a good representation when a value must come from a fixed set.2 min readswitch statements. It also assumes you have seen union types. A union type allows a value to belong to one of several types.2 min read Hello, ${name} `. A template literal type uses a similar syntax to build a set of allowed string types a2 min readswitch statements. You should also know that TypeScript is compiled into JavaScript before it runs.3 min readas const and understand that TypeScript can infer a type from a value.2 min read