Expected 'undefined' and instead saw 'void'
71 vscode.commands.registerCommand(
72 "python-easy-print.easyPrintPy2",
73 () => {
74 void utils.initPrintPython2();75 }
76 )
77 );
Expected 'undefined' and instead saw 'void'
62 for (const [action, command] of Object.entries(DOCUMENT_COMMANDS)) {
63 context.subscriptions.push(
64 vscode.commands.registerCommand(command, () => {
65 void doc.executeCommand(action);66 })
67 );
68 }
Description
A return;
statement with nothing after it is redundant, and has no effect on the runtime behavior of a function.
This can be confusing, so it's better to disallow these redundant statements.
Bad Practice
function foo() { return; }
function foo() {
doSomething();
return;
}
function foo() {
if (condition) {
bar();
return;
} else {
baz();
}
}
function foo() {
switch (bar) {
case 1:
doSomething();
default:
doSomethingElse();
return;
}
}
Recommended
function foo() { return 5; }
function foo() {
return doSomething();
}
function foo() {
if (condition) {
bar();
return;
} else {
baz();
}
qux();
}
function foo() {
switch (bar) {
case 1:
doSomething();
return;
default:
doSomethingElse();
}
}
function foo() {
for (const foo of bar) {
return;
}
}