mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-11 00:31:45 +01:00
[PM-8518] Adding generic typing to tabSendMessage call
This commit is contained in:
parent
9373c5f9cd
commit
52341fb563
@ -176,16 +176,16 @@ export class BrowserApi {
|
|||||||
return BrowserApi.tabSendMessage(tab, obj);
|
return BrowserApi.tabSendMessage(tab, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async tabSendMessage<T>(
|
static async tabSendMessage<T, TResponse = unknown>(
|
||||||
tab: chrome.tabs.Tab,
|
tab: chrome.tabs.Tab,
|
||||||
obj: T,
|
obj: T,
|
||||||
options: chrome.tabs.MessageSendOptions = null,
|
options: chrome.tabs.MessageSendOptions = null,
|
||||||
): Promise<any> {
|
): Promise<TResponse> {
|
||||||
if (!tab || !tab.id) {
|
if (!tab || !tab.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise<any>((resolve) => {
|
return new Promise<TResponse>((resolve) => {
|
||||||
chrome.tabs.sendMessage(tab.id, obj, options, (response) => {
|
chrome.tabs.sendMessage(tab.id, obj, options, (response) => {
|
||||||
if (chrome.runtime.lastError) {
|
if (chrome.runtime.lastError) {
|
||||||
// Some error happened
|
// Some error happened
|
||||||
|
Loading…
Reference in New Issue
Block a user