Contracts

TypeScript

Before starting a Masquerade project, its critical to understand TypeScript at a minimum level.
You can read more from the TypeScript website, and there are many great blog posts and guides such as this one.

What are Contracts?

We use the term "contracts" as an alias for typings, however definitions with the suffix Contract should generally be defined as interfaces in most cases.

What are they for?

In addition to all the usual benefits of TypeScript, contracts help the framework understand the shape of your classes without prior knowledge of the class.
Any number of new contracts can be defined, but to augment the base framework Contract interfaces, we recommend using declare module like so.
1
declare module "@masqueradejs/backstage" {
2
export interface ConfigContract {
3
get(): ConfigurationSet
4
}
5
6
export interface ConfigurationSet {
7
browsers: BrowsersConfigurationContract
8
app: AppConfigurationContract
9
}
10
11
export interface BrowsersConfigurationContract {
12
chromelike?: BrowserConfig
13
}
14
}
Copied!