Mixins and more in TypeScript 2.2

Refinements: The object type and dotted property access

Our Favorite Update: Support for mixins and composable classes!

Increased use of decorators

export interface GridRowMixin extends WidgetMixin<GridRowProperties>, RegistryMixin { }export type GridRow = Widget<GridRowProperties> & Themeableexport interface GridRowFactory extends WidgetFactory<GridRowMixin, GridRowProperties> { }const createGridRow: GridRowFactory = createWidgetBase
.mixin(registryMixin)
.mixin(themeable)
.mixin({
mixin: {
baseClasses: css,
diffPropertyItem(this: GridRow, previousProperty: any, newProperty: any): PropertyChangeRecord {
let changed;
if (typeof newProperty.equals === ‘function’) {
changed = !newProperty.equals(previousProperty);
}
else {
changed = newProperty !== previousProperty;
}
return {
changed,
value: newProperty
};
},
render(this: GridRow): DNode {
// …
}
}
});
export default createGridRow;
export const GridRowBase = ThemeableMixin(RegistryMixin(WidgetBase));@theme(css)
export default class GridRow extends GridRowBase<GridRowProperties> implements ThemeableMixinInterface {
diffPropertyItem(previousProperty: any, newProperty: any): PropertyChangeRecord {
let changed = newProperty !== previousProperty;
if (typeof newProperty.equals === ‘function’) {
changed = !newProperty.equals(previousProperty);
}
return { changed, value: newProperty };
}
render(): DNode {
// …
}
}

Giving early feedback

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store