LDAP-Server using ldapjs on TypeScript

2.1k views Asked by At

I want to host an LDAP Server using ldapjs. Sadly there is no documentation for TypeScript yet. So I found the typings in @types/nodejs but there are no server methods present:

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

This gives me an error in VS Code that no method called createServer is present. Only createClient is showing. Also the index.d.ts from the Typings package contains only a Client interface:

export interface Client extends EventEmitter { // ...

How can I get the correct Typings for server usage?

1

There are 1 answers

0
Antoine Drouhin On

ldapjs server is currently not properly typed.

The fast solution is to type ldapjs as any. This will remove type errors from your code.

const ldap: any = require('ldapjs')

The longer solution would be to contribute to the ldapjs typing with a pull request to https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ldapjs