From 7aae543bd7256545c9efc13e2d2d42606716ef6f Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Thu, 9 Jul 2015 11:22:59 +0300 Subject: [PATCH] Strong types for builder.load parameters. Hopefully better intellisense. --- ui/builder/builder.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ui/builder/builder.ts b/ui/builder/builder.ts index d73df82f5..5b6458c05 100644 --- a/ui/builder/builder.ts +++ b/ui/builder/builder.ts @@ -223,19 +223,21 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr return result; } -export function load(arg: any): view.View { +export function load(pathOrOptions: string | definition.LoadOptions, context?: any): view.View { var viewToReturn: view.View; var componentModule: componentBuilder.ComponentModule; - if (arguments.length === 1) { - if (!types.isString(arguments[0])) { - var options = arguments[0]; + if (!context) { + if (!types.isString(pathOrOptions)) { + var options = pathOrOptions; componentModule = loadCustomComponent(options.path, options.name, undefined, options.exports, options.page); } else { - componentModule = loadInternal(arguments[0]); + var path = pathOrOptions; + componentModule = loadInternal(path); } } else { - componentModule = loadInternal(arguments[0], arguments[1]); + var path = pathOrOptions; + componentModule = loadInternal(path, context); } if (componentModule) { @@ -315,4 +317,4 @@ function getExports(instance: view.View): any { } return parent ? (parent).exports : undefined; -} \ No newline at end of file +}