-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
added types to OutgoingHttpHeaders #66783
added types to OutgoingHttpHeaders #66783
Conversation
As per the discussion in #66753 |
@skwee357 Thank you for submitting this PR! This is a live comment which I will keep updated. 1 package in this PR
Code ReviewsBecause you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it. You can test the changes of this PR in the Playground. Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 66783,
"author": "skwee357",
"headCommitOid": "adfb3b7b9611cf6a68003e22c675d75dd9096e29",
"mergeBaseOid": "46cd17037ac5399364b0a59511d646c0dd56165a",
"lastPushDate": "2023-09-22T00:50:51.000Z",
"lastActivityDate": "2023-09-29T15:20:01.000Z",
"maintainerBlessed": "Waiting for Code Reviews",
"mergeOfferDate": "2023-09-29T03:06:27.000Z",
"mergeRequestDate": "2023-09-29T15:20:01.000Z",
"mergeRequestUser": "skwee357",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"hugeChange": false,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "node",
"kind": "edit",
"files": [
{
"path": "types/node/http.d.ts",
"kind": "definition"
},
{
"path": "types/node/test/http.ts",
"kind": "test"
},
{
"path": "types/node/ts4.8/http.d.ts",
"kind": "definition"
},
{
"path": "types/node/ts4.8/test/http.ts",
"kind": "test"
},
{
"path": "types/node/v16/http.d.ts",
"kind": "definition"
},
{
"path": "types/node/v16/test/http.ts",
"kind": "test"
},
{
"path": "types/node/v16/ts4.8/http.d.ts",
"kind": "definition"
},
{
"path": "types/node/v16/ts4.8/test/http.ts",
"kind": "test"
},
{
"path": "types/node/v18/http.d.ts",
"kind": "definition"
},
{
"path": "types/node/v18/test/http.ts",
"kind": "test"
},
{
"path": "types/node/v18/ts4.8/http.d.ts",
"kind": "definition"
},
{
"path": "types/node/v18/ts4.8/test/http.ts",
"kind": "test"
}
],
"owners": [
"Microsoft",
"DefinitelyTyped",
"jkomyno",
"alvis",
"r3nya",
"btoueg",
"smac89",
"touffy",
"DeividasBakanas",
"eyqs",
"Hannes-Magnusson-CK",
"hoo29",
"kjin",
"ajafff",
"islishude",
"mwiktorczyk",
"mohsen1",
"n-e",
"galkin",
"parambirs",
"eps1lon",
"ThomasdenH",
"WilcoBakker",
"wwwy3y3",
"samuela",
"kuehlein",
"bhongy",
"chyzwar",
"trivikr",
"yoursunny",
"qwelias",
"ExE-Boss",
"peterblazejewicz",
"addaleax",
"victorperin",
"ZYSzys",
"NodeJS",
"LinusU",
"wafuwafu13",
"mcollina",
"Semigradsky"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "Semigradsky",
"date": "2023-09-28T15:53:00.000Z",
"isMaintainer": false
},
{
"type": "stale",
"reviewer": "Uzlopak",
"date": "2023-09-26T17:45:01.000Z",
"abbrOid": "8bef76d"
}
],
"mainBotCommentID": 1730564460,
"ciResult": "pass"
} |
🔔 @microsoft @DefinitelyTyped @jkomyno @alvis @r3nya @btoueg @smac89 @Touffy @DeividasBakanas @eyqs @Hannes-Magnusson-CK @hoo29 @kjin @ajafff @islishude @mwiktorczyk @mohsen1 @n-e @galkin @parambirs @eps1lon @ThomasdenH @WilcoBakker @wwwy3y3 @samuela @kuehlein @bhongy @chyzwar @trivikr @yoursunny @qwelias @ExE-Boss @peterblazejewicz @addaleax @victorperin @ZYSzys @nodejs @LinusU @wafuwafu13 @mcollina @Semigradsky — please review this PR in the next few days. Be sure to explicitly select |
types/node/http.d.ts
Outdated
'content-disposition'?: string | undefined; | ||
'content-encoding'?: string | undefined; | ||
'content-language'?: string | undefined; | ||
'content-length'?: string | undefined; |
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.
number
often used for 'content-length'
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.
thanks, fixed
types/node/http.d.ts
Outdated
interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {} | ||
interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> { | ||
accept?: string | undefined; | ||
'accept-charset'?: string | undefined; |
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.
string[]
can be used almost with all headers
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 the same applied to IncomingHeaders
? If so, I propose we match them, because as of right now, most incoming headers accept only string.
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.
See https://github.com/nodejs/node/blob/31e727db7e0f57bd71d35ce8c1cf378bab309b0f/test/parallel/test-http-server-multiheaders2.js#L32-L45 for multiple allowed headers list
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 the same applied to IncomingHeaders?
Not sure, they can be received as joined string. Need testing
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 only string
for IncomingHeaders
: https://github.com/nodejs/node/blob/31e727db7e0f57bd71d35ce8c1cf378bab309b0f/test/parallel/test-http-multiple-headers.js#L23-L29
@Semigradsky Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
@skwee357 Unfortunately, this pull request currently has a merge conflict 😥. Please update your PR branch to be up-to-date with respect to master. Have a nice day! |
'content-disposition'?: string | undefined; | ||
'content-encoding'?: string | undefined; | ||
'content-language'?: string | undefined; | ||
'content-length'?: string | number | undefined; |
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 assumption is dangerously wrong. headers are usually strings and have to be casted manually.
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.
In examples and tests Node.js team often use number for 'content-length'. The same in real world. Not sure that need to break it.
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.
Do you have a link?
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.
In examples:
- https://nodejs.org/dist/latest-v20.x/docs/api/http.html#responsewriteheadstatuscode-statusmessage-headers
- https://nodejs.org/dist/latest-v20.x/docs/api/http2.html#http2streamrespondwithfdfd-headers-options
In tests:
- https://github.com/nodejs/node/blob/c829c03df2451212d1d6d28e867579e5d5e4a06e/test/async-hooks/test-http-agent-handle-reuse-serial.js#L63
- https://github.com/nodejs/node/blob/c829c03df2451212d1d6d28e867579e5d5e4a06e/test/parallel/test-http-allow-content-length-304.js#L11
- https://github.com/nodejs/node/blob/c829c03df2451212d1d6d28e867579e5d5e4a06e/test/parallel/test-http-client-spurious-aborted.js#L14
- and many others...
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.
Ok, it will converted to string internally...
623f763
to
905f85b
Compare
@Uzlopak, @Semigradsky Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
@Semigradsky, @Uzlopak Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
@Uzlopak, @Semigradsky Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
types/node/http.d.ts
Outdated
'sec-websocket-protocol'?: string | string[] | undefined; | ||
'sec-websocket-version'?: string | undefined; | ||
server?: string | undefined; | ||
'set-cookie'?: string[] | undefined; |
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.
Imho set-cookie can be also a single string.
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.
Apologies for the back-and-forth. I'm not focused recently
@skwee357 Looks good! 👍 Currently you added it for Node.js v20 and TypeScript > 4.8 Need to add also
|
@Uzlopak Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
Ready to merge |
It is not compatible with the |
@JandenMa I apologize for that. As pointed out by @Semigradsky here https://github.com/nodejs/node/blob/31e727db7e0f57bd71d35ce8c1cf378bab309b0f/test/parallel/test-http-server-multiheaders2.js#L32-L45 As a temporary solution, maybe you can force cast it to satisfy the problematic package? I would also suggest opening an issue / PR to the problematic package. |
@skwee357 Thanks for your response. |
@JandenMa what the type |
Ok, looks like |
Well I use the |
Do you use |
native one~ |
In this case looks like issue should be gone after #66824 when you will use types from |
Hmmm I don't think that's what I can control though. |
No, they are the same, see DefinitelyTyped/types/aws4/index.d.ts Line 38 in 5d599be
|
Oh, it refers to the same type. |
Thank you @Semigradsky 😋 |
due to DefinitelyTyped/DefinitelyTyped#66783 we got a downstream type error on httpExecutor's RequestHeaders fixed by using OutgoingHttpHeader from node bumped repo's @types/node to verify fix
Please fill in this template.
npm test <package to test>
.Select one of these and delete the others:
If adding a new definition:
.d.ts
files generated via--declaration
dts-gen --dt
, not by basing it on an existing project.tslint.json
should contain{ "extends": "@definitelytyped/dtslint/dt.json" }
, and no additional rules.tsconfig.json
should havenoImplicitAny
,noImplicitThis
,strictNullChecks
, andstrictFunctionTypes
set totrue
.If changing an existing definition:
If removing a declaration:
notNeededPackages.json
.