Skip to content

Commit

Permalink
fix: Ensure that hooks can compile correctly for ES6 targets using di…
Browse files Browse the repository at this point in the history
…fferent promise implementations
  • Loading branch information
notheotherben committed Jun 9, 2016
1 parent 8ddb696 commit e04e75f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions lib/Hooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface Hooks<TDocument, TInstance> {
onCreating? (document: TDocument): Promise<any> | void;
onRetrieved? (document: TDocument): Promise<any> | void;
onReady? (instance: TInstance): Promise<any> | void;
onSaving?(instance: TInstance, changes: any): Promise<any> | void;
onCreating? (document: TDocument): Promise<any> | PromiseLike<any> | void;
onRetrieved? (document: TDocument): Promise<any> | PromiseLike<any> | void;
onReady? (instance: TInstance): Promise<any> | PromiseLike<any> | void;
onSaving?(instance: TInstance, changes: any): Promise<any> | PromiseLike<any> | void;
}
8 changes: 4 additions & 4 deletions lib/Instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,20 @@ export class Instance<TDocument extends { _id?: any }, TInstance> {
* A function which is called whenever a new document is in the process of being inserted into the database.
* @param document The document which will be inserted into the database.
*/
static onCreating: (document: { _id?: any }) => Promise<any> | void;
static onCreating: (document: { _id?: any }) => Promise<any> | PromiseLike<any> | void;

/**
* A function which is called whenever a document of this type is received from the database, prior to it being
* wrapped by an Instance object.
* @param document The document that was retrieved from the database.
*/
static onRetrieved: (document: { _id?: any }) => Promise<any> | void;
static onRetrieved: (document: { _id?: any }) => Promise<any> | PromiseLike<any> | void;

/**
* A function which is called whenever a new instance has been created to wrap a document.
* @param instance The instance which has been created.
*/
static onReady: (instance: Instance<{ _id?: any }, Instance<{ _id?: any }, any>>) => Promise<any> | void;
static onReady: (instance: Instance<{ _id?: any }, Instance<{ _id?: any }, any>>) => Promise<any> | PromiseLike<any> | void;

/**
* A function which is called whenever an instance's save() method is called to allow you to interrogate and/or manipulate
Expand All @@ -91,7 +91,7 @@ export class Instance<TDocument extends { _id?: any }, TInstance> {
* @param instance The instance to which the changes are being made
* @param changes The MongoDB change object describing the changes being made to the document.
*/
static onSaving: (instance: Instance<{ _id?: any }, Instance<{ _id?: any }, any>>, changes: any) => Promise<any> | void;
static onSaving: (instance: Instance<{ _id?: any }, Instance<{ _id?: any }, any>>, changes: any) => Promise<any> | PromiseLike<any> | void;

/**
* The name of the collection into which documents of this type are stored.
Expand Down
8 changes: 4 additions & 4 deletions lib/InstanceInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export interface InstanceImplementation<TDocument extends { _id ?: any }, TInsta
* document inserted into the database. As a result, long running tasks will have a significant impact
* on the performance of your inserts.
*/
onCreating? (document: TDocument): Promise<any> | void;
onCreating? (document: TDocument): Promise<any> | PromiseLike<any> | void;

/**
* An optional method which is called whenever a new document is received from the model's collection and
Expand All @@ -74,7 +74,7 @@ export interface InstanceImplementation<TDocument extends { _id ?: any }, TInsta
* document retrieved from the database. As a result, long running tasks will have a significant impact
* on the performance of your queries.
*/
onRetrieved? (document: TDocument): Promise<any> | void;
onRetrieved? (document: TDocument): Promise<any> | PromiseLike<any> | void;

/**
* An optional method which is called whenever a new document for this model has been wrapped in an instance.
Expand All @@ -86,7 +86,7 @@ export interface InstanceImplementation<TDocument extends { _id ?: any }, TInsta
* document retrieved from the database. As a result, long running tasks will have a significant impact
* on the performance of your queries.
*/
onReady? (instance: TInstance): Promise<any> | void;
onReady? (instance: TInstance): Promise<any> | PromiseLike<any> | void;

/**
* An optional method which is called prior to saving an instance, it is provided with the instance itself as
Expand All @@ -101,7 +101,7 @@ export interface InstanceImplementation<TDocument extends { _id ?: any }, TInsta
* call to save. As a result, long running tasks will have a significant impact on how quickly your save
* operations are dispatched.
*/
onSaving? (instance: TInstance, changes: any): Promise<any> | void;
onSaving? (instance: TInstance, changes: any): Promise<any> | PromiseLike<any> | void;

/**
* The cache controller used to determine whether a document may be cached, as well as deriving a unique cache
Expand Down

0 comments on commit e04e75f

Please sign in to comment.