Visitar URL original
"sshKeyMemoryNew" is not found in Typescript · Issue #1962 · nodegit/nodegit · GitHub
Skip to content

"sshKeyMemoryNew" is not found in Typescript #1962

Description

@nakky

Probably because namespace "Cred" has changed, "sshKeyMemoryNew" is not found in Typescript.

"sshKeyNew" can be used although the following warning is issued.

Use NodeGit.Credential.sshKeyNew instead of NodeGit.Cred.sshKeyNew

I think it will probably be solved by updating the definition of Typescript.
(It worked when I directly modified the output js file)
The definition may not have been updated because it is alpha, but it is necessary for check, so please support it.

System information

  • node version: v16.3.0
  • npm or yarn version: yarn 1.22.18
  • OS/version/architecture: darwin 21.4.0 arm64
  • Applicable nodegit version: 0.28.0-alpha.20

Activity

  1. tkmcmaster commented on Feb 28, 2023

    @tkmcmaster
    Contributor

    I'm having a different problem. Typescript does have NodeGit.Cred.sshKeyMemoryNew for me but no NodeGit.Credential. Trying to use NodeGit.Cred.sshKeyMemoryNew doesn't work in Node 14 or 16 when using "nodegit": "^0.28.0-alpha.21" and "@types/nodegit": "^0.28.2". If I change to sshKeyNew I get the same deprecation warning, but it works. I've been trying different builds of nodegit 0.28.0 alphas for a while and have yet to find one that works on sskKeyMemoryNew. The same code does work in "nodegit": "^0.27.0"

    Trying to use NodeGit.Cred.sshKeyMemoryNew simply throws the error Method clone has thrown an error. with no additional info (or fetch or other calls). Trying to call it directly looks like it's been removed.

    import { Cred } from "nodegit";
    
    const credentials = await Cred.sshKeyMemoryNew("git", deployKeyPublic, deployKeyPrivate, "");
    
    throws:
    TypeError: nodegit_1.Cred.sshKeyMemoryNew is not a function
    

    So it looks like sshKeyMemoryNew has been removed from the new version but is still in the typings and docs. Looking at https://github.com/nodegit/nodegit/blob/master/lib/credential.js seems to concur.

    Edit: More digging, it looks like the deprecated Cred doesn't have sshKeyMemoryNew but Credential does.

    {
        "typeof NodeGit.Cred": "object",
        "typeof NodeGit.Credential": "function",
        "Object.keys(NodeGit.Cred)": [
          "defaultNew",
          "sshKeyFromAgent",
          "sshKeyNew",
          "usernameNew",
          "userpassPlaintextNew",
          "TYPE"
        ],
        "Object.keys(NodeGit.Credential)": [
          "defaultNew",
          "sshKeyFromAgent",
          "sshKeyMemoryNew",
          "sshKeyNew",
          "usernameNew",
          "userpassPlaintextNew",
          "getSelfFreeingInstanceCount",
          "getNonSelfFreeingConstructedCount",
          "TYPE"
        ]
      }
    

    So there's two bugs. One is here in nodegit that sshKeyMemoryNew is missing from credential.js. The second is in DefinitelyTyped that it's missing NodeGit.Credential.

  2. added a commit that references this issue on Mar 3, 2023
  3. tkmcmaster commented on Mar 3, 2023

    @tkmcmaster
    Contributor

    @nakky Upgrade @types/nodegit to ^0.28.3 to fix Typescript using NodeGit.Credential.sshKeyMemoryNew(). #1973 will fix NodeGit.Cred.sshKeyMemoryNew().

  4. nakky commented on Mar 8, 2023

    @nakky
    Author

    @tkmcmaster I agree with you. When I was looking inside, it seemed that the namespace of the js library had been changed, but Typescript did not support it. (I used "@types/nodegit": "^0.28.2")
    Thanks for the update!! After updating to ^0.28.3 and rewriting to Credential, it worked! !

  5. added a commit that references this issue on Mar 13, 2023
  6. added a commit that references this issue on Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions