8000 fix(types): fix Logger type (#1104) · chimurai/http-proxy-middleware@cf72bcd · GitHub
[go: up one dir, main page]

Skip to content

Commit cf72bcd

Browse files
authored
fix(types): fix Logger type (#1104)
1 parent d3851ed commit cf72bcd

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## next
4+
5+
- fix(types): fix Logger type
6+
37
## [v3.0.5](https://github.com/chimurai/http-proxy-middleware/releases/tag/v3.0.5)
48

59
- fix(fixRequestBody): check readableLength ([#1096](https://github.com/chimurai/http-proxy-middleware/pull/1096))

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,5 @@ export interface Options<TReq = http.IncomingMessage, TRes = http.ServerResponse
136136
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/logger.md
137137
* @since v3.0.0
138138
*/
139-
logger?: Logger | any;
139+
logger?: Logger;
140140
}

test/types.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,33 @@ describe('http-proxy-middleware TypeScript Types', () => {
101101
options = { logger: console };
102102
expect(options).toBeDefined();
103103
});
104+
105+
it('should allow custom logger option', () => {
106+
const customLogger = {
107+
info: () => {},
108+
warn: () => {},
109+
error: () => {},
110+
};
111+
options = { logger: customLogger };
112+
expect(options).toBeDefined();
113+
});
114+
115+
it('should fail when custom logger has missing log function', () => {
116+
const customLogger = {
117+
info: () => {},
118+
// warn: () => {},
119+
error: () => {},
120+
};
121+
// @ts-expect-error explanation: should error when customLogger has a missing log function
122+
options = { logger: customLogger };
123+
expect(options).toBeDefined();
124+
});
125+
126+
it('should fail when invalid logger is provided', () => {
127+
// @ts-expect-error explanation: should error when invalid logger is provided
128+
options = { logger: 500 };
129+
expect(options).toBeDefined();
130+
});
104131
});
105132

106133
describe('on', () => {

0 commit comments

Comments
 (0)
0