Skip to content

Commit 1b9f13e

Browse files
oltolmWebFreak001
authored andcommitted
set "noImplicitAny" to true and fix the problems
1 parent 86b6678 commit 1b9f13e

12 files changed

Lines changed: 114 additions & 56 deletions

File tree

package-lock.json

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@
11121112
"@istanbuljs/nyc-config-typescript": "^1.0.2",
11131113
"@types/mocha": "^5.2.6",
11141114
"@types/node": "^11.11.3",
1115+
"@types/ssh2": "^1.15.0",
11151116
"@types/vscode": "^1.55.0",
11161117
"@typescript-eslint/eslint-plugin": "^5.22.0",
11171118
"@typescript-eslint/parser": "^5.22.0",

src/backend/backend.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export interface IBackend {
6060
attach(cwd: string, executable: string, target: string, autorun: string[]): Thenable<any>;
6161
connect(cwd: string, executable: string, target: string, autorun: string[]): Thenable<any>;
6262
start(runToStart: boolean): Thenable<boolean>;
63-
stop();
64-
detach();
63+
stop(): void;
64+
detach(): void;
6565
interrupt(): Thenable<boolean>;
6666
continue(): Thenable<boolean>;
6767
next(): Thenable<boolean>;

src/backend/gdb_expansion.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { VariableObject } from "./backend";
12
import { MINode } from "./mi_parse";
23

34
const resultRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-]*|\[\d+\])\s*=\s*/;
@@ -29,7 +30,7 @@ export function isExpandable(value: string): number {
2930
else return 0;
3031
}
3132

