-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add basic internal type checks #6
Conversation
@@ -103,12 +144,13 @@ class VirtualResponse extends PassThrough { | |||
if (body === null) body = Buffer.alloc(0); | |||
|
|||
if (body instanceof Buffer) { | |||
// @ts-ignore | |||
this.body = body; |
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.
I wish we could get rid of this but it's a breaking change I guess..? Being able to immediately read the body without piping is neat but I'm not sure it's worth keeping this super awkward "overwrite the helper method" around for.
lib/respond.js
Outdated
/** | ||
* @template {NodeJS.WritableStream} T | ||
* @param {T} res | ||
* @param {{ end?: boolean | undefined } | undefined} [options] |
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.
does this need the second | undefined
given that options
is already optional?
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.
Removed both | undefined
since they were redundant.
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.
LGTM; thanks!
@@ -28,6 +28,9 @@ | |||
"caseless": "^0.10.0" | |||
}, | |||
"devDependencies": { | |||
"@types/caseless": "^0.12.2", | |||
"@types/mocha": "^5.2.7", | |||
"@types/node": "^12.0.4", | |||
"assertive": "^2.1.0", |
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.
looks like we also need a npm i -D typescript
Fixed! |
I went for a minimal PR with internal checks only as a starting point. May follow up with type checks for the tests and/or public interface types.