0

I'm using the ssh2-sftp-client NPM package and types for it are provided by @types/ssh2-sftp-client. I've both of them installed but no types are being picked up. This is what my package.json look like:

{
  "name": "name",
  "version": "0.1.0",
  "description": "description",
  "devDependencies": {
    "@types/ssh2": "^1.11.7",
    "@types/ssh2-sftp-client": "^9.0.0"
  },
  "dependencies": {
    "ssh2-sftp-client": "^9.0.4"
  }
}

There's this related answer, however it seems to address types you declare yourself. Do I need to do further setup after installing any @typings package?

Edit... I forgot to add tsconfig.json file:


  "compilerOptions": {
    "lib": ["ES2022"],
    "module": "commonjs",
    "target": "ES2022",
    "declaration": true,
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": false,
    "inlineSourceMap": true,
    "inlineSources": true,
    "experimentalDecorators": true,
    "skipLibCheck": true,
    "strictPropertyInitialization": false,
    "typeRoots": [
      "./node_modules/@types"
    ]
  },
  "exclude": [
    "node_modules/**/*",
    "cdk.out"
  ]
}
uzluisf
  • 2,586
  • 1
  • 9
  • 27
  • You might need to restart ts server to make it pick the types. Other than that it should work. – Yury Tarabanko Feb 16 '23 at 15:51
  • I'm using VSCode. How do I restart the server? – uzluisf Feb 16 '23 at 16:46
  • @António Conselheiro I've added the tsconfig to the question. – uzluisf Feb 16 '23 at 16:47
  • Hi @uzluisf I have come across the same problem. I am using ssh2-sftp-client and creating a Client instance fails. I have now added the same `@types` as you, but VSCode says: Module '"ssh2-sftp-client"' has no exported member 'Client'.ts(2305) Wondering if you made any progress. Restarting VSCode doesn't solve anything in this case. – raulra08 May 12 '23 at 10:06

1 Answers1

0

As suggested by @Yury Tarabanko, I restarted the language server and that did the trick. On VSCode, press Cmd/Ctrl + Shift + P to bring up the command palette, and then search/run Developer: Reload Window.

uzluisf
  • 2,586
  • 1
  • 9
  • 27