Comparing version 5.0.1 to 5.0.2
@@ -1,2 +0,2 @@ | ||
import { Methods, CallSender } from '../types'; | ||
import { Methods, CallSender, AsyncMethodReturns } from '../types'; | ||
declare type Options = { | ||
@@ -25,3 +25,3 @@ /** | ||
*/ | ||
promise: Promise<TCallSender>; | ||
promise: Promise<AsyncMethodReturns<TCallSender>>; | ||
/** | ||
@@ -28,0 +28,0 @@ * A method that, when called, will disconnect any messaging channels. |
@@ -10,3 +10,3 @@ import { ErrorCode } from './enums'; | ||
}) => { | ||
promise: Promise<TCallSender>; | ||
promise: Promise<import("./types").AsyncMethodReturns<TCallSender, { [K in keyof TCallSender]: TCallSender[K] extends Function ? K : never; }[keyof TCallSender]>>; | ||
destroy: Function; | ||
@@ -20,3 +20,3 @@ }; | ||
}) => { | ||
promise: Promise<TCallSender_1>; | ||
promise: Promise<import("./types").AsyncMethodReturns<TCallSender_1, { [K_1 in keyof TCallSender_1]: TCallSender_1[K_1] extends Function ? K_1 : never; }[keyof TCallSender_1]>>; | ||
destroy: Function; | ||
@@ -23,0 +23,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import { CallSender, Methods } from '../types'; | ||
import { CallSender, Methods, AsyncMethodReturns } from '../types'; | ||
declare type Options = { | ||
@@ -31,3 +31,3 @@ /** | ||
*/ | ||
promise: Promise<TCallSender>; | ||
promise: Promise<AsyncMethodReturns<TCallSender>>; | ||
/** | ||
@@ -34,0 +34,0 @@ * A method that, when called, will disconnect any messaging channels. |
@@ -81,1 +81,13 @@ import { ErrorCode, MessageType, Resolution } from './enums'; | ||
}; | ||
/** | ||
* A mapped type to extract only object properties which are functions. | ||
*/ | ||
export declare type FunctionPropertyNames<T> = { | ||
[K in keyof T]: T[K] extends Function ? K : never; | ||
}[keyof T]; | ||
/** | ||
* A mapped type to convert non async methods into async methods and exclude any non function properties. | ||
*/ | ||
export declare type AsyncMethodReturns<T, K extends keyof T = FunctionPropertyNames<T>> = { | ||
[KK in K]: T[KK] extends (...args: any[]) => PromiseLike<any> ? T[KK] : T[KK] extends (...args: infer A) => infer R ? (...args: A) => Promise<R> : T[KK]; | ||
}; |
{ | ||
"name": "penpal", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "A promise-based library for communicating with iframes via postMessage.", | ||
@@ -5,0 +5,0 @@ "author": "Aaron Hardy <aaron@aaronhardy.com>", |
89202
1499