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

[node] Expose global ResponseInit; remove NodeJS.fetch namespace #67341

Merged

Conversation

thw0rted
Copy link
Contributor

@thw0rted thw0rted commented Nov 7, 2023

Please fill in this template.

Select one of these and delete the others:

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: https://fetch.spec.whatwg.org/
  • 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.

@typescript-bot
Copy link
Contributor

typescript-bot commented Nov 7, 2023

@thw0rted Thank you for submitting this PR!

This is a live comment which I will keep updated.

1 package in this PR

Code Reviews

Because this is a widely-used package, a DT maintainer will need to review it before it can be merged.

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 a DT maintainer

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": 67341,
  "author": "thw0rted",
  "headCommitOid": "3884171509ea897c7411be2f8d23f81dd99c1c62",
  "mergeBaseOid": "9235592ccbfd67841f58d46f06ddef1306bd61e9",
  "lastPushDate": "2023-11-07T16:47:01.000Z",
  "lastActivityDate": "2023-12-01T19:42:37.000Z",
  "mergeOfferDate": "2023-11-30T23:51:14.000Z",
  "mergeRequestDate": "2023-12-01T19:42:37.000Z",
  "mergeRequestUser": "thw0rted",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "node",
      "kind": "edit",
      "files": [
        {
          "path": "types/node/globals.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/test/globals.ts",
          "kind": "test"
        },
        {
          "path": "types/node/ts4.8/globals.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/ts4.8/test/globals.ts",
          "kind": "test"
        },
        {
          "path": "types/node/v18/globals.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v18/test/globals.ts",
          "kind": "test"
        },
        {
          "path": "types/node/v18/ts4.8/globals.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v18/ts4.8/test/globals.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "Microsoft",
        "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": "andrewbranch",
      "date": "2023-11-30T23:50:28.000Z",
      "isMaintainer": true
    },
    {
      "type": "stale",
      "reviewer": "jakebailey",
      "date": "2023-11-13T19:42:49.000Z",
      "abbrOid": "d0cd74c"
    },
    {
      "type": "stale",
      "reviewer": "RyanCavanaugh",
      "date": "2023-11-10T22:32:53.000Z",
      "abbrOid": "d0cd74c"
    }
  ],
  "mainBotCommentID": 1799183235,
  "ciResult": "pass"
}

@thw0rted
Copy link
Contributor Author

thw0rted commented Nov 7, 2023

This is really two changes and if anyone objects to either, I can split into separate PRs.

The first is to add the global ResponseInfo type, which was missing from the original PR #66824.

The second is to refactor out the NodeJS.fetch "fictional" namespace so that users don't start explicitly including the types there, including aliases that are only used as part of the conditional global definition gadget (typeof globalThis extends ...).

I updated tests but couldn't get test-all to run locally (microsoft/DefinitelyTyped-tools#816) and they're failing in CI.

ETA: figured out pnpm run test node/v18 which passes, whew.

@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Nov 7, 2023
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Author Action in New Pull Request Status Board Nov 7, 2023
@typescript-bot
Copy link
Contributor

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

@thw0rted
Copy link
Contributor Author

thw0rted commented Nov 7, 2023

I'm not sure these CI failures are actually caused by my changes, see also #67259 and #67291.

