From 461ecd94e3e24e4a2bdcfbc519c55365ebf19ab4 Mon Sep 17 00:00:00 2001 From: Tamas Mezei <1107282+mezeitamas@users.noreply.github.com> Date: Tue, 23 Jun 2020 21:16:35 +0200 Subject: [PATCH] fix function signature for createserver (#45386) --- types/xmlrpc/index.d.ts | 4 ++-- types/xmlrpc/xmlrpc-tests.ts | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/types/xmlrpc/index.d.ts b/types/xmlrpc/index.d.ts index 8425d4672c..1afc6d190b 100644 --- a/types/xmlrpc/index.d.ts +++ b/types/xmlrpc/index.d.ts @@ -46,8 +46,8 @@ declare module 'xmlrpc' { function createClient(options: string | ClientOptions): Client; function createSecureClient(options: string | ClientOptions): Client; - function createServer(options: string | ServerOptions, callback: () => void): Server; - function createSecureServer(options: string | TlsOptions, callback: () => void): Server; + function createServer(options: string | ServerOptions, callback?: () => void): Server; + function createSecureServer(options: string | TlsOptions, callback?: () => void): Server; interface Client { options: ClientOptions; diff --git a/types/xmlrpc/xmlrpc-tests.ts b/types/xmlrpc/xmlrpc-tests.ts index b9cdff2e3f..28dbbab15a 100644 --- a/types/xmlrpc/xmlrpc-tests.ts +++ b/types/xmlrpc/xmlrpc-tests.ts @@ -5,12 +5,14 @@ const serverOpts = { port: 9000 }; -const server = xmlrpc.createServer(serverOpts, () => { - server.on('NotFound', method => { +const serverWithOutCallback = xmlrpc.createServer(serverOpts); + +const serverWithCallback = xmlrpc.createServer(serverOpts, () => { + serverWithCallback.on('NotFound', method => { console.log(`Method ${method} not found`); }) - server.on('hello', (err, params, cb) => { + serverWithCallback.on('hello', (err, params, cb) => { cb(null, `Hello, ${params[0]}!`); });