diff --git a/types/amqplib/amqplib-tests.ts b/types/amqplib/amqplib-tests.ts index ef448d5b36..a42d2f717d 100644 --- a/types/amqplib/amqplib-tests.ts +++ b/types/amqplib/amqplib-tests.ts @@ -14,6 +14,14 @@ amqp.connect('amqp://localhost') amqp.connect('amqp://localhost') .then(connection => { + connection.serverProperties.copyright; // $ExpectType string | undefined + connection.serverProperties.platform; // $ExpectType string + connection.serverProperties.information; // $ExpectType string + connection.serverProperties.host; // $ExpectType string + connection.serverProperties.product; // $ExpectType string + connection.serverProperties.version; // $ExpectType string + connection.serverProperties.customField; // $ExpectType string | undefined + return connection.createChannel() .tap(channel => channel.checkQueue('myQueue')) .then(channel => { @@ -37,6 +45,14 @@ import amqpcb = require('amqplib/callback_api'); amqpcb.connect('amqp://localhost', (err, connection) => { if (!err) { + connection.serverProperties.copyright; // $ExpectType string | undefined + connection.serverProperties.platform; // $ExpectType string + connection.serverProperties.information; // $ExpectType string + connection.serverProperties.host; // $ExpectType string + connection.serverProperties.product; // $ExpectType string + connection.serverProperties.version; // $ExpectType string + connection.serverProperties.customField; // $ExpectType string | undefined + connection.createChannel((err, channel) => { if (!err) { channel.assertQueue('myQueue', {}, (err, ok) => { diff --git a/types/amqplib/callback_api.d.ts b/types/amqplib/callback_api.d.ts index 9fca3972e4..56842abc26 100644 --- a/types/amqplib/callback_api.d.ts +++ b/types/amqplib/callback_api.d.ts @@ -1,11 +1,12 @@ import events = require('events'); -import { Replies, Options, Message } from './properties'; +import { Replies, Options, Message, ServerProperties } from './properties'; export * from './properties'; export interface Connection extends events.EventEmitter { close(callback?: (err: any) => void): void; createChannel(callback: (err: any, channel: Channel) => void): void; createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void; + serverProperties: ServerProperties; } export interface Channel extends events.EventEmitter { diff --git a/types/amqplib/index.d.ts b/types/amqplib/index.d.ts index 7087d74edc..77e5d19ca9 100644 --- a/types/amqplib/index.d.ts +++ b/types/amqplib/index.d.ts @@ -8,13 +8,14 @@ import * as Promise from 'bluebird'; import * as events from 'events'; -import { Replies, Options, Message, GetMessage, ConsumeMessage } from './properties'; +import { Replies, Options, Message, GetMessage, ConsumeMessage, ServerProperties } from './properties'; export * from './properties'; export interface Connection extends events.EventEmitter { close(): Promise; createChannel(): Promise; createConfirmChannel(): Promise; + serverProperties: ServerProperties; } export interface Channel extends events.EventEmitter { diff --git a/types/amqplib/properties.d.ts b/types/amqplib/properties.d.ts index 97dc8ac393..4c7a210c6f 100644 --- a/types/amqplib/properties.d.ts +++ b/types/amqplib/properties.d.ts @@ -210,3 +210,13 @@ export interface XDeath { "original-expiration"?: any; "routing-keys": string[]; } + +export interface ServerProperties { + host: string; + product: string; + version: string; + platform: string; + copyright?: string; + information: string; + [key: string]: string | undefined; +}