Fix a few more errors

This commit is contained in:
Matt Bierner 2017-11-06 13:31:06 -08:00
parent b743e245ad
commit ab1d686a41
7 changed files with 21 additions and 18 deletions

View file

@ -34,8 +34,8 @@ function main(argv: string[]): void {
return fatal('Skip fetch commands');
}
const output = process.env['VSCODE_GIT_ASKPASS_PIPE'];
const socketPath = process.env['VSCODE_GIT_ASKPASS_HANDLE'];
const output = process.env['VSCODE_GIT_ASKPASS_PIPE'] as string;
const socketPath = process.env['VSCODE_GIT_ASKPASS_HANDLE'] as string;
const request = argv[2];
const host = argv[4].substring(1, argv[4].length - 2);
const opts: http.RequestOptions = {

View file

@ -28,7 +28,7 @@ function getIPCHandlePath(nonce: string): string {
}
if (process.env['XDG_RUNTIME_DIR']) {
return path.join(process.env['XDG_RUNTIME_DIR'], `vscode-git-askpass-${nonce}.sock`);
return path.join(process.env['XDG_RUNTIME_DIR'] as string, `vscode-git-askpass-${nonce}.sock`);
}
return path.join(os.tmpdir(), `vscode-git-askpass-${nonce}.sock`);

View file

@ -118,9 +118,9 @@ function findSystemGitWin32(base: string): Promise<IGit> {
}
function findGitWin32(): Promise<IGit> {
return findSystemGitWin32(process.env['ProgramW6432'])
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles(x86)']))
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles']))
return findSystemGitWin32(process.env['ProgramW6432'] as string)
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles(x86)'] as string))
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles'] as string))
.then(void 0, () => findSpecificGit('git'));
}
@ -173,12 +173,12 @@ async function exec(child: cp.ChildProcess, options: SpawnOptions = {}): Promise
const disposables: IDisposable[] = [];
const once = (ee: NodeJS.EventEmitter, name: string, fn: Function) => {
const once = (ee: NodeJS.EventEmitter, name: string, fn: (...args: any[]) => void) => {
ee.once(name, fn);
disposables.push(toDisposable(() => ee.removeListener(name, fn)));
};
const on = (ee: NodeJS.EventEmitter, name: string, fn: Function) => {
const on = (ee: NodeJS.EventEmitter, name: string, fn: (...args: any[]) => void) => {
ee.on(name, fn);
disposables.push(toDisposable(() => ee.removeListener(name, fn)));
};
@ -193,12 +193,12 @@ async function exec(child: cp.ChildProcess, options: SpawnOptions = {}): Promise
}),
new Promise<string>(c => {
const buffers: Buffer[] = [];
on(child.stdout, 'data', b => buffers.push(b));
on(child.stdout, 'data', (b: Buffer) => buffers.push(b));
once(child.stdout, 'close', () => c(iconv.decode(Buffer.concat(buffers), encoding)));
}),
new Promise<string>(c => {
const buffers: Buffer[] = [];
on(child.stderr, 'data', b => buffers.push(b));
on(child.stderr, 'data', (b: Buffer) => buffers.push(b));
once(child.stderr, 'close', () => c(Buffer.concat(buffers).toString('utf8')));
})
]);
@ -891,7 +891,7 @@ export class Repository {
const env = { GIT_OPTIONAL_LOCKS: '0' };
const child = this.stream(['status', '-z', '-u'], { env });
const onExit = exitCode => {
const onExit = (exitCode: number) => {
if (exitCode !== 0) {
const stderr = stderrData.join('');
return e(new GitError({
@ -953,7 +953,7 @@ export class Repository {
async getRefs(): Promise<Ref[]> {
const result = await this.run(['for-each-ref', '--format', '%(refname) %(objectname)']);
const fn = (line): Ref | null => {
const fn = (line: string): Ref | null => {
let match: RegExpExecArray | null;
if (match = /^refs\/heads\/([^ ]+) ([0-9a-f]{40})$/.exec(line)) {
@ -978,7 +978,7 @@ export class Repository {
const regex = /^stash@{(\d+)}:(.+)$/;
const rawStashes = result.stdout.trim().split('\n')
.filter(b => !!b)
.map(line => regex.exec(line))
.map(line => regex.exec(line) as RegExpExecArray)
.filter(g => !!g)
.map(([, index, description]: RegExpExecArray) => ({ index: parseInt(index), description }));
@ -990,7 +990,7 @@ export class Repository {
const regex = /^([^\s]+)\s+([^\s]+)\s/;
const rawRemotes = result.stdout.trim().split('\n')
.filter(b => !!b)
.map(line => regex.exec(line))
.map(line => regex.exec(line) as RegExpExecArray)
.filter(g => !!g)
.map((groups: RegExpExecArray) => ({ name: groups[1], url: groups[2] }));

View file

@ -5,6 +5,8 @@
'use strict';
import 'mocha';
import { GitStatusParser } from '../git';
import * as assert from 'assert';

View file

@ -5,5 +5,3 @@
/// <reference path='../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../src/vs/vscode.proposed.d.ts'/>
/// <reference types='@types/node'/>
/// <reference types='@types/mocha'/>

View file

@ -84,9 +84,9 @@ export function once(fn: (...args: any[]) => any): (...args: any[]) => any {
};
}
export function assign<T>(destination: T, ...sources: (keyof T)[]): T {
export function assign<T>(destination: T, ...sources: any[]): T {
for (const source of sources) {
Object.keys(source).forEach(key => destination[key] = source[key]);
Object.keys(source).forEach(key => (destination as any)[key] = source[key]);
}
return destination;

View file

@ -6,6 +6,9 @@
],
"module": "commonjs",
"outDir": "./out",
"typeRoots": [
"./node_modules/@types"
],
"strict": true,
"experimentalDecorators": true
},