Skip to content

[Node]: Update http request listeners#61922

Merged
typescript-bot merged 20 commits intoDefinitelyTyped:masterfrom
vansergen:node/custom-request-response
Sep 7, 2022
Merged

[Node]: Update http request listeners#61922
typescript-bot merged 20 commits intoDefinitelyTyped:masterfrom
vansergen:node/custom-request-response

Conversation

@vansergen
Copy link
Copy Markdown
Contributor

@vansergen vansergen commented Aug 24, 2022

Description

The second attempt to merge #58879.

Motivation

import { IncomingMessage, ServerResponse, createServer } from "node:http";
class CustomIncomingMessage extends IncomingMessage {}
class CustomServerResponse extends ServerResponse {}
createServer({
  IncomingMessage: CustomIncomingMessage,
  ServerResponse: CustomServerResponse,
})
  .on("upgrade", (req) => {
    // $ExpectType CustomIncomingMessage
    req;
  })
  .on("request", (req, res) => {
    // $ExpectType CustomIncomingMessage
    req;
    // $ExpectType CustomServerResponse
    res;
    // $ExpectType CustomIncomingMessage
    res.req;
  });

Checklist

@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Aug 24, 2022

@vansergen Thank you for submitting this PR!

This is a live comment which I will keep updated.

4 packages in this PR

Code Reviews

