Add types for common browser functions

This commit is contained in:
Daniel James Smith 2021-10-18 16:34:14 +02:00
parent 1bf7a7cad6
commit 2699e0f5a0
No known key found for this signature in database
GPG Key ID: 03E4BD365FF06726
3 changed files with 6 additions and 6 deletions

View File

@ -39,14 +39,14 @@ export default class NotificationBackground {
return;
}
BrowserApi.messageListener('notification.background', async (msg: any, sender: any, sendResponse: any) => {
await this.processMessage(msg, sender, sendResponse);
BrowserApi.messageListener('notification.background', async (msg: any, sender: chrome.runtime.MessageSender) => {
await this.processMessage(msg, sender);
});
this.cleanupNotificationQueue();
}
async processMessage(msg: any, sender: any, sendResponse: any) {
async processMessage(msg: any, sender: chrome.runtime.MessageSender) {
switch (msg.command) {
case 'bgGetDataForTab':
await this.getDataForTab(sender.tab, msg.responseCommand);

View File

@ -36,7 +36,7 @@ export default class RuntimeBackground {
}
await this.checkOnInstalled();
BrowserApi.messageListener('runtime.background', async (msg: any, sender: any, sendResponse: any) => {
BrowserApi.messageListener('runtime.background', async (msg: any, sender: chrome.runtime.MessageSender, sendResponse: any) => {
await this.processMessage(msg, sender, sendResponse);
});
}

View File

@ -91,8 +91,8 @@ export class BrowserApi {
chrome.tabs.create({ url: url, active: active });
}
static messageListener(name: string, callback: (message: any, sender: any, response: any) => void) {
chrome.runtime.onMessage.addListener((msg: any, sender: any, response: any) => {
static messageListener(name: string, callback: (message: any, sender: chrome.runtime.MessageSender, response: any) => void) {
chrome.runtime.onMessage.addListener((msg: any, sender: chrome.runtime.MessageSender, response: any) => {
callback(msg, sender, response);
});
}