From ba19c573a76c75469b5b2ed9093f8373907ea364 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 14 Mar 2021 14:54:12 +0900 Subject: Specific return type --- src/background/infrastructures/ConsoleClient.ts | 20 ++++++++++---------- .../infrastructures/ContentMessageListener.ts | 21 ++++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) (limited to 'src/background/infrastructures') diff --git a/src/background/infrastructures/ConsoleClient.ts b/src/background/infrastructures/ConsoleClient.ts index 2a1df5b..f2d0e8a 100644 --- a/src/background/infrastructures/ConsoleClient.ts +++ b/src/background/infrastructures/ConsoleClient.ts @@ -2,47 +2,47 @@ import { injectable } from "tsyringe"; import * as messages from "../../shared/messages"; export default interface ConsoleClient { - showCommand(tabId: number, command: string): Promise; + showCommand(tabId: number, command: string): Promise; - showFind(tabId: number): Promise; + showFind(tabId: number): Promise; - showInfo(tabId: number, message: string): Promise; + showInfo(tabId: number, message: string): Promise; - showError(tabId: number, message: string): Promise; + showError(tabId: number, message: string): Promise; - hide(tabId: number): Promise; + hide(tabId: number): Promise; } @injectable() export class ConsoleClientImpl implements ConsoleClient { - showCommand(tabId: number, command: string): Promise { + showCommand(tabId: number, command: string): Promise { return browser.tabs.sendMessage(tabId, { type: messages.CONSOLE_SHOW_COMMAND, command, }); } - showFind(tabId: number): Promise { + showFind(tabId: number): Promise { return browser.tabs.sendMessage(tabId, { type: messages.CONSOLE_SHOW_FIND, }); } - showInfo(tabId: number, message: string): Promise { + showInfo(tabId: number, message: string): Promise { return browser.tabs.sendMessage(tabId, { type: messages.CONSOLE_SHOW_INFO, text: message, }); } - showError(tabId: number, message: string): Promise { + showError(tabId: number, message: string): Promise { return browser.tabs.sendMessage(tabId, { type: messages.CONSOLE_SHOW_ERROR, text: message, }); } - hide(tabId: number): Promise { + hide(tabId: number): Promise { return browser.tabs.sendMessage(tabId, { type: messages.CONSOLE_HIDE, }); diff --git a/src/background/infrastructures/ContentMessageListener.ts b/src/background/infrastructures/ContentMessageListener.ts index 6978d35..26f98ab 100644 --- a/src/background/infrastructures/ContentMessageListener.ts +++ b/src/background/infrastructures/ContentMessageListener.ts @@ -61,7 +61,7 @@ export default class ContentMessageListener { onMessage( message: messages.Message, senderTab: browser.tabs.Tab - ): Promise | any { + ): Promise | unknown { switch (message.type) { case messages.CONSOLE_GET_COMPLETION_TYPES: return this.completionController.getCompletionTypes(); @@ -110,11 +110,11 @@ export default class ContentMessageListener { throw new Error("unsupported message: " + message.type); } - onConsoleEnterCommand(text: string): Promise { + onConsoleEnterCommand(text: string): Promise { return this.commandController.exec(text); } - async onSettingsQuery(): Promise { + async onSettingsQuery(): Promise { return (await this.settingController.getSetting()).toJSON(); } @@ -122,11 +122,11 @@ export default class ContentMessageListener { return this.findController.getKeyword(); } - onFindSetKeyword(keyword: string): Promise { + onFindSetKeyword(keyword: string): Promise { return this.findController.setKeyword(keyword); } - onAddonEnabledResponse(enabled: boolean): Promise { + onAddonEnabledResponse(enabled: boolean): Promise { return this.addonEnabledController.indicate(enabled); } @@ -135,22 +135,25 @@ export default class ContentMessageListener { url: string, openerId: number, background: boolean - ): Promise { + ): Promise { if (newTab) { return this.linkController.openNewTab(url, openerId, background); } return this.linkController.openToTab(url, openerId); } - onBackgroundOperation(count: number, op: operations.Operation): Promise { + onBackgroundOperation( + count: number, + op: operations.Operation + ): Promise { return this.operationController.exec(count, op); } - onMarkSetGlobal(key: string, x: number, y: number): Promise { + onMarkSetGlobal(key: string, x: number, y: number): Promise { return this.markController.setGlobal(key, x, y); } - onMarkJumpGlobal(key: string): Promise { + onMarkJumpGlobal(key: string): Promise { return this.markController.jumpGlobal(key); } -- cgit v1.2.3