Skip to content

Commit 515f950

Browse files
authored
🤖 Merge PR DefinitelyTyped#72093 Fixed several errors in amqplib connection typing by @bytenik
1 parent 8cc0cd5 commit 515f950

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

‎types/amqplib/amqplib-tests.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const msg = "Hello World";
66
// test promise api
77
amqp.connect("amqp://localhost")
88
.then(connection => {
9+
connection.connection;
910
return connection.createChannel()
1011
.then(channel => {
1112
channel.connection;

‎types/amqplib/index.d.ts‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@ import { ConsumeMessage, GetMessage, Message, Options, Replies, ServerProperties
55
export * from "./properties";
66

77
export interface Connection extends events.EventEmitter {
8+
serverProperties: ServerProperties;
9+
/**
10+
* Set by library when the connection closing has been kicked off
11+
*/
12+
expectSocketClose: boolean;
13+
sentSinceLastCheck: boolean;
14+
recvSinceLastCheck: boolean;
15+
sendMessage(...args: unknown[]): unknown;
16+
}
17+
18+
export interface ChannelModel extends events.EventEmitter {
819
close(): Promise<void>;
920
createChannel(): Promise<Channel>;
1021
createConfirmChannel(): Promise<ConfirmChannel>;
11-
connection: {
12-
serverProperties: ServerProperties;
13-
};
22+
connection: Connection;
1423
updateSecret(newSecret: Buffer, reason: string): Promise<void>;
1524
}
1625

@@ -100,4 +109,4 @@ export const credentials: {
100109
};
101110
};
102111

103-
export function connect(url: string | Options.Connect, socketOptions?: any): Promise<Connection>;
112+
export function connect(url: string | Options.Connect, socketOptions?: any): Promise<ChannelModel>;

0 commit comments

Comments
 (0)