【发布时间】:2019-11-05 04:23:07
【问题描述】:
Passport.js 策略可以支持身份验证调用中的其他选项:
passport.authenticate('azuread-openidconnect', {
// Default passport options
failWithError: true,
successReturnToOrRedirect: '/',
// Custom option supported by the azure-ad plugin
// Type error - 'tenantIdOrName' does not exist in type 'AuthenticateOptions'
tenantIdOrName: 'common',
});
使用自定义策略支持的选项,例如上面的tenantIdOrName,会导致打字稿错误,因为它不是护照的AuthenticateOptions 接口found here 的一部分并用于authenticate 签名here
我尝试了一些没有成功的事情
- 模块扩充,即
declare module 'passport' {...}似乎覆盖了模块的类型而不是扩展它们(不在我的扩展中的任何东西都被视为无类型) - 合并接口即
declare namespace passport { interface AuthenticateOptions { ...new properties }},这似乎对authenticate方法签名没有影响。
如何在不进行类型转换的情况下支持 authenticate 调用中的其他属性?
【问题讨论】:
标签: typescript passport.js passport-azure-ad