0

示例中,使用了以下代码:

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)

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

4

1 回答 1

2

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

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

于 2020-07-27T10:04:23.983 回答