diff --git a/src/Injector.ts b/src/Injector.ts index 493216aa..596919eb 100644 --- a/src/Injector.ts +++ b/src/Injector.ts @@ -1,6 +1,6 @@ import { assign } from '@dojo/core/lang'; import { Evented } from '@dojo/core/Evented'; -import { diffProperty, afterRender, WidgetBase, InternalWNode, InternalHNode } from './WidgetBase'; +import { diffProperty, afterRender, WidgetBase } from './WidgetBase'; import { decorate, isHNode, isWNode } from './d'; import { DiffType } from './diff'; import { @@ -64,7 +64,7 @@ export interface InjectorProperties extends WidgetProperties { scope: any; render(): DNode; getProperties?: GetProperties; - properties: WidgetProperties; + properties: any; getChildren?: GetChildren; children: DNode[]; } @@ -100,9 +100,9 @@ export function Injector { + decorate(node, (node: any) => { const { properties } = node; properties.bind = scope; }, (node: DNode) => { return isHNode(node) || isWNode(node); }); diff --git a/src/WidgetBase.ts b/src/WidgetBase.ts index ce77ab5e..ae32e979 100644 --- a/src/WidgetBase.ts +++ b/src/WidgetBase.ts @@ -17,7 +17,6 @@ import { PropertiesChangeEvent, RegistryLabel, HNode, - WNode, WidgetMetaConstructor } from './interfaces'; import MetaBase from './meta/Base'; @@ -35,17 +34,6 @@ interface WidgetCacheWrapper { used: boolean; } -export interface InternalWNode extends WNode { - properties: { - bind: any; - }; -} -export interface InternalHNode extends HNode { - properties: { - bind: any; - }; -} - enum WidgetRenderState { IDLE = 1, PROPERTIES, @@ -145,7 +133,7 @@ function isHNodeWithKey(node: DNode): node is HNode { * Main widget base for all widgets to extend */ @diffProperty('bind', DiffType.REFERENCE) -export class WidgetBase

extends Evented implements WidgetBaseInterface { +export class WidgetBase

extends Evented implements WidgetBaseInterface { /** * static identifier @@ -175,7 +163,7 @@ export class WidgetBase

{ + decorate(node, (node: any) => { const { properties = {} }: { properties: { bind?: any } } = node; if (!properties.bind) { properties.bind = this; @@ -364,7 +352,7 @@ export class WidgetBase

element); } - public get properties(): Readonly

{ + public get properties(): Readonly

& Readonly { return this._properties; } diff --git a/src/interfaces.d.ts b/src/interfaces.d.ts index 74f59617..0394eff4 100644 --- a/src/interfaces.d.ts +++ b/src/interfaces.d.ts @@ -338,13 +338,13 @@ export interface DefaultWidgetBaseInterface extends WidgetBaseInterface> extends Evented { /** * Widget properties */ - readonly properties: P; + readonly properties: P & WidgetProperties; /** * Returns the widget's children diff --git a/tests/unit/WidgetBase.ts b/tests/unit/WidgetBase.ts index 9f2fbc0f..24f37487 100644 --- a/tests/unit/WidgetBase.ts +++ b/tests/unit/WidgetBase.ts @@ -4,7 +4,6 @@ import * as registerSuite from 'intern!object'; import * as assert from 'intern/chai!assert'; import { stub, spy, SinonStub } from 'sinon'; import { v, w, registry } from '../../src/d'; -import { DNode, WidgetProperties } from '../../src/interfaces'; import { WidgetBase, diffProperty, @@ -13,9 +12,10 @@ import { beforeRender, onPropertiesChanged } from '../../src/WidgetBase'; +import { Constructor, DNode } from '../../src/interfaces'; import WidgetRegistry, { WIDGET_BASE_TYPE } from './../../src/WidgetRegistry'; -interface TestProperties extends WidgetProperties { +interface TestProperties { id: string; foo: string; bar?: null | string; @@ -859,7 +859,7 @@ widget.__setProperties__({ 'async factories only initialise once'() { let resolveFunction: any; const loadFunction = () => { - return new Promise((resolve) => { + return new Promise>((resolve) => { resolveFunction = resolve; }); }; @@ -907,7 +907,7 @@ widget.__setProperties__({ 'render with async factory'() { let resolveFunction: any; const loadFunction = () => { - return new Promise((resolve) => { + return new Promise>((resolve) => { resolveFunction = resolve; }); }; diff --git a/tests/unit/WidgetRegistry.ts b/tests/unit/WidgetRegistry.ts index 4b60a65b..ec1eb42a 100644 --- a/tests/unit/WidgetRegistry.ts +++ b/tests/unit/WidgetRegistry.ts @@ -81,7 +81,7 @@ registerSuite({ const RegistryTestWidget = factoryRegistry.get('test-widget'); assert.isNotNull(RegistryTestWidget); const widget = new RegistryTestWidget!(); - // demontrates the design time typing + // demonstrates the design time typing widget.__setProperties__({ foo: 'bar' }); }, 'throws an error if factory has not been registered.'() { diff --git a/tests/unit/testIntegration.tsx b/tests/unit/testIntegration.tsx index 1651f0dd..60f9bc07 100644 --- a/tests/unit/testIntegration.tsx +++ b/tests/unit/testIntegration.tsx @@ -1,10 +1,10 @@ import * as registerSuite from 'intern!object'; import * as assert from 'intern/chai!assert'; import { WidgetBase } from '../../src/WidgetBase'; -import { fromRegistry, registry } from '../../src/d'; +import { registry } from '../../src/d'; import { WidgetProperties } from '../../src/interfaces'; import { VNode } from '@dojo/interfaces/vdom'; -import * as tsx from './../../src/tsx'; +import { fromRegistry } from './../../src/tsx'; registerSuite({ name: 'tsx',