To type an object in TypeScript, you can define an interface that describes the shape of the object. Here is an example:
index.ts233 chars14 lines
In this example, we've created an interface
called Person
that defines the properties name
, age
, and isStudent
with their respective types. Then we've created an object person
that conforms to this interface.
gistlibby LogSnag