Search⌘ K
AI Features

Creating a strongly-typed object

Explore how TypeScript infers object types and learn to apply explicit type annotations for objects in your React apps. Understand how to create reusable and strongly-typed objects that enhance reliability and maintainability in your codebase.

Inferred object types #

In the code below, what has TypeScript inferred the type of tomScore to be?

TypeScript 3.3.4
const tomScore = {
name: "Tom",
score: 70
}

Later in the program, if we ...