32-
export function expandValue(variableCreate: Function, value: string, root: string = "", extra: any = undefined): any {
33+
export function expandValue(variableCreate: (arg: VariableObject | string, options?: any) => any, value: string, root: string = "", extra: any = undefined): any {
3334
const parseCString = () => {
3435
value = value.trim();
3536
if (value[0] != '"' && value[0] != '\'')
@@ -56,10 +57,10 @@ export function expandValue(variableCreate: Function, value: string, root: strin
5657
};
5758

5859
const stack = [root];
59-
let parseValue, parseCommaResult, parseCommaValue, parseResult, createValue;
60+
let parseValue: () => any, parseCommaResult: (pushToStack: boolean) => any, parseCommaValue: () => any, parseResult: (pushToStack: boolean) => any, createValue: (name: string, val: any) => any;
6061
let variable = "";
6162

62-
const getNamespace = (variable) => {
63+
const getNamespace = (variable: string) => {
6364
let namespace = "";
6465
let prefix = "";
6566
stack.push(variable);
@@ -209,7 +210,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
209210
return createValue(name, val);
210211
};
211212

212-
createValue = (name, val) => {
213+
createValue = (name: string, val: any) => {
213214
let ref = 0;
214215
if (typeof val == "object") {
215216
ref = variableCreate(val);
@@ -223,7 +224,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
223224
val = "Object@" + val;
224225
}
225226
} else if (typeof val == "string" && val.startsWith("@0x")) {
226-
ref = variableCreate(getNamespace("*&" + name.substr));
227+
ref = variableCreate(getNamespace("*&" + name.substring(1)));
227228
val = "Ref" + val;
228229
} else if (typeof val == "string" && val.startsWith("<...>")) {
229230
ref = variableCreate(getNamespace(name));

src/backend/mi2/mi2.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as linuxTerm from '../linux/console';
66
import * as net from "net";
77
import * as fs from "fs";
88
import * as path from "path";
9-
import { Client } from "ssh2";
9+
import { Client, ClientChannel, ExecOptions } from "ssh2";
1010

1111
export function escape(str: string) {
1212
return str.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
@@ -29,7 +29,7 @@ export class MI2 extends EventEmitter implements IBackend {
2929
super();
3030

3131
if (procEnv) {
32-
const env = {};
32+
const env: { [key: string]: string } = {};
3333
// Duplicate process.env so we don't override it
3434
for (const key in process.env)
3535
if (process.env.hasOwnProperty(key))
@@ -57,8 +57,8 @@ export class MI2 extends EventEmitter implements IBackend {
5757
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd, env: this.procEnv });
5858
this.process.stdout.on("data", this.stdout.bind(this));
5959
this.process.stderr.on("data", this.stderr.bind(this));
60-
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
61-
this.process.on("error", ((err) => { this.emit("launcherror", err); }).bind(this));
60+
this.process.on("exit", () => this.emit("quit"));
61+
this.process.on("error", err => this.emit("launcherror", err));
6262
const promises = this.initCommands(target, cwd);
6363
if (procArgs && procArgs.length)
6464
promises.push(this.sendCommand("exec-arguments " + procArgs));
@@ -137,7 +137,7 @@ export class MI2 extends EventEmitter implements IBackend {
137137

138138
this.sshConn.on("ready", () => {
139139
this.log("stdout", "Running " + this.application + " over ssh...");
140-
const execArgs: any = {};
140+
const execArgs: ExecOptions = {};
141141
if (args.forwardX11) {
142142
execArgs.x11 = {
143143
single: false,
@@ -150,7 +150,7 @@ export class MI2 extends EventEmitter implements IBackend {
150150
if (err) {
151151
this.log("stderr", "Could not run " + this.application + "(" + sshCMD + ") over ssh!");
152152
if (err === undefined) {
153-
err = "<reason unknown>";
153+
err = new Error("<reason unknown>");
154154
}
155155
this.log("stderr", err.toString());
156156
this.emit("quit");
@@ -161,10 +161,10 @@ export class MI2 extends EventEmitter implements IBackend {
161161
this.stream = stream;
162162
stream.on("data", this.stdout.bind(this));
163163
stream.stderr.on("data", this.stderr.bind(this));
164-
stream.on("exit", (() => {
164+
stream.on("exit", () => {
165165
this.emit("quit");
166166
this.sshConn.end();
167-
}).bind(this));
167+
});
168168
const promises = this.initCommands(target, cwd, attach);
169169
promises.push(this.sendCommand("environment-cd \"" + escape(cwd) + "\""));
170170
if (attach) {
@@ -181,7 +181,7 @@ export class MI2 extends EventEmitter implements IBackend {
181181
}).on("error", (err) => {
182182
this.log("stderr", "Error running " + this.application + " over ssh!");
183183
if (err === undefined) {
184-
err = "<reason unknown>";
184+
err = new Error("<reason unknown>");
185185
}
186186
this.log("stderr", err.toString());
187187
this.emit("quit");
@@ -235,8 +235,8 @@ export class MI2 extends EventEmitter implements IBackend {
235235
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd, env: this.procEnv });
236236
this.process.stdout.on("data", this.stdout.bind(this));
237237
this.process.stderr.on("data", this.stderr.bind(this));
238-
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
239-
this.process.on("error", ((err) => { this.emit("launcherror", err); }).bind(this));
238+
this.process.on("exit", () => this.emit("quit"));
239+
this.process.on("error", err => this.emit("launcherror", err));
240240
const promises = this.initCommands(target, cwd, true);
241241
if (target.startsWith("extended-remote")) {
242242
promises.push(this.sendCommand("target-select " + target));
@@ -267,8 +267,8 @@ export class MI2 extends EventEmitter implements IBackend {
267267
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd, env: this.procEnv });
268268
this.process.stdout.on("data", this.stdout.bind(this));
269269
this.process.stderr.on("data", this.stderr.bind(this));
270-
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
271-
this.process.on("error", ((err) => { this.emit("launcherror", err); }).bind(this));
270+
this.process.on("exit", () => this.emit("quit"));
271+
this.process.on("error", err => this.emit("launcherror", err));
272272
const promises = this.initCommands(target, cwd, true);
273273
promises.push(this.sendCommand("target-select remote " + target));
274274
promises.push(...autorun.map(value => { return this.sendUserInput(value); }));
@@ -279,7 +279,7 @@ export class MI2 extends EventEmitter implements IBackend {
279279
});
280280
}
281281

282-
stdout(data) {
282+
stdout(data: any) {
283283
if (trace)
284284
this.log("stderr", "stdout: " + data);
285285
if (typeof data == "string")
@@ -298,7 +298,7 @@ export class MI2 extends EventEmitter implements IBackend {
298298
}
299299
}
300300

301-
stderr(data) {
301+
stderr(data: any) {
302302
if (typeof data == "string")
303303
this.errbuf += data;
304304
else
@@ -563,7 +563,7 @@ export class MI2 extends EventEmitter implements IBackend {
563563
loadBreakPoints(breakpoints: Breakpoint[]): Thenable<[boolean, Breakpoint][]> {
564564
if (trace)
565565
this.log("stderr", "loadBreakPoints");
566-
const promisses = [];
566+
const promisses: Thenable<[boolean, Breakpoint]>[] = [];
567567
breakpoints.forEach(breakpoint => {
568568
promisses.push(this.addBreakPoint(breakpoint));
569569
});
@@ -651,7 +651,7 @@ export class MI2 extends EventEmitter implements IBackend {
651651
if (trace)
652652
this.log("stderr", "clearBreakPoints");
653653
return new Promise((resolve, reject) => {
654-
const promises = [];
654+
const promises: Thenable<void | MINode>[] = [];
655655
const breakpoints = this.breakpoints;
656656
this.breakpoints = new Map();
657657
breakpoints.forEach((k, index) => {
@@ -709,7 +709,7 @@ export class MI2 extends EventEmitter implements IBackend {
709709

710710
const result = await this.sendCommand(["stack-list-frames"].concat(options).join(" "));
711711
const stack = result.result("stack");
712-
return stack.map(element => {
712+
return stack.map((element: any) => {
713713
const level = MINode.valueOf(element, "@frame.level");
714714
const addr = MINode.valueOf(element, "@frame.addr");
715715
const func = MINode.valueOf(element, "@frame.func");
@@ -856,7 +856,7 @@ export class MI2 extends EventEmitter implements IBackend {
856856
//TODO: add `from` and `to` arguments
857857
const res = await this.sendCommand(`var-list-children --all-values ${this.quote(name)}`);
858858
const children = res.result("children") || [];
859-
const omg: VariableObject[] = children.map(child => new VariableObject(child[1]));
859+
const omg: VariableObject[] = children.map((child: any) => new VariableObject(child[1]));
860860
return omg;
861861
}
862862

@@ -945,6 +945,6 @@ export class MI2 extends EventEmitter implements IBackend {
945945
protected buffer: string;
946946
protected errbuf: string;
947947
protected process: ChildProcess.ChildProcess;
948-
protected stream;
949-
protected sshConn;
948+
protected stream: ClientChannel;
949+
protected sshConn: Client;
950950
}

src/backend/mi2/mi2lldb.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export class MI2_LLDB extends MI2 {
4141
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd, env: this.procEnv });
4242
this.process.stdout.on("data", this.stdout.bind(this));
4343
this.process.stderr.on("data", this.stderr.bind(this));
44-
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
45-
this.process.on("error", ((err) => { this.emit("launcherror", err); }).bind(this));
44+
this.process.on("exit", () => this.emit("quit"));
45+
this.process.on("error", err => this.emit("launcherror", err));
4646
const promises = this.initCommands(target, cwd, true);
4747
promises.push(this.sendCommand("file-exec-and-symbols \"" + escape(executable) + "\""));
4848
promises.push(this.sendCommand("target-attach " + target));

src/backend/mi2/mi2mago.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export class MI2_Mago extends MI2_LLDB {
99
this.sendCommand(command).then((result) => {
1010
const stack = result.resultRecords.results;
1111
const ret: Stack[] = [];
12-
const remaining = [];
13-
const addToStack = (element) => {
12+
const remaining: any = [];
13+
const addToStack = (element: any) => {
1414
const level = MINode.valueOf(element, "frame.level");
1515
const addr = MINode.valueOf(element, "frame.addr");
1616
const func = MINode.valueOf(element, "frame.func");

src/backend/mi_parse.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,19 @@ export function parseMI(output: string): MINode {
150150
*/
151151

152152
let token = undefined;
153-
const outOfBandRecord = [];
153+
const outOfBandRecord: { isStream: boolean, type: string, asyncClass: string, output: [string, any][], content: string }[] = [];
154154
let resultRecords = undefined;
155155

156156
const asyncRecordType = {
157157
"*": "exec",
158158
"+": "status",
159159
"=": "notify"
160-
};
160+
} as const;
161161
const streamRecordType = {
162162
"~": "console",
163163
"@": "target",
164164
"&": "log"
165-
};
165+
} as const;
166166

167167
const parseCString = () => {
168168
if (output[0] != '"')
@@ -192,7 +192,7 @@ export function parseMI(output: string): MINode {
192192
return str;
193193
};
194194

195-
let parseValue, parseCommaResult, parseCommaValue, parseResult;
195+
let parseValue: () => any, parseCommaResult: () => any, parseCommaValue: () => any, parseResult: () => any;
196196

197197
const parseTupleOrList = () => {
198198
if (output[0] != '{' && output[0] != '[')
@@ -274,9 +274,10 @@ export function parseMI(output: string): MINode {
274274
output = output.substring(classMatch[0].length);
275275
const asyncRecord = {
276276
isStream: false,
277-
type: asyncRecordType[match[2]],
277+
type: asyncRecordType[match[2] as keyof typeof asyncRecordType],
278278
asyncClass: classMatch[0],
279-
output: []
279+
output: [] as any,
280+
content: ""
280281
};
281282
let result;
282283
while (result = parseCommaResult())
@@ -285,8 +286,10 @@ export function parseMI(output: string): MINode {
285286
} else if (match[3]) {
286287
const streamRecord = {
287288
isStream: true,
288-
type: streamRecordType[match[3]],
289-
content: parseCString()
289+
type: streamRecordType[match[3] as keyof typeof streamRecordType],
290+
content: parseCString(),
291+
output: [] as [string, any][],
292+
asyncClass: ""
290293
};
291294
outOfBandRecord.push(streamRecord);
292295
}
@@ -310,5 +313,5 @@ export function parseMI(output: string): MINode {
310313
output = output.replace(newlineRegex, "");
311314
}
312315

313-
return new MINode(token, <any> outOfBandRecord || [], resultRecords);
316+
return new MINode(token, outOfBandRecord || [], resultRecords);
314317
}

0 commit comments

Comments
 (0)