From 3497b7ecd30a9355bcd416f7045d465b71b80c44 Mon Sep 17 00:00:00 2001 From: Daniel Earwicker Date: Tue, 20 Jan 2015 21:47:29 +0000 Subject: [PATCH 1/2] ko.unwrap uses union types --- knockout/knockout.d.ts | 2 +- knockout/tests/knockout-tests.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 3ac8d0a0e..c68c38aff 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -442,7 +442,7 @@ interface KnockoutStatic { cleanNode(node: Element): Element; renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any): any; renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any): any; - unwrap(value: any): any; + unwrap(value: KnockoutObservable | T): T; computedContext: KnockoutComputedContext; diff --git a/knockout/tests/knockout-tests.ts b/knockout/tests/knockout-tests.ts index 64a91d199..78d464f07 100644 --- a/knockout/tests/knockout-tests.ts +++ b/knockout/tests/knockout-tests.ts @@ -648,4 +648,11 @@ function test_Components() { // Empty config for registering custom elements that are handled by name convention ko.components.register('name', { /* No config needed */ }); } +} + +function testUnwrapUnion() { + + var possibleObs: KnockoutObservable | number; + var num = ko.unwrap(possibleObs); + } \ No newline at end of file From 458c047f7ed5c522888d6f7281a3cee411ebfeeb Mon Sep 17 00:00:00 2001 From: Daniel Earwicker Date: Tue, 20 Jan 2015 21:59:36 +0000 Subject: [PATCH 2/2] ko.utils.unwrapObservable uses union types --- knockout/knockout.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index c68c38aff..6f9ff2076 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -306,7 +306,7 @@ interface KnockoutUtils { triggerEvent(element: any, eventType: any): void; - unwrapObservable(value: KnockoutObservable): T; + unwrapObservable(value: KnockoutObservable | T): T; peekObservable(value: KnockoutObservable): T;