Skip to content

Commit b826c9c

Browse files
authored
🤖 Merge PR DefinitelyTyped#73785 [chrome] update pageCapture namespace by @erwanjugand
1 parent a17b8fa commit b826c9c

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

types/chrome/index.d.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7587,15 +7587,11 @@ declare namespace chrome {
75877587

75887588
/**
75897589
* Saves the content of the tab with given id as MHTML.
7590-
* @param callback Called when the MHTML has been generated.
7591-
* Parameter mhtmlData: The MHTML data as a Blob.
7592-
*/
7593-
export function saveAsMHTML(details: SaveDetails, callback: (mhtmlData?: Blob) => void): void;
7594-
/**
7595-
* Saves the content of the tab with given id as MHTML.
7596-
* @since Chrome 116 MV3
7590+
*
7591+
* Can return its result via Promise in Manifest V3 or later since Chrome 116.
75977592
*/
75987593
export function saveAsMHTML(details: SaveDetails): Promise<Blob | undefined>;
7594+
export function saveAsMHTML(details: SaveDetails, callback: (mhtmlData?: Blob) => void): void;
75997595
}
76007596

76017597
////////////////////

types/chrome/test/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4285,9 +4285,16 @@ function testI18n() {
42854285
chrome.i18n.getUILanguage(); // $ExpectType string
42864286
}
42874287

4288-
async function testPageCapture() {
4289-
chrome.pageCapture.saveAsMHTML({ tabId: 0 }, (data: Blob | undefined) => {}); // $ExpectType void
4290-
await chrome.pageCapture.saveAsMHTML({ tabId: 0 }); // $ExpectType Blob | undefined
4288+
// https://developer.chrome.com/docs/extensions/reference/api/pageCapture
4289+
function testPageCapture() {
4290+
const details = { tabId: 0 };
4291+
4292+
chrome.pageCapture.saveAsMHTML(details); // $ExpectType Promise<Blob | undefined>
4293+
chrome.pageCapture.saveAsMHTML(details, (data) => { // $ExpectType void
4294+
data; // $ExpectType Blob | undefined
4295+
});
4296+
// @ts-expect-error
4297+
chrome.pageCapture.saveAsMHTML(details, () => {}).then(() => {});
42914298
}
42924299

42934300
// https://developer.chrome.com/docs/extensions/reference/api/downloads

0 commit comments

Comments
 (0)