【问题标题】:LDAP-Server using ldapjs on TypeScript在 TypeScript 上使用 ldapjs 的 LDAP 服务器
【发布时间】:2019-04-07 13:51:45
【问题描述】:

我想使用ldapjs 托管一个 LDAP 服务器。遗憾的是,目前还没有 TypeScript 的文档。所以我在@types/nodejs 中找到了类型,但没有服务器方法存在:

import ldap = require('ldapjs')
let server = ldap.createServer()

这在 VS Code 中给我一个错误,即不存在名为 createServer 的方法。仅显示 createClient。 Typings 包中的 index.d.ts 也只包含一个 Client 接口:

export interface Client extends EventEmitter { // ...

如何获得服务器使用的正确类型?

【问题讨论】:

    标签: javascript node.js typescript typescript-typings ldapjs


    【解决方案1】:

    ldapjs 服务器当前没有正确输入。

    快速的解决方案是将 ldapjs 键入为any。这将从您的代码中删除类型错误。

    const ldap: any = require('ldapjs')
    

    更长的解决方案是通过对https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ldapjs 的拉取请求为 ldapjs 打字做出贡献

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-30
      • 2022-10-23
      • 2020-02-14
      • 1970-01-01
      • 1970-01-01
      • 2012-06-23
      相关资源
      最近更新 更多