Skip to content
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

Merged
merged 7 commits into from
Sep 29, 2023

Conversation

skwee357
Copy link
Contributor

@skwee357 skwee357 commented Sep 22, 2023

Please fill in this template.

Select one of these and delete the others:

If adding a new definition:

  • The package does not already provide its own types, or cannot have its .d.ts files generated via --declaration
  • If this is for an npm package, match the name. If not, do not conflict with the name of an npm package.
  • Create it with dts-gen --dt, not by basing it on an existing project.
  • Represents shape of module/library correctly
  • tslint.json should contain { "extends": "@definitelytyped/dtslint/dt.json" }, and no additional rules.
  • tsconfig.json should have noImplicitAny, noImplicitThis, strictNullChecks, and strictFunctionTypes set to true.

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: <>
  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.

If removing a declaration:

  • If a package was never on Definitely Typed, you don't need to do anything. (If you wrote a package and provided types, you don't need to register it with us.)
  • Delete the package's directory.
  • Add it to notNeededPackages.json.

@skwee357
Copy link
Contributor Author

skwee357 commented Sep 22, 2023

As per the discussion in #66753

@typescript-bot
Copy link
Contributor

typescript-bot commented Sep 22, 2023

@skwee357 Thank you for submitting this PR!

This is a live comment which I will keep updated.

1 package in this PR

Code Reviews

Because 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

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by type definition owners or DT maintainers

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"
}

@typescript-bot typescript-bot added this to Waiting for Code Reviews in New Pull Request Status Board Sep 22, 2023
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in New Pull Request Status Board Sep 22, 2023
'content-disposition'?: string | undefined;
'content-encoding'?: string | undefined;
'content-language'?: string | undefined;
'content-length'?: string | undefined;
Copy link
Contributor

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'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed

interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {}
interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {
accept?: string | undefined;
'accept-charset'?: string | undefined;
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sheetalkamat sheetalkamat moved this from Needs Maintainer Review to Waiting for Code Reviews in New Pull Request Status Board Sep 22, 2023
@typescript-bot
Copy link
Contributor

@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?

@typescript-bot typescript-bot added the Has Merge Conflict This PR can't be merged because it has a merge conflict. The author needs to update it. label Sep 24, 2023
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Author Action in New Pull Request Status Board Sep 24, 2023
@typescript-bot
Copy link
Contributor

@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!

@typescript-bot typescript-bot removed the Has Merge Conflict This PR can't be merged because it has a merge conflict. The author needs to update it. label Sep 24, 2023
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in New Pull Request Status Board Sep 24, 2023
'content-disposition'?: string | undefined;
'content-encoding'?: string | undefined;
'content-language'?: string | undefined;
'content-length'?: string | number | undefined;
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor

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...

@typescript-bot
Copy link
Contributor

@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?

@typescript-bot
Copy link
Contributor

@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?

@typescript-bot
Copy link
Contributor

@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?

'sec-websocket-protocol'?: string | string[] | undefined;
'sec-websocket-version'?: string | undefined;
server?: string | undefined;
'set-cookie'?: string[] | undefined;
Copy link
Contributor

@Uzlopak Uzlopak Sep 26, 2023

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.

Copy link
Contributor Author

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

@Semigradsky
Copy link
Contributor

@skwee357 Looks good! 👍 Currently you added it for Node.js v20 and TypeScript > 4.8

Need to add also

  • to folder types/node/ts4.8 for TypeScript <= 4.8
  • to folders types/node/v18, types/node/v18/ts4.8, types/node/v16, types/node/v16/ts4.8 for other Node.js versions

@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label Sep 28, 2023
@typescript-bot typescript-bot removed the The CI failed When GH Actions fails label Sep 29, 2023
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in New Pull Request Status Board Sep 29, 2023
@typescript-bot typescript-bot added the Self Merge This PR can now be self-merged by the PR author or an owner label Sep 29, 2023
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Waiting for Author to Merge in New Pull Request Status Board Sep 29, 2023
@typescript-bot
Copy link
Contributor

@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?

@skwee357
Copy link
Contributor Author

Ready to merge

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in New Pull Request Status Board Sep 29, 2023
@typescript-bot typescript-bot merged commit 9189e31 into DefinitelyTyped:master Sep 29, 2023
2 checks passed
@skwee357 skwee357 deleted the typed-headers branch September 29, 2023 15:30
@JandenMa
Copy link

JandenMa commented Sep 29, 2023

image

It is not compatible with the header type of aws4. It broke our deployment. 😔 @mhart

@typescript-bot typescript-bot removed this from Recently Merged in New Pull Request Status Board Sep 29, 2023
@skwee357
Copy link
Contributor Author

@JandenMa I apologize for that.
My understanding is that aws4 expects accept header to be a string, rather than string[]?

As pointed out by @Semigradsky here https://github.com/nodejs/node/blob/31e727db7e0f57bd71d35ce8c1cf378bab309b0f/test/parallel/test-http-server-multiheaders2.js#L32-L45 accept header could be an array.

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.

@JandenMa
Copy link

@skwee357 Thanks for your response.
I think aws4 depends on the old @types/node version.
And no worries I use resolutions to force indirect dependencies to install 18.18.0, it works for now.
Could you let me know when the problematic package is upgraded or resolved?

@Semigradsky
Copy link
Contributor

@JandenMa what the type HeadersInit?

@JandenMa
Copy link

@Semigradsky
image

@Semigradsky
Copy link
Contributor

Ok, looks like aws4 is okay and just HeadersInit from lib.dom.d.ts and ...HttpHeaders from @types/node incompatible. How you use these headers then? Maybe you not need type HeadersInit here.

@JandenMa
Copy link

Well I use the createHttpLink from the @apollo/client for signable requests, the options of fetch argument requires RequestInit type, and the headers of options requires HeadersInit type. @Semigradsky

@Semigradsky
Copy link
Contributor

Do you use node-fetch? Or 'native' fetch from Node.js?

@JandenMa
Copy link

native one~

@Semigradsky
Copy link
Contributor

In this case looks like issue should be gone after #66824 when you will use types from @types/node instead of fetch from lib.dom.d.ts.

@JandenMa
Copy link

Hmmm I don't think that's what I can control though.
The issue I think from aws4.sign, the headers from it that seems different type from the @types/node change. But I could be wrong.

@Semigradsky
Copy link
Contributor

Semigradsky commented Sep 30, 2023

No, they are the same, see

headers?: OutgoingHttpHeaders;

@JandenMa
Copy link

Oh, it refers to the same type.
Alright, I will try to import types from @types/node instead of lib.dom.d.ts (global) when #66824 is merged. That's what you meant right?
Btw, could you let me know after merging?

@JandenMa
Copy link

Thank you @Semigradsky 😋

@Semigradsky Semigradsky mentioned this pull request Sep 30, 2023
8 tasks
AviVahl added a commit to AviVahl/electron-builder that referenced this pull request Oct 1, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Critical package Owner Approved A listed owner of this package signed off on the pull request. Self Merge This PR can now be self-merged by the PR author or an owner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants