I am looking to create a subset interface, FooAppStateSubset, from the main AppState interface in order to streamline coding against specific properties needed for certain sections of our website. This subset will only contain properties that are populated by controller classes further up in the pipeline.
My requirements:
- Ensure that FooAppStateSubset ONLY includes properties and values present in AppState
- Do not require FooAppStateSubset to list non-optional parameters from AppState
- Error at compile and build time if rules 1 and 2 are violated
- Autocomplete for properties would be a nice-to-have feature
- Ability to define models throughout the site without having to implement them all in the master AppState interface
MODELS:
interface AppState {
email: string;
userId: number;
firstName?: string;
isAwesome: boolean;
}
interface/type FooAppStateSubset {
isAwesome: boolean;
firstName?: string;
}