Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
Added missing return types
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschwendener committed Oct 20, 2018
1 parent e7a3d57 commit 72c8094
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/ts/available-color-themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { join } from "path";

const files = readdirSync(join(__dirname, "..", "styles"));

const colorThemes = files.filter((file: string) => {
const colorThemes = files.filter((file: string): boolean => {
return file !== "app.css";
});

export const availableColorThemes = colorThemes.map((colorTheme: string) => {
export const availableColorThemes = colorThemes.map((colorTheme: string): string => {
return colorTheme.replace(".css", "");
}).sort();
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CustomCommand } from "../custom-shortcut";
export class CustomCommandBuilder {
public static buildExecutionArgumentForCustomCommand(userInput: string, customCommand: CustomCommand): string {
const words = StringHelpers.splitIntoWords(userInput);
return `${customCommand.executionArgument} ${words.filter((word) => word !== customCommand.prefix).join(" ")}`;
return `${customCommand.executionArgument} ${words.filter((word): boolean => word !== customCommand.prefix).join(" ")}`;
}

public static buildCustomCommandName(userInput: string, customCommand: CustomCommand): string {
Expand Down
12 changes: 6 additions & 6 deletions src/ts/executors/command-line-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ export class CommandLineExecutor implements Executor {
const commandLineTool = spawn(command.name, command.args);

const commandLineToolStartedMessage = (command.args !== undefined && command.args.length > 0)
? `Started "${command.name}" with parameters: ${command.args.map((c) => `"${c}"`).join(", ")}`
? `Started "${command.name}" with parameters: ${command.args.map((c): string => `"${c}"`).join(", ")}`
: `Started "${command.name}"`;

this.sendCommandLineOutputToRenderer(commandLineToolStartedMessage);

commandLineTool.on("error", (err) => {
commandLineTool.on("error", (err): void => {
this.sendCommandLineOutputToRenderer(err.message);
});

commandLineTool.stderr.on("data", (data) => {
commandLineTool.stderr.on("data", (data): void => {
this.sendCommandLineOutputToRenderer(data.toString());
});

commandLineTool.stdout.on("data", (data) => {
commandLineTool.stdout.on("data", (data): void => {
this.sendCommandLineOutputToRenderer(data.toString());
});

commandLineTool.on("exit", (code) => {
commandLineTool.on("exit", (code): void => {
this.sendCommandLineOutputToRenderer(`Exit ${code} `);
});

ipcMain.on(IpcChannels.exitCommandLineTool, () => {
ipcMain.on(IpcChannels.exitCommandLineTool, (): void => {
commandLineTool.kill();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/ts/executors/file-path-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class FilePathExecutor implements Executor {
}

private handleExecution(command: string): void {
exec(command, (err) => {
exec(command, (err): void => {
if (err) {
throw err;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ts/executors/web-search-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class WebSearchExecutor implements Executor {
for (const webSearch of this.webSearches) {
if (executionArgument.startsWith(`${webSearch.prefix}${WebSearchHelpers.webSearchSeparator}`)) {
const command = Injector.getOpenUrlWithDefaultBrowserCommand(platform(), executionArgument);
exec(command, (err) => {
exec(command, (err): void => {
if (err) {
throw err;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ts/executors/web-url-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class WebUrlExecutor implements Executor {
}

private handleCommandExecution(command: string): void {
exec(command, (err) => {
exec(command, (err): void => {
if (err) {
throw err;
}
Expand Down
6 changes: 3 additions & 3 deletions src/ts/helpers/file-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ export class FileHelpers {
return join(folderPath, f);
});

const accessibleFiles = filePaths.map((filePath) => {
const accessibleFiles = filePaths.map((filePath): string | undefined => {
try {
lstatSync(filePath);
return filePath;
} catch (err) {
// do nothing
}
}).filter((maybe) => maybe !== undefined) as string[];
}).filter((maybe): boolean => maybe !== undefined) as string[];

return accessibleFiles;
} catch (error) {
Expand All @@ -75,7 +75,7 @@ export class FileHelpers {
private static getFileNamesFromFolder(folderPath: string): string[] {
const allFiles = readdirSync(folderPath);

const visibleFiles = allFiles.filter((fileName) => {
const visibleFiles = allFiles.filter((fileName): boolean => {
return !fileName.startsWith(".");
});

Expand Down
2 changes: 1 addition & 1 deletion src/ts/helpers/string-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class StringHelpers {

public static stringToWords(value: string): string[] {
const words = value.split(/\s/g);
return words.filter((w) => {
return words.filter((w): boolean => {
return !StringHelpers.stringIsWhiteSpace(w);
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/ts/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let executionService = new ExecutionService(
config,
ipcEmitter);

const otherInstanceIsAlreadyRunning = app.makeSingleInstance(() => { /* do nothing */ });
const otherInstanceIsAlreadyRunning = app.makeSingleInstance((): void => { /* do nothing */ });
let rescanInterval = setInterval(initializeInputValidationService, TimeHelpers.convertSecondsToMilliseconds(config.rescanInterval));

if (otherInstanceIsAlreadyRunning) {
Expand Down Expand Up @@ -200,7 +200,7 @@ function hideMainWindow(): void {
mainWindow.webContents.send(IpcChannels.resetUserInput);
mainWindow.webContents.send(IpcChannels.hideSettings);

setTimeout(() => {
setTimeout((): void => {
if (mainWindow !== null && mainWindow !== undefined) {
updateWindowSize(0);
mainWindow.hide();
Expand Down Expand Up @@ -350,11 +350,11 @@ ipcMain.on(IpcChannels.hideSettings, (): void => {
updateWindowSize(0);
});

ipcMain.on(IpcChannels.updateAppConfig, (event: Electron.Event, updatedAppConfig: AppConfig) => {
ipcMain.on(IpcChannels.updateAppConfig, (event: Electron.Event, updatedAppConfig: AppConfig): void => {
appConfigRepository.setAppConfig(updatedAppConfig);
});

ipcMain.on(IpcChannels.updateUserConfig, (event: Electron.Event, updatedUserConfig: UserConfigOptions) => {
ipcMain.on(IpcChannels.updateUserConfig, (event: Electron.Event, updatedUserConfig: UserConfigOptions): void => {
config = updatedUserConfig;
setUpNewRescanInterval();
userConfigRepository.saveConfig(updatedUserConfig);
Expand Down
10 changes: 5 additions & 5 deletions src/ts/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ const vue = new Vue({
return `./styles/${config.colorTheme}.css`;
},
getUnusedFallbackWebSearches: (): WebSearch[] => {
return config.webSearches.filter((w) => {
return config.fallbackWebSearches.filter((f) => {
return config.webSearches.filter((w): boolean => {
return config.fallbackWebSearches.filter((f): boolean => {
return f === w.name;
}).length === 0;
});
Expand Down Expand Up @@ -282,7 +282,7 @@ ipcRenderer.on(IpcChannels.commandLineOutput, (event: Electron.Event, arg: strin
handleCommandLineOutput(arg);
});

ipcRenderer.on(IpcChannels.ueliUpdateWasFound, () => {
ipcRenderer.on(IpcChannels.ueliUpdateWasFound, (): void => {
vue.updateAvailable = true;
vue.noUpdateFound = false;
vue.errorOnUpdateCheck = false;
Expand Down Expand Up @@ -380,7 +380,7 @@ function changeActiveItem(direction: string): void {
}

function changeActiveItemByIndex(index: number): void {
vue.searchResults.forEach((searchResultItem: SearchResultItemViewModel) => {
vue.searchResults.forEach((searchResultItem: SearchResultItemViewModel): void => {
searchResultItem.active = false;
});

Expand Down Expand Up @@ -437,7 +437,7 @@ function handleAutoCompletion(): void {
}

function getActiveItem(): SearchResultItemViewModel | undefined {
const activeSearchResults = vue.searchResults.filter((s: any) => {
const activeSearchResults = vue.searchResults.filter((s: any): void => {
return s.active;
}) as SearchResultItemViewModel[];

Expand Down
2 changes: 1 addition & 1 deletion src/ts/search-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class SearchEngine {
}
}

searchResults = searchResults.sort((a, b) => {
searchResults = searchResults.sort((a, b): number => {
return a.score - b.score;
});

Expand Down
4 changes: 3 additions & 1 deletion src/ts/searcher/search-plugins-searcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export class SearchPluginsSearcher implements Searcher {
const plugins = searchPluginManager.getPlugins();

this.items = plugins.length > 0
? plugins.map((plugin) => plugin.getAllItems()).reduce((acc, pluginItems) => acc.concat(pluginItems))
? plugins
.map((plugin): SearchResultItem[] => plugin.getAllItems())
.reduce((acc, pluginItems): SearchResultItem[] => acc.concat(pluginItems))
: [];
}

Expand Down

0 comments on commit 72c8094

Please sign in to comment.