Skip to content

Commit b743e24

Browse files
committed
Enable strict compilation settings in git extension
Enables strict checks in the git extensions
1 parent 00ca96b commit b743e24

7 files changed

Lines changed: 17 additions & 16 deletions

File tree

extensions/git/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@
902902
"devDependencies": {
903903
"@types/mocha": "2.2.43",
904904
"@types/node": "7.0.43",
905+
"@types/byline": "4.2.31",
905906
"mocha": "^3.2.0"
906907
}
907908
}

extensions/git/src/commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ export class CommandCenter {
13841384
}
13851385

13861386
private createCommand(id: string, key: string, method: Function, options: CommandOptions): (...args: any[]) => any {
1387-
const result = (...args) => {
1387+
const result = (...args: any[]) => {
13881388
let result: Promise<any>;
13891389

13901390
if (!options.repository) {
@@ -1433,7 +1433,7 @@ export class CommandCenter {
14331433
.replace(/^error: /mi, '')
14341434
.replace(/^> husky.*$/mi, '')
14351435
.split(/[\r\n]/)
1436-
.filter(line => !!line)
1436+
.filter((line: any) => !!line)
14371437
[0];
14381438

14391439
message = hint
@@ -1459,7 +1459,7 @@ export class CommandCenter {
14591459
};
14601460

14611461
// patch this object, so people can call methods directly
1462-
this[key] = result;
1462+
(this as any)[key] = result;
14631463

14641464
return result;
14651465
}

extensions/git/src/decorators.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function decorate(decorator: (fn: Function, key: string) => Function): Function
3131
function _memoize(fn: Function, key: string): Function {
3232
const memoizeKey = `$memoize$${key}`;
3333

34-
return function (...args: any[]) {
34+
return function (this: any, ...args: any[]) {
3535
if (!this.hasOwnProperty(memoizeKey)) {
3636
Object.defineProperty(this, memoizeKey, {
3737
configurable: false,
@@ -51,7 +51,7 @@ function _throttle<T>(fn: Function, key: string): Function {
5151
const currentKey = `$throttle$current$${key}`;
5252
const nextKey = `$throttle$next$${key}`;
5353

54-
const trigger = function (...args: any[]) {
54+
const trigger = function (this: any, ...args: any[]) {
5555
if (this[nextKey]) {
5656
return this[nextKey];
5757
}
@@ -81,7 +81,7 @@ export const throttle = decorate(_throttle);
8181
function _sequentialize<T>(fn: Function, key: string): Function {
8282
const currentKey = `__$sequence$${key}`;
8383

84-
return function (...args: any[]) {
84+
return function (this: any, ...args: any[]) {
8585
const currentPromise = this[currentKey] as Promise<any> || Promise.resolve(null);
8686
const run = async () => await fn.apply(this, args);
8787
this[currentKey] = currentPromise.then(run, run);
@@ -95,7 +95,7 @@ export function debounce(delay: number): Function {
9595
return decorate((fn, key) => {
9696
const timerKey = `$debounce$${key}`;
9797

98-
return function (...args: any[]) {
98+
return function (this: any, ...args: any[]) {
9999
clearTimeout(this[timerKey]);
100100
this[timerKey] = setTimeout(() => fn.apply(this, args), delay);
101101
};

extensions/git/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
4848

4949
outputChannel.appendLine(localize('using git', "Using git {0} from {1}", info.version, info.path));
5050

51-
const onOutput = str => outputChannel.append(str);
51+
const onOutput = (str: string) => outputChannel.append(str);
5252
git.onOutput.addListener('log', onOutput);
5353
disposables.push(toDisposable(() => git.onOutput.removeListener('log', onOutput)));
5454

extensions/git/src/repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class Resource implements SourceControlResourceState {
8282
get original(): Uri { return this._resourceUri; }
8383
get renameResourceUri(): Uri | undefined { return this._renameResourceUri; }
8484

85-
private static Icons = {
85+
private static Icons: any = {
8686
light: {
8787
Modified: getIconUri('status-modified', 'light'),
8888
Added: getIconUri('status-added', 'light'),
@@ -724,7 +724,7 @@ export class Repository implements Disposable {
724724

725725
const child = this.repository.stream(['check-ignore', ...filePaths]);
726726

727-
const onExit = exitCode => {
727+
const onExit = (exitCode: number) => {
728728
if (exitCode === 1) {
729729
// nothing ignored
730730
resolve(new Set<string>());

extensions/git/src/util.ts

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

87-
export function assign<T>(destination: T, ...sources: any[]): T {
87+
export function assign<T>(destination: T, ...sources: (keyof T)[]): T {
8888
for (const source of sources) {
8989
Object.keys(source).forEach(key => destination[key] = source[key]);
9090
}
@@ -115,12 +115,12 @@ export function groupBy<T>(arr: T[], fn: (el: T) => string): { [key: string]: T[
115115
}, Object.create(null));
116116
}
117117

118-
export function denodeify<R>(fn: Function): (...args) => Promise<R> {
119-
return (...args) => new Promise<R>((c, e) => fn(...args, (err, r) => err ? e(err) : c(r)));
118+
export function denodeify<R>(fn: Function): (...args: any[]) => Promise<R> {
119+
return (...args) => new Promise<R>((c, e) => fn(...args, (err: any, r: any) => err ? e(err) : c(r)));
120120
}
121121

122-
export function nfcall<R>(fn: Function, ...args): Promise<R> {
123-
return new Promise<R>((c, e) => fn(...args, (err, r) => err ? e(err) : c(r)));
122+
export function nfcall<R>(fn: Function, ...args: any[]): Promise<R> {
123+
return new Promise<R>((c, e) => fn(...args, (err: any, r: any) => err ? e(err) : c(r)));
124124
}
125125

126126
export async function mkdirp(path: string, mode?: number): Promise<boolean> {

extensions/git/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77
"module": "commonjs",
88
"outDir": "./out",
9-
"strictNullChecks": true,
9+
"strict": true,
1010
"experimentalDecorators": true
1111
},
1212
"include": [

0 commit comments

Comments
 (0)