src/debugAdapter: address TS2794 warnings
TS2794 Expected 1 arguments, but got 0
The code is so convoluted that I am not 100% sure about the logic.
But first, let's address the tslint error.
Change-Id: Iab2e45664698d05c6103d535e7b3c6e170623a2f
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/280696
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts
index 72d1772..e91b9e1 100644
--- a/src/debugAdapter/goDebug.ts
+++ b/src/debugAdapter/goDebug.ts
@@ -395,7 +395,7 @@
public program: string;
public remotePath: string;
public loadConfig: LoadConfig;
- public connection: Promise<RPCConnection>;
+ public connection: Promise<RPCConnection|null>; // null if connection isn't necessary (e.g. noDebug mode)
public onstdout: (str: string) => void;
public onstderr: (str: string) => void;
public onclose: (code: number) => void;
@@ -587,7 +587,7 @@
reject(err);
});
- resolve();
+ resolve(null);
return;
}
}
@@ -950,7 +950,7 @@
// we should have a timeout in case disconnectRequestHelper hangs.
await Promise.race([
this.disconnectRequestHelper(response, args),
- new Promise((resolve) => setTimeout(() => {
+ new Promise<void>((resolve) => setTimeout(() => {
log('DisconnectRequestHelper timed out after 5s.');
resolve();
}, 5_000))
@@ -2046,7 +2046,7 @@
if (this.remoteSourcesAndPackages.initializingRemoteSourceFiles) {
try {
- await new Promise((resolve) => {
+ await new Promise<void>((resolve) => {
this.remoteSourcesAndPackages.on(RemoteSourcesAndPackages.INITIALIZED, () => {
resolve();
});
@@ -2175,7 +2175,7 @@
);
}
- private async getPackageInfo(debugState: DebuggerState): Promise<string> {
+ private async getPackageInfo(debugState: DebuggerState): Promise<string|void> {
if (!debugState.currentThread || !debugState.currentThread.file) {
return Promise.resolve(null);
}
diff --git a/test/integration/goDebug.test.ts b/test/integration/goDebug.test.ts
index fbf775b..e52bf1f 100644
--- a/test/integration/goDebug.test.ts
+++ b/test/integration/goDebug.test.ts
@@ -358,7 +358,7 @@
// When the attach request is completed successfully, we should get
// an initialized event.
await Promise.all([
- new Promise(async (resolve) => {
+ new Promise<void>(async (resolve) => {
console.log(`Setting up attach request for ${JSON.stringify(debugConfig)}.`);
const attachResult = await dc.attachRequest(debugConfig as DebugProtocol.AttachRequestArguments);
assert.ok(attachResult.success);
@@ -1170,7 +1170,7 @@
// Calls the helloworld server to get a response.
let response = '';
- await new Promise((resolve) => {
+ await new Promise<void>((resolve) => {
http.get(`http://localhost:${server}`, (res) => {
res.on('data', (data) => response += data);
res.on('end', () => resolve());
@@ -1180,7 +1180,7 @@
await dc.disconnectRequest();
// Checks that after the disconnect, the helloworld server still works.
let secondResponse = '';
- await new Promise((resolve) => {
+ await new Promise<void>((resolve) => {
http.get(`http://localhost:${server}`, (res) => {
res.on('data', (data) => secondResponse += data);
res.on('end', () => resolve());