Skip to content

Commit ab1d686

Browse files
committed
Fix a few more errors
1 parent b743e24 commit ab1d686

7 files changed

Lines changed: 21 additions & 18 deletions

File tree

extensions/git/src/askpass-main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ function main(argv: string[]): void {
3434
return fatal('Skip fetch commands');
3535
}
3636

37-
const output = process.env['VSCODE_GIT_ASKPASS_PIPE'];
38-
const socketPath = process.env['VSCODE_GIT_ASKPASS_HANDLE'];
37+
const output = process.env['VSCODE_GIT_ASKPASS_PIPE'] as string;
38+
const socketPath = process.env['VSCODE_GIT_ASKPASS_HANDLE'] as string;
3939
const request = argv[2];
4040
const host = argv[4].substring(1, argv[4].length - 2);
4141
const opts: http.RequestOptions = {

extensions/git/src/askpass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function getIPCHandlePath(nonce: string): string {
2828
}
2929

3030
if (process.env['XDG_RUNTIME_DIR']) {
31-
return path.join(process.env['XDG_RUNTIME_DIR'], `vscode-git-askpass-${nonce}.sock`);
31+
return path.join(process.env['XDG_RUNTIME_DIR'] as string, `vscode-git-askpass-${nonce}.sock`);
3232
}
3333

3434
return path.join(os.tmpdir(), `vscode-git-askpass-${nonce}.sock`);

extensions/git/src/git.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ function findSystemGitWin32(base: string): Promise<IGit> {
118118
}
119119

120120
function findGitWin32(): Promise<IGit> {
121-
return findSystemGitWin32(process.env['ProgramW6432'])
122-
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles(x86)']))
123-
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles']))
121+
return findSystemGitWin32(process.env['ProgramW6432'] as string)
122+
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles(x86)'] as string))
123+
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles'] as string))
124124
.then(void 0, () => findSpecificGit('git'));
125125
}
126126

@@ -173,12 +173,12 @@ async function exec(child: cp.ChildProcess, options: SpawnOptions = {}): Promise
173173

174174
const disposables: IDisposable[] = [];
175175

176-
const once = (ee: NodeJS.EventEmitter, name: string, fn: Function) => {
176+
const once = (ee: NodeJS.EventEmitter, name: string, fn: (...args: any[]) => void) => {
177177
ee.once(name, fn);
178178
disposables.push(toDisposable(() => ee.removeListener(name, fn)));
179179
};
180180

181-
const on = (ee: NodeJS.EventEmitter, name: string, fn: Function) => {
181+
const on = (ee: NodeJS.EventEmitter, name: string, fn: (...args: any[]) => void) => {
182182
ee.on(name, fn);
183183
disposables.push(toDisposable(() => ee.removeListener(name, fn)));
184184
};
@@ -193,12 +193,12 @@ async function exec(child: cp.ChildProcess, options: SpawnOptions = {}): Promise
193193
}),
194194
new Promise<string>(c => {
195195
const buffers: Buffer[] = [];
196-
on(child.stdout, 'data', b => buffers.push(b));
196+
on(child.stdout, 'data', (b: Buffer) => buffers.push(b));
197197
once(child.stdout, 'close', () => c(iconv.decode(Buffer.concat(buffers), encoding)));
198198
}),
199199
new Promise<string>(c => {
200200
const buffers: Buffer[] = [];
201-
on(child.stderr, 'data', b => buffers.push(b));
201+
on(child.stderr, 'data', (b: Buffer) => buffers.push(b));
202202
once(child.stderr, 'close', () => c(Buffer.concat(buffers).toString('utf8')));
203203
})
204204
]);
@@ -891,7 +891,7 @@ export class Repository {
891891
const env = { GIT_OPTIONAL_LOCKS: '0' };
892892
const child = this.stream(['status', '-z', '-u'], { env });
893893

894-
const onExit = exitCode => {
894+
const onExit = (exitCode: number) => {
895895
if (exitCode !== 0) {
896896
const stderr = stderrData.join('');
897897
return e(new GitError({
@@ -953,7 +953,7 @@ export class Repository {
953953
async getRefs(): Promise<Ref[]> {
954954
const result = await this.run(['for-each-ref', '--format', '%(refname) %(objectname)']);
955955

956-
const fn = (line): Ref | null => {
956+
const fn = (line: string): Ref | null => {
957957
let match: RegExpExecArray | null;
958958

959959
if (match = /^refs\/heads\/([^ ]+) ([0-9a-f]{40})$/.exec(line)) {
@@ -978,7 +978,7 @@ export class Repository {
978978
const regex = /^stash@{(\d+)}:(.+)$/;
979979
const rawStashes = result.stdout.trim().split('\n')
980980
.filter(b => !!b)
981-
.map(line => regex.exec(line))
981+
.map(line => regex.exec(line) as RegExpExecArray)
982982
.filter(g => !!g)
983983
.map(([, index, description]: RegExpExecArray) => ({ index: parseInt(index), description }));
984984

@@ -990,7 +990,7 @@ export class Repository {
990990
const regex = /^([^\s]+)\s+([^\s]+)\s/;
991991
const rawRemotes = result.stdout.trim().split('\n')
992992
.filter(b => !!b)
993-
.map(line => regex.exec(line))
993+
.map(line => regex.exec(line) as RegExpExecArray)
994994
.filter(g => !!g)
995995
.map((groups: RegExpExecArray) => ({ name: groups[1], url: groups[2] }));
996996

extensions/git/src/test/git.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
'use strict';
77

8+
import 'mocha';
9+
810
import { GitStatusParser } from '../git';
911
import * as assert from 'assert';
1012

extensions/git/src/typings/refs.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@
55

66
/// <reference path='../../../../src/vs/vscode.d.ts'/>
77
/// <reference path='../../../../src/vs/vscode.proposed.d.ts'/>
8-
/// <reference types='@types/node'/>
9-
/// <reference types='@types/mocha'/>

extensions/git/src/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ export function once(fn: (...args: any[]) => any): (...args: any[]) => any {
8484
};
8585
}
8686

87-
export function assign<T>(destination: T, ...sources: (keyof T)[]): T {
87+
export function assign<T>(destination: T, ...sources: any[]): T {
8888
for (const source of sources) {
89-
Object.keys(source).forEach(key => destination[key] = source[key]);
89+
Object.keys(source).forEach(key => (destination as any)[key] = source[key]);
9090
}
9191

9292
return destination;

extensions/git/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
],
77
"module": "commonjs",
88
"outDir": "./out",
9+
"typeRoots": [
10+
"./node_modules/@types"
11+
],
912
"strict": true,
1013
"experimentalDecorators": true
1114
},

0 commit comments

Comments
 (0)