sanketbajoria / ssh2-promise

ssh with promise/async await and typescript support
https://www.npmjs.com/package/ssh2-promise
MIT License
148 stars 25 forks source link

Typescript integration #22

Closed jeffrson closed 3 years ago

jeffrson commented 5 years ago

Hi, would love to see typescript support like import { SFTP } from 'ssh2-promise'

Currently there seems to be no way to access the type of SFTP (in class or interface) at all.

sanketbajoria commented 5 years ago

Currently it is exposed as below var SFTP = require('ssh2-promise').SFTP

jeffrson commented 5 years ago

Then it's just "any".

grammati commented 4 years ago

Workaround:

import Ssh from "ssh2-promise";
const dummy = () => new Ssh({}).sftp();
type SFTP = ReturnType<typeof dummy>;
sanketbajoria commented 3 years ago

Now we support SFTP type

//without esModuleInterop
import SFTP = require('ssh2-promise/lib/sftp')

//with esModuleInterop
import SFTP from 'ssh2-promise/lib/sftp'