This PR can be merged once it's reviewed.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Type definition owners or DT maintainers needs to approve changes which affect more than one package

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": 61922,
  "author": "vansergen",
  "headCommitOid": "302f650c7986b4efac2a2e158b13ee286ffa351e",
  "mergeBaseOid": "5c248b832935aebece0abff07360102f1e9111f3",
  "lastPushDate": "2022-09-07T09:39:48.000Z",
  "lastActivityDate": "2022-09-07T20:22:09.000Z",
  "maintainerBlessed": "Waiting for Code Reviews",
  "mergeOfferDate": "2022-09-07T18:59:48.000Z",
  "mergeRequestDate": "2022-09-07T20:22:09.000Z",
  "mergeRequestUser": "vansergen",
  "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/https.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/node-tests.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/http.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/https.ts",
          "kind": "test"
        },
        {
          "path": "types/node/v14/http.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v14/https.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v14/test/http.ts",
          "kind": "test"
        },
        {
          "path": "types/node/v14/test/https.ts",
          "kind": "test"
        },
        {
          "path": "types/node/v16/http.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v16/https.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v16/node-tests.ts",
          "kind": "test"
        },
        {
          "path": "types/node/v16/test/http.ts",
          "kind": "test"
        },
        {
          "path": "types/node/v16/test/https.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",
        "SimonSchick",
        "ThomasdenH",
        "WilcoBakker",
        "wwwy3y3",
        "samuela",
        "kuehlein",
        "bhongy",
        "chyzwar",
        "trivikr",
        "yoursunny",
        "qwelias",
        "ExE-Boss",
        "peterblazejewicz",
        "addaleax",
        "victorperin",
        "ZYSzys",
        "NodeJS",
        "LinusU",
        "wafuwafu13",
        "mcollina"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    },
    {
      "name": "on-finished",
      "kind": "edit",
      "files": [
        {
          "path": "types/on-finished/on-finished-tests.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "czechboy0",
        "BendingBender"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "request-stats",
      "kind": "edit",
      "files": [
        {
          "path": "types/request-stats/request-stats-tests.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "BendingBender"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    },
    {
      "name": "stoppable",
      "kind": "edit",
      "files": [
        {
          "path": "types/stoppable/stoppable-tests.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "EricByers",
        "jplusje",
        "BendingBender"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "mcollina",
      "date": "2022-09-07T20:17:20.000Z",
      "isMaintainer": false
    },
    {
      "type": "approved",
      "reviewer": "sheetalkamat",
      "date": "2022-09-07T18:59:01.000Z",
      "isMaintainer": true
    }
  ],
  "mainBotCommentID": 1225963261,
  "ciResult": "pass"
}

@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Aug 24, 2022

Copy link
Copy Markdown
Contributor

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Copy Markdown
Contributor

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

I fear this would be too breaking as a change.

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Aug 24, 2022
@typescript-bot
Copy link
Copy Markdown
Contributor

@vansergen One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you!

@typescript-bot typescript-bot removed the Revision needed This PR needs code changes before it can be merged. label Aug 24, 2022
@vansergen vansergen force-pushed the node/custom-request-response branch from 2d86275 to 3c714aa Compare August 24, 2022 16:48
@vansergen
Copy link
Copy Markdown
Contributor Author

vansergen commented Aug 24, 2022

I fear this would be too breaking as a change.

I believe it could be a breaking change in tests (like it happened in other packages on-finished, stoppable etc.) when $ExpectType is used

@typescript-bot
Copy link
Copy Markdown
Contributor

@mcollina 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 The CI failed When GH Actions fails label Sep 5, 2022
@typescript-bot
Copy link
Copy Markdown
Contributor

@vansergen The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review.

@vansergen vansergen force-pushed the node/custom-request-response branch from 84d3ca9 to d35df07 Compare September 5, 2022 12:02
@typescript-bot typescript-bot removed New Definition This PR creates a new definition package. The CI failed When GH Actions fails labels Sep 5, 2022
Copy link
Copy Markdown
Contributor

@sheetalkamat sheetalkamat left a comment

Choose a reason for hiding this comment

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

Need maintainer signoff to see how is the new approach.

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Sep 6, 2022
@typescript-bot
Copy link
Copy Markdown
Contributor

@vansergen One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you!

Copy link
Copy Markdown
Contributor

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@vansergen vansergen requested review from sheetalkamat and removed request for peterblazejewicz September 7, 2022 09:31
@vansergen
Copy link
Copy Markdown
Contributor Author

@sheetalkamat Could you please be more specific on requested changes?

@typescript-bot typescript-bot removed the Revision needed This PR needs code changes before it can be merged. label Sep 7, 2022
@typescript-bot
Copy link
Copy Markdown
Contributor

@mcollina, @sheetalkamat 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 Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner labels Sep 7, 2022
@typescript-bot
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label Sep 7, 2022
@vansergen
Copy link
Copy Markdown
Contributor Author

Ready to merge

@typescript-bot typescript-bot merged commit 05b8eef into DefinitelyTyped:master Sep 7, 2022
@vansergen vansergen deleted the node/custom-request-response branch September 8, 2022 18:13
@srajiang
Copy link
Copy Markdown

srajiang commented Sep 8, 2022

Hello @vansergen @mcollina @sheetalkamat. I see this was just released as part of v18.7.16 - I posted a more fleshed out issue that we're seeing now using this version with these changes included.

Here's that issue:
#62170

It's breaking in our CI/CD atm, and reverting to a version without the changes resolves the issue.

From reading the error message, the changes have made the https and http createServer types incompatible.

@mcollina
Copy link
Copy Markdown
Contributor

mcollina commented Sep 9, 2022

@vansergen could you revert this? I think it's breaking everybody.

@vansergen
Copy link
Copy Markdown
Contributor Author

vansergen commented Sep 9, 2022

@mcollina Sure, I could create a new PR that reverses it. But I think we should collect those breaking examples first.

@vansergen
Copy link
Copy Markdown
Contributor Author

vansergen commented Sep 10, 2022

The following

import * as http from "node:http";
import * as https from "node:https";
const createServerFn: typeof http.createServer | typeof https.createServer = https.createServer;
createServerFn({});
// TS2349: This expression is not callable. Each member of the union type has signatures, but none of those signatures are compatible with each other.

does not work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Critical package Edits multiple packages Maintainer Approved 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.

5 participants