Skip to content

Conversation

@sandersn
Copy link
Contributor

This allows packages that may or may not depend on node create a Buffer stub.

This will solve the current problem with dependents of @types/mongoose, which is deprecated but also broken on @types/node@16 because of the way it references global.Buffer. Even disregarding mongoose, a central class like Buffer should be declared in a mergeable way so that other packages can add to it in extenuating circumstances.

This allows packages that may or may not depend on node create a Buffer stub.
This will solve the current problem with dependents of `@types/mongoose`,
which is deprecated but also broken on `@types/node@16` because
of the way it references `global.Buffer`.
@typescript-bot
Copy link
Contributor

typescript-bot commented Jul 13, 2021

@sandersn Thank you for submitting this PR!

This is a live comment which I will keep updated.

2 packages 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 failed
  • 🕐 A DT maintainer needs to approve changes which affect more than one package

Once every item on this list is checked, I'll ask you for permission to merge and publish the changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 54479,
  "author": "sandersn",
  "headCommitOid": "345beb76f3d61f7542c2560a4cdaad2902bc8460",
  "lastPushDate": "2021-07-13T22:26:43.000Z",
  "lastActivityDate": "2021-07-13T22:35:56.000Z",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "node",
      "kind": "edit",
      "files": [
        {
          "path": "types/node/buffer.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "Microsoft",
        "DefinitelyTyped",
        "jkomyno",
        "alvis",
        "r3nya",
        "btoueg",
        "smac89",
        "touffy",
        "DeividasBakanas",
        "eyqs",
        "Hannes-Magnusson-CK",
        "KSXGitHub",
        "hoo29",
        "kjin",
        "ajafff",
        "islishude",
        "mwiktorczyk",
        "mohsen1",
        "n-e",
        "galkin",
        "parambirs",
        "eps1lon",
        "SimonSchick",
        "ThomasdenH",
        "WilcoBakker",
        "wwwy3y3",
        "samuela",
        "kuehlein",
        "bhongy",
        "chyzwar",
        "trivikr",
        "nguymin4",
        "yoursunny",
        "qwelias",
        "ExE-Boss",
        "Ryan-Willpower",
        "peterblazejewicz",
        "addaleax",
        "JasonHK",
        "victorperin",
        "ZYSzys"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    },
    {
      "name": "safer-buffer",
      "kind": "edit",
      "files": [
        {
          "path": "types/safer-buffer/safer-buffer-tests.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "ffflorian"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    }
  ],
  "reviews": [],
  "mainBotCommentID": 878699083,
  "ciResult": "fail",
  "ciUrl": "https://github.com/DefinitelyTyped/DefinitelyTyped/commit/345beb76f3d61f7542c2560a4cdaad2902bc8460/checks?check_suite_id=3231602075"
}

@typescript-bot typescript-bot added Critical package Untested Change This PR does not touch tests labels Jul 13, 2021
@typescript-bot
Copy link
Contributor

typescript-bot commented Jul 13, 2021

@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Jul 13, 2021
@typescript-bot
Copy link
Contributor

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

@SimonSchick
Copy link
Contributor

@sandersn any timeline for classes to be mergeable with other class declarations?

@peterblazejewicz
Copy link
Member

I assume this will fix issues seen in the CI complaining about Buffer. I've seen this today on other failing PR not related to node directly

1. The name of the static side of Buffer is now BufferConstructor.
2. BYTES_PER_LENGTH is no longer a static member of Buffer.
@typescript-bot typescript-bot added Edits multiple packages and removed The CI failed When GH Actions fails Untested Change This PR does not touch tests labels Jul 13, 2021
@sandersn
Copy link
Contributor Author

@SimonSchick It's not something we've considered recently because it's possible today and not a common requirement.
Two problems:

  1. Current TS never merges two values. (conveniently, namespaces are defined not to be values)
  2. Current TS definitely never merges two block-scoped declarations.

@peterblazejewicz It should fix all the dependents of the deprecated @types/mongoose. I'm not sure about any others.

@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Jul 13, 2021
@typescript-bot
Copy link
Contributor

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

@sandersn
Copy link
Contributor Author

@peterblazejewicz After some experimentation, I'm going to ship this as-is, so that it only fixes mongoose dependents. safer-buffer, for example, still fails with

ERROR: 1:1  no-outside-dependencies 
File /Users/nathanshively-sanders/DefinitelyTyped/node_modules/buffer/index.d.ts 
  comes from a `node_modules` but is not declared in this type's `package.json`. 

Because resolution of 'buffer' resolves not to the ambient module in DT/types/node/buffer.d.ts but the actual module in DT/node_modules/buffer/index.d.ts. It's likely that this will necessitate some other fix to buffer, but I want to at least get the mongoose dependents up and running again.

@sandersn sandersn merged commit f5e6ac9 into master Jul 13, 2021
@sandersn sandersn deleted the make-node-Buffer-mergeable branch July 13, 2021 23:59
@typescript-bot
Copy link
Contributor

I just published @types/[email protected] to npm.

This was referenced Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants