diff --git a/esp/src/src/DataPatternsWidget.ts b/esp/src/src/DataPatternsWidget.ts index 75c479c049f..f030a85e231 100644 --- a/esp/src/src/DataPatternsWidget.ts +++ b/esp/src/src/DataPatternsWidget.ts @@ -34,7 +34,7 @@ import "dijit/TooltipDialog"; import "hpcc/TableContainer"; import "hpcc/TargetSelectWidget"; -import { declareDecorator } from "./DeclareDecorator"; +import { declareMixin } from "./DeclareDecorator"; import { WUStatus } from "./WUStatus"; type _TabContainerWidget = { @@ -50,11 +50,10 @@ type _TabContainerWidget = { export const supportedFileType = (contentType: string): boolean => ["flat", "csv", "thor"].indexOf((contentType || "").toLowerCase()) >= 0; -export interface DataPatternsWidget extends _TabContainerWidget { +interface _DataPatternsWidget extends _TabContainerWidget { } -@declareDecorator("DataPatternsWidget", _TabContainerWidget) -export class DataPatternsWidget { +class _DataPatternsWidget { templateString = template; static baseClass = "DataPatternsWidget"; i18n = nlsHPCC; @@ -296,3 +295,5 @@ export class DataPatternsWidget { ; } } + +export const DataPatternsWidget = declareMixin(_DataPatternsWidget, "DataPatternsWidget", _TabContainerWidget); diff --git a/esp/src/src/DeclareDecorator.ts b/esp/src/src/DeclareDecorator.ts index cb5e5d8debd..603f1ed7e5c 100644 --- a/esp/src/src/DeclareDecorator.ts +++ b/esp/src/src/DeclareDecorator.ts @@ -10,3 +10,8 @@ export function declareDecorator(classID: string, ...mixins: object[]) { return declare(classID, mixins, target.prototype); }; } + +type Constructor = new (...args: any[]) => T; +export function declareMixin(target: T, classID: string, ...mixins: object[]): T { + return declare(classID, mixins, target.prototype); +} diff --git a/esp/src/src/ECLArchiveWidget.ts b/esp/src/src/ECLArchiveWidget.ts index 8076a41433e..14d58ff37fa 100644 --- a/esp/src/src/ECLArchiveWidget.ts +++ b/esp/src/src/ECLArchiveWidget.ts @@ -18,7 +18,7 @@ import { themeIsDark } from "./Utility"; import * as template from "dojo/text!hpcc/templates/ECLArchiveWidget.html"; // @ts-ignore import * as _Widget from "hpcc/_Widget"; -import { declareDecorator } from "./DeclareDecorator"; +import { declareMixin } from "./DeclareDecorator"; const TIME_NAMES = ["TimeMaxLocalExecute", "TimeAvgLocalExecute", "TimeLocalExecute"]; @@ -36,11 +36,10 @@ type _Widget = { setDisabled(id: string, disabled: boolean, icon?: string, disabledIcon?: string); }; -export interface ECLArchiveWidget extends _Widget { +interface _ECLArchiveWidget extends _Widget { } -@declareDecorator("ECLArchiveWidget", _Widget) -export class ECLArchiveWidget { +class _ECLArchiveWidget { protected templateString = template; static baseClass = "ECLArchiveWidget"; protected i18n = nlsHPCC; @@ -714,3 +713,5 @@ export class ECLArchiveWidget { } } } +export const ECLArchiveWidget = declareMixin(_ECLArchiveWidget, "ECLArchiveWidget", _Widget); + diff --git a/esp/src/src/Graph7Widget.ts b/esp/src/src/Graph7Widget.ts index 1c72eba37e4..5bb3ee1f6d2 100644 --- a/esp/src/src/Graph7Widget.ts +++ b/esp/src/src/Graph7Widget.ts @@ -21,7 +21,7 @@ import "dijit/layout/ContentPane"; import "dijit/Toolbar"; import "dijit/ToolbarSeparator"; -import { declareDecorator } from "./DeclareDecorator"; +import { declareMixin } from "./DeclareDecorator"; import nlsHPCC from "./nlsHPCC"; import { WUScopeController } from "./WUScopeController"; @@ -33,11 +33,10 @@ type _Widget = { setDisabled(id: string, disabled: boolean, icon?: string, disabledIcon?: string); }; -export interface Graph7Widget extends _Widget { +interface _Graph7Widget extends _Widget { } -@declareDecorator("Graph7Widget", _Widget) -export class Graph7Widget { +class _Graph7Widget { templateString = template; static baseClass = "Graph7Widget"; i18n = nlsHPCC; @@ -252,3 +251,4 @@ export class Graph7Widget { ; } } +export const Graph7Widget = declareMixin(_Graph7Widget, "Graph7Widget", _Widget); diff --git a/esp/src/src/GraphTree7Widget.ts b/esp/src/src/GraphTree7Widget.ts index 5238395e430..0f792c18095 100644 --- a/esp/src/src/GraphTree7Widget.ts +++ b/esp/src/src/GraphTree7Widget.ts @@ -15,7 +15,7 @@ import { hashSum } from "@hpcc-js/util"; // @ts-ignore import * as _Widget from "hpcc/_Widget"; -import { declareDecorator } from "./DeclareDecorator"; +import { declareMixin } from "./DeclareDecorator"; import { Grid, maximizeWidget } from "./ESPUtil"; import { GraphStore, GraphTreeStore } from "./GraphStore"; import nlsHPCC from "./nlsHPCC"; @@ -88,11 +88,10 @@ type _Widget = { setDisabled(id: string, disabled: boolean, icon?: string, disabledIcon?: string); }; -export interface GraphTree7Widget extends _Widget { +interface _GraphTree7Widget extends _Widget { } -@declareDecorator("GraphTree7Widget", _Widget) -export class GraphTree7Widget { +class _GraphTree7Widget { templateString = template; static baseClass = "GraphTree7Widget"; i18n = nlsHPCC; @@ -761,7 +760,7 @@ export class GraphTree7Widget { } } -GraphTree7Widget.prototype._syncSelectionFrom = debounce(function (this: GraphTree7Widget, sourceControlOrGlobalIDs) { +_GraphTree7Widget.prototype._syncSelectionFrom = debounce(function (this: _GraphTree7Widget, sourceControlOrGlobalIDs) { this.inSyncSelectionFrom = true; const sourceControl = sourceControlOrGlobalIDs instanceof Array ? null : sourceControlOrGlobalIDs; let selectedGlobalIDs = sourceControlOrGlobalIDs instanceof Array ? sourceControlOrGlobalIDs : []; @@ -846,3 +845,5 @@ GraphTree7Widget.prototype._syncSelectionFrom = debounce(function (this: GraphTr } this.inSyncSelectionFrom = false; }, 500, false); + +export const GraphTree7Widget = declareMixin(_GraphTree7Widget, "GraphTree7Widget", _Widget); \ No newline at end of file diff --git a/esp/src/src/GraphTreeWidget.ts b/esp/src/src/GraphTreeWidget.ts index 0a2e74d80fc..10fec1ba60b 100644 --- a/esp/src/src/GraphTreeWidget.ts +++ b/esp/src/src/GraphTreeWidget.ts @@ -48,13 +48,12 @@ import "dijit/ToolbarSeparator"; import "hpcc/JSGraphWidget"; import "hpcc/TimingTreeMapWidget"; -import { declareDecorator } from "./DeclareDecorator"; +import { declareMixin } from "./DeclareDecorator"; type _Widget = any; -export interface GraphTreeWidget extends _Widget { } +interface _GraphTreeWidget extends _Widget { } -@declareDecorator("GraphTreeWidget", _Widget) -export class GraphTreeWidget { +class _GraphTreeWidget { templateString = template; baseClass = "GraphTreeWidget"; i18n = nlsHPCC; @@ -796,3 +795,4 @@ export class GraphTreeWidget { this.setDisabled(this.id + "ActivityMetric", tab.id !== this.id + "ActivitiesTreeMap"); } } +export const GraphTreeWidget = declareMixin(_GraphTreeWidget, "GraphTreeWidget", _Widget); diff --git a/esp/src/tsconfig.json b/esp/src/tsconfig.json index 55fd90ef44b..a2340603d81 100644 --- a/esp/src/tsconfig.json +++ b/esp/src/tsconfig.json @@ -14,7 +14,6 @@ "noUnusedLocals": true, "strictNullChecks": false, "importHelpers": true, - "experimentalDecorators": true, "allowJs": true, "skipLibCheck": true, "noImplicitUseStrict": true,