【问题标题】:Passport Azure AD This expression is not callablePassport Azure AD 此表达式不可调用
【发布时间】:2020-07-27 18:04:23
【问题描述】:

example 中使用了以下代码:

import { BearerStrategy } from 'passport-azure-ad'

const bearerStrategy = new BearerStrategy(config, (token, done) => {
        // Send user info using the second argument
        done(null, {}, token);
    }
);

这会引发以下 TS 错误:

src/index.ts:26:12 - error TS2349: This expression is not callable.
  Type 'ITokenPayload' has no call signatures.

26     return done(null, {}, token)

虽然代码有效,但我想知道如何避免此错误。

【问题讨论】:

  • 试试new BearerStrategy(config, (token: ITokenPayload, done: CallableFunction) => ...
  • 是的,解决了!如果您将其写为答案,我会将其标记为已解决。谢谢。

标签: typescript passport.js passport-azure-ad


【解决方案1】:

您可以为每个参数添加类型。

new BearerStrategy(config, (token: ITokenPayload, done: CallableFunction) => ...

【讨论】:

    猜你喜欢
    • 2018-07-25
    • 2021-06-12
    • 2016-02-25
    • 2021-08-16
    • 2022-09-30
    • 1970-01-01
    • 2018-05-27
    • 2020-08-16
    • 2017-02-01
    相关资源
    最近更新 更多