From 26b8a029f511b399ff0dd5e5be44941e875be5eb Mon Sep 17 00:00:00 2001 From: impinball Date: Sat, 2 Apr 2016 13:03:35 -0400 Subject: [PATCH] Clean up Promise/Thenable types, remove PromiseProperty type. --- mithril.d.ts | 49 ++++++++----------------------------------------- 1 file changed, 8 insertions(+), 41 deletions(-) diff --git a/mithril.d.ts b/mithril.d.ts index 52ef8253..63074dd1 100644 --- a/mithril.d.ts +++ b/mithril.d.ts @@ -76,7 +76,7 @@ declare namespace Mithril { * * @see m.withAttr */ - prop(promise: Thennable) : PromiseProperty; + prop(promise: Thennable) : Promise; /** * Creates a getter-setter function that wraps a simple value. Useful @@ -601,37 +601,6 @@ declare namespace Mithril { toJSON(): T; } - /** - * This represents a promise getter-setter function. - * - * @see m.prop which returns objects that implement this interface. - */ - interface PromiseProperty extends Promise>, - Property> { - /** - * Gets the contained promise. - * - * @return The contained value. - */ - (): Promise; - - /** - * Sets the contained promise. - * - * @param value The new value to set. - * @return The newly set value. - */ - (value: Promise): Promise; - - /** - * Sets the contained wrapped value. - * - * @param value The new value to set. - * @return The newly set value. - */ - (value: T): Promise; - } - /** * This represents a key-value mapping linking routes to components. */ @@ -687,9 +656,10 @@ declare namespace Mithril { * This represents a thennable. */ interface Thennable { - then(success: (value: T) => U): Thennable; - then(success: (value: T) => U, error: (value: Error) => V): Thennable|Thennable; - catch?(error: (value: Error) => U): Thennable; + then(success: SuccessCallback): Thennable; + then(success: SuccessCallback, error: ErrorCallback): Thennable; + catch?(error: ErrorCallback): Thennable; + catch?(error: ErrorCallback): Thennable; } /** @@ -703,7 +673,7 @@ declare namespace Mithril { * @param success The callback to call when the promise is resolved. * @return The chained promise. */ - then(success: SuccessCallback): Promise; + then(success: SuccessCallback): Promise; /** * Chain this promise with a success callback and error callback, without @@ -713,10 +683,7 @@ declare namespace Mithril { * @param error The callback to call when the promise is rejected. * @return The chained promise. */ - then( - success: SuccessCallback, - error: ErrorCallback - ): Promise | Promise; + then(success: SuccessCallback, error: ErrorCallback): Promise; /** * Chain this promise with a single error callback, without propogating @@ -725,7 +692,7 @@ declare namespace Mithril { * @param error The callback to call when the promise is rejected. * @return The chained promise. */ - catch(error: ErrorCallback): Promise | Promise; + catch(error: ErrorCallback): Promise; } /**