egg
egg copied to clipboard
[Feature Request] egg-passport 的 index.d.ts 添加支持回调函数
Background
我在使用 ctx.app.passport.authenticate 时,翻阅了passport的文档的时候发现可以自定义回调函数,而我在 ts 模板中使用回调函数的时候,代码可以跑通,但是 ts 编译报错,因为 egg-passport 的 index.d.ts 里面定义的第二个参数只能传 AuthenticateOptions 类型
interface EggPassport extends Authenticator {
authenticate<AuthenticateRet = any>(strategy: string | string[]): AuthenticateRet;
authenticate<AuthenticateRet = any>(strategy: string | string[], options: AuthenticateOptions): AuthenticateRet;
...
}
Proposal
希望能多加一个函数重载以支持在 ts 中使用回调函数
interface EggPassport extends Authenticator {
authenticate<AuthenticateRet = any>(strategy: string | string[]): AuthenticateRet;
authenticate<AuthenticateRet = any>(strategy: string | string[], options: AuthenticateOptions): AuthenticateRet;
authenticate<AuthenticateRet = any>(strategy: string | string[], callback: function): AuthenticateRet;
...
}
PR is welcome :)