-
Notifications
You must be signed in to change notification settings - Fork 2
enable typescript strict checks #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable typescript strict checks #9
Conversation
350a403
to
7d22922
Compare
@@ -12,7 +12,6 @@ export const isSSL = /^https|wss/; | |||
type Outgoing0 = ProxyTargetDetailed & ServerOptions; | |||
|
|||
export interface Outgoing extends Outgoing0 { | |||
method?: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is moved to ServerOptions
.
outgoing.port = | ||
options[forward || "target"].port ?? | ||
(isSSL.test(options[forward || "target"].protocol) ? 443 : 80); | ||
+(target.port ?? (target.protocol !== undefined && isSSL.test(target.protocol) ? 443 : 80)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+
is to convert options[forward || "target"].port
(string | number
) to number
.
if (isSSL.test(options[forward || "target"].protocol)) { | ||
if (target.protocol !== undefined && isSSL.test(target.protocol)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When target.protocol
is undefined
, it was working like isSSL.test('undefined')
and returned false
.
target.protocol !== undefined && | ||
required(outgoing.port, target.protocol) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When target.protocol
is undefined
, required(outgoing.port, options[forward || "target"].protocol)
throwed an error before this PR.
// @ts-expect-error FIXME: options.target may be undefined | ||
const proto = common.isSSL.test(options.target.protocol) ? https : http; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a bug. If options.forward
is set and options.target
is not set, this line throws an error. I kept the behavior for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
it("creates the round robin proxy server", async () => { | ||
// create one proxy for each backend server | ||
const proxies = addresses.map((target) => | ||
httpProxy.createProxyServer({ target }), | ||
); | ||
|
||
proxyPort = await getPort(); | ||
servers.proxy = httpProxy.createProxyServer({}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line doesn't seem to be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel free to remove it in another PR.
port: "you", | ||
port: 3000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is needed because of #9 (comment)
@@ -154,7 +155,7 @@ describe("#setupOutgoing", () => { | |||
|
|||
it("should set the agent to false if none is given", () => { | |||
const outgoing: any = {}; | |||
setupOutgoing(outgoing, { target: "http://localhost" }, { url: "/" }); | |||
setupOutgoing(outgoing, { target: new URL("http://localhost") }, { url: "/" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setupOutgoing
expects target
to be normalized.
Thanks!!! Merged and published. |
Added
strict: true
to tsconfig.json and fixed the type errors so that it's easier to maintain.