From 0621c118a7a543178d3215e511273b5899cbec61 Mon Sep 17 00:00:00 2001 From: Hirako2000 Date: Mon, 17 Jul 2017 00:28:34 +0700 Subject: [PATCH] Adds types for DefineModule and adjusts elementModule constructor as container is optional - #298 --- types/modules/DefineModule.d.ts | 9 +++++++++ types/modules/app/ElementModule.d.ts | 4 ++-- types/modules/index.d.ts | 3 ++- types/whs-tests.ts | 10 ++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 types/modules/DefineModule.d.ts diff --git a/types/modules/DefineModule.d.ts b/types/modules/DefineModule.d.ts new file mode 100644 index 000000000..1e4436123 --- /dev/null +++ b/types/modules/DefineModule.d.ts @@ -0,0 +1,9 @@ +export class DefineModule { + + /** + * @constructor Creates a define module. + * @param name name of the module + * @param data the module to define + */ + constructor(name: string, data: object); +} diff --git a/types/modules/app/ElementModule.d.ts b/types/modules/app/ElementModule.d.ts index 7b39dd590..aa4b71521 100644 --- a/types/modules/app/ElementModule.d.ts +++ b/types/modules/app/ElementModule.d.ts @@ -2,9 +2,9 @@ export class ElementModule { /** * @constructor Creates an element module. - * @param container dom element to use as context for rendering + * @param container dom element to use as context for rendering. Default is document.body */ - constructor(container: HTMLElement); + constructor(container?: HTMLElement); /** * Creates a div element inside the container diff --git a/types/modules/index.d.ts b/types/modules/index.d.ts index 32221739e..f5f795635 100644 --- a/types/modules/index.d.ts +++ b/types/modules/index.d.ts @@ -1,2 +1,3 @@ export * from './app'; -export * from './mesh'; \ No newline at end of file +export * from './mesh'; +export * from './DefineModule'; diff --git a/types/whs-tests.ts b/types/whs-tests.ts index 98083d9aa..d77d4a882 100644 --- a/types/whs-tests.ts +++ b/types/whs-tests.ts @@ -47,6 +47,8 @@ import { VirtualMouseModule } from './modules/app'; +import {DefineModule} from './modules'; + // Core const app = new App(); app.start(); @@ -224,3 +226,11 @@ const data = stateModule.get('key'); const virtualMouseModule = new VirtualMouseModule(); virtualMouseModule.hovers(new Box(), false); virtualMouseModule.track(new Sphere(), false); + +const defineModule = new DefineModule('camera', + new PerspectiveCamera({ + build: false, + far: 100 + }) +); +new App([defineModule]);