- work in tandem with the utility types
- which are included in TS and available globally
Type guards and Differentiating Types
- Union types are useful for modeling situation
- values can overlap in the types
- it make access members that are guaranteed to be in all the constituents of a union type.
class AbstractView {
constructor() {}
}
type Page = {
path: string;
view: AbstractView;
};
const page: Page = {
path: '',
view: new AbstractView
}
// (1) 'in' operator check
console.log('path' in page);