Maybe @jakebailey or @andrewbranch can take a look? (Author and reviewer of microsoft/DefinitelyTyped-tools#803, respectively.)

@thw0rted
Copy link
Contributor Author

thw0rted commented Nov 7, 2023

New commit adds the missing global File type as well, since it winds up in some fetch sub-sub-types.

@typescript-bot typescript-bot removed the The CI failed When GH Actions fails label Nov 7, 2023
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in New Pull Request Status Board Nov 7, 2023
@jakebailey
Copy link
Member

Weird es-abstract related failures are a problem due to our new partial package installs here; the latest dt-tools should fix this via some hack.

@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Nov 7, 2023
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Author Action in New Pull Request Status Board Nov 7, 2023
@typescript-bot
Copy link
Contributor

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

@jakebailey jakebailey closed this Nov 9, 2023
@jakebailey jakebailey reopened this Nov 9, 2023
@jakebailey jakebailey closed this Nov 10, 2023
@jakebailey jakebailey reopened this Nov 10, 2023
@typescript-bot typescript-bot removed the The CI failed When GH Actions fails label Nov 10, 2023
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in New Pull Request Status Board Nov 10, 2023
@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Nov 10, 2023
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Author Action in New Pull Request Status Board Nov 10, 2023
@typescript-bot
Copy link
Contributor

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

@jakebailey
Copy link
Member

wat

image

Remove trailing whitespace
@typescript-bot typescript-bot removed the The CI failed When GH Actions fails label Nov 10, 2023
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in New Pull Request Status Board Nov 10, 2023
@DangerBotOSS
Copy link

Formatting

The following files are not formatted:

  1. types/node/globals.d.ts
  2. types/node/v18/globals.d.ts
  3. types/node/ts4.8/globals.d.ts
  4. types/node/v18/ts4.8/globals.d.ts

Consider running pnpm dprint fmt on these files to make review easier.

Generated by 🚫 dangerJS against 3884171

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

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

@jakebailey, @RyanCavanaugh 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 Unreviewed No one showed up to review this PR, so it'll be reviewed by a DT maintainer. label Nov 18, 2023
@typescript-bot
Copy link
Contributor

@typescript-bot
Copy link
Contributor

@typescript-bot typescript-bot moved this from Needs Maintainer Review to Needs Maintainer Action in New Pull Request Status Board Nov 25, 2023
interface ErrorConstructor {
/** Create .stack property on a target object */
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
export {} // Make this a module
Copy link
Member

Choose a reason for hiding this comment

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

This makes import {} from "node/globals" legal 😕 That’s why my _Request et al. types are accessible. There’s no way to hide them without declaring a module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess you learn something new every day. When I messed this up last time, nobody seems to have noticed. Does that need to change as well?

Would it be preferable to move these declarations out of globals.d.ts and into some other module context? I was mostly trying to avoid exposing the fictional namespace so that library authors wouldn't come to depend on that implementation detail, but of course I'd defer to the team about which hazard is more important to work around.

Copy link
Member

Choose a reason for hiding this comment

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

Well, if nobody noticed the last one, probably nobody will notice this. I guess it’s fine 😄

If we had a type reference directive condition, we could use it to hide everything from imports while keeping things accessible to type reference directives:

{
  "exports": {
    "./*": {
      "types@>=5.5": {
        "typereference": "./*",
        "default": null
      },
      "default": "./*"
    }
  }
}

🤔

@typescript-bot typescript-bot added Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner and removed Unreviewed No one showed up to review this PR, so it'll be reviewed by a DT maintainer. labels Nov 30, 2023
@typescript-bot typescript-bot moved this from Needs Maintainer Action to Waiting for Author to Merge in New Pull Request Status Board Nov 30, 2023
@thw0rted
Copy link
Contributor Author

thw0rted commented Dec 1, 2023

Ready to merge

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in New Pull Request Status Board Dec 1, 2023
@typescript-bot typescript-bot merged commit c788615 into DefinitelyTyped:master Dec 1, 2023
3 checks passed
@typescript-bot typescript-bot removed this from Recently Merged in New Pull Request Status Board Dec 2, 2023
@jordanebelanger
Copy link

Hi folks,

I am having an issue which may stem from this PR. Before this PR, RequestCredentials and other types were exported directly.

Now I am trying to make the OpenAPi typescript-fetch code generator work for nodejs and running into an issue whereas it's referencing types such as RequestCredentials directly. This no longer works following this PR as the type is no longer exported directly.

But, this is something that does work in a context where lib.dom is added as a lib.

image

@thw0rted
Copy link
Contributor Author

You can try an older version of @types/node but I don't think it ever exposed a global RequestCredentials -- this PR only removed a namespaced re-export of import("undici-types").RequestCredentials. There are a number of helper types (interfaces and enums, mostly) that lib.dom.d.ts exports but which have no runtime value, and this is one of them. You could open a PR to add the helpers listed here in the fetch spec, for compatibility with lib-DOM, if you wanted. I'm not a maintainer, but it seems like a pretty good idea to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Critical package Maintainer Approved 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

7 participants