Models mean a lot of things to a lot of people. Here, they are simple definitions of the data we expect when we refer to a certain entity. At runtime, they provide little benefit, however, in TypeScript, they can help us understand the code that uses them, and ensures we use the correct attribute names when interacting with the data.
Authoring a Model
Models can be found in the src/Models directory. Model files should be in title-case, for example Example.ts rather than example.ts. These files should also then be imported into Models.ts and added to the union type defining Models.
Lets break down the User model and examine how its built.
Note that whilst this looks like your everyday household JavaScript object, after each line, there is a semi-colon. This tells TypeScript that we have finished defining that attribute.
Some attributes have a ? at the end of the attribute name. This denotes that it is optional.
_id is using a custom type definition. It is an XUID of type User as enumerated by the SupportedXuid enum.