Fix source files to adhere to stricter TS type checking

pull/142/merge
Kelvin Schoofs 5 years ago
parent 31a0a6b4dc
commit f044bb42a0

@ -147,6 +147,10 @@ export async function createSocket(config: FileSystemConfig): Promise<NodeJS.Rea
Logging.debug(`\tError connecting to hop ${config.hop} for ${config.name}: ${err}`);
err.message = `Couldn't connect through the hop:\n${err.message}`;
return reject(err);
} else if (!channel) {
err = new Error('Did not receive a channel');
Logging.debug(`\tGot no channel when connecting to hop ${config.hop} for ${config.name}`);
return reject(err);
}
channel.once('close', () => ssh.destroy());
resolve(channel);
@ -159,9 +163,9 @@ export async function createSocket(config: FileSystemConfig): Promise<NodeJS.Rea
break;
case 'socks4':
case 'socks5':
return await (await import ('./proxy')).socks(config);
return await (await import('./proxy')).socks(config);
case 'http':
return await (await import ('./proxy')).http(config);
return await (await import('./proxy')).http(config);
default:
throw new Error(`Unknown proxy method`);
}

@ -26,7 +26,7 @@ export class SSHFileSystem implements vscode.FileSystemProvider {
if (relPath.startsWith('/')) relPath = relPath.substr(1);
return path.posix.resolve(this.root, relPath);
}
public continuePromise<T>(func: (cb: (err: Error | null, res?: T) => void) => boolean): Promise<T> {
public continuePromise<T>(func: (cb: (err: Error | null | undefined, res?: T) => void) => boolean): Promise<T> {
return new Promise<T>((resolve, reject) => {
const exec = () => {
this.waitForContinue = false;

@ -1,5 +1,5 @@
export type toPromiseCallback<T> = (err: Error | null, res?: T) => void;
export type toPromiseCallback<T> = (err: Error | null | undefined, res?: T) => void;
export async function toPromise<T>(func: (cb: toPromiseCallback<T>) => void): Promise<T> {
return new Promise<T>((resolve, reject) => {
try {

@ -50,7 +50,7 @@ export abstract class FieldBase<T, P = {}, S = {}> extends React.Component<Props
}
return validator ? validator(newValue!) : null;
}
public getValue(): T {
public getValue(): T | undefined {
const { newValue, oldValue } = this.state;
if (newValue === undefined) {
return this.props.optional ? newValue : oldValue;

@ -23,7 +23,7 @@ export class FieldDropdown<T> extends FieldBase<T, Props<T>, State<T>> {
public renderInput() {
const { newValue, open } = this.state;
const { displayName } = this.props;
const display = newValue ? (displayName ? displayName(newValue) : newValue.toString()) : '';
const display = newValue ? (displayName ? displayName(newValue) : `${newValue}`) : '';
return <div className="FieldDropdown" ref={this.mainDivRef}>
<p style={{ float: 'right', margin: 5 }}></p>
<div className="current" onClick={this.toggle}>{display}</div>
@ -35,7 +35,7 @@ export class FieldDropdown<T> extends FieldBase<T, Props<T>, State<T>> {
const generateItem = (item: T, index: number) => {
const style = displayStyle && displayStyle(item);
return <li key={index} style={style} onClick={this.select.bind(this, item)}>
{displayName ? displayName(item) : item.toString()}
{displayName ? displayName(item) : `${item}`}
</li>
};
return <ul className="list">

Loading…
Cancel
Save