From 17ce7262df05a11e4cd4642f31f312ba1580760b Mon Sep 17 00:00:00 2001 From: frogcjn Date: Tue, 28 Jun 2016 12:17:22 +0800 Subject: [PATCH 1/3] fix post function --- mongoose/mongoose.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mongoose/mongoose.d.ts b/mongoose/mongoose.d.ts index 6d74a0e4b1..7a4d33c522 100644 --- a/mongoose/mongoose.d.ts +++ b/mongoose/mongoose.d.ts @@ -276,8 +276,7 @@ declare module "mongoose" { pre(method: string, fn: HookSyncCallback, errorCb?: HookErrorCallback): Schema; pre(method: string, isAsync: boolean, fn: HookAsyncCallback, errorCb?: HookErrorCallback): Schema; - post(method: string, fn: HookSyncCallback, errorCb?: HookErrorCallback): Schema; - post(method: string, isAsync: boolean, fn: HookAsyncCallback, errorCb?: HookErrorCallback): Schema; + post(method: string, fn: (doc: Document, next?: HookNextFunction) => any ): Schema; requiredPaths(): string[]; set(key: string, value: any): void; From 60b5a415abb71c4f020ab8f2f148ae5360066cc1 Mon Sep 17 00:00:00 2001 From: frogcjn Date: Tue, 28 Jun 2016 12:56:56 +0800 Subject: [PATCH 2/3] fix tests --- mongoose/mongoose-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoose/mongoose-tests.ts b/mongoose/mongoose-tests.ts index cd5f53c4d9..2f6467437c 100644 --- a/mongoose/mongoose-tests.ts +++ b/mongoose/mongoose-tests.ts @@ -369,7 +369,7 @@ schema.path('name'); schema.path('name', Number); schema.pathType('name'); schema.plugin(function() {}); -schema.post('save', function(next: () => void, doc: IActor) {}); +schema.post('save', function(doc: IActor) {}); schema.pre('save', function(next: () => void) {}); schema.requiredPaths(); schema.static('findByName', function(name: string, callback: () => void) {}); From ed6c1cf4e4abaad3526ba1c2b07521f76f42a8ed Mon Sep 17 00:00:00 2001 From: frogcjn Date: Wed, 29 Jun 2016 09:49:20 +0800 Subject: [PATCH 3/3] enhence callback type --- express-jwt/express-jwt.d.ts | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/express-jwt/express-jwt.d.ts b/express-jwt/express-jwt.d.ts index 1aec6606fe..dadf833f67 100644 --- a/express-jwt/express-jwt.d.ts +++ b/express-jwt/express-jwt.d.ts @@ -12,21 +12,30 @@ declare module "express-jwt" { function jwt(options: jwt.Options): jwt.RequestHandler; - interface IDoneCallback { - (err: Error, result: T): void; - } - - type ICallback = (req: express.Request, payload: T, done: IDoneCallback) => void; - namespace jwt { + + export type secretType = string | Buffer + export interface SecretCallback { + (req: express.Request, header:any, payload: any, done: (err: any, secret?: boolean) => void): void; + (req: express.Request, payload: any, done: (err: any, secret?: secretType) => void):void; + } + + export interface IsRevokedCallback { + (req: express.Request, payload: any, done: (err: any, revoked?: boolean) => void): void; + } + + export interface GetTokenCallback { + (req: express.Request): any; + } + export interface Options { - secret: string|Buffer|ICallback; + secret: secretType|SecretCallback; userProperty?: string; skip?: string[]; credentialsRequired?: boolean; - isRevoked?: boolean; + isRevoked?: IsRevokedCallback; requestProperty?: string; - getToken?: ICallback; + getToken?: GetTokenCallback; [property: string]: any; } export interface RequestHandler extends express.RequestHandler { @@ -34,4 +43,4 @@ declare module "express-jwt" { } } export = jwt; -} +} \ No newline at end of file