Skip to content

Commit 233a197

Browse files
authored
🤖 Merge PR DefinitelyTyped#72564 [chrome] add printing.getJobStatus() since Chrome 135 by @erwanjugand
1 parent 8591881 commit 233a197

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

‎types/chrome/index.d.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7881,6 +7881,13 @@ declare namespace chrome {
78817881
export function cancelJob(jobId: string): Promise<void>;
78827882
export function cancelJob(jobId: string, callback: () => void): void;
78837883

7884+
/**
7885+
* Returns the status of the print job. This call will fail with a runtime error if the print job with the given `jobId` doesn't exist. `jobId`: The id of the print job to return the status of. This should be the same id received in a {@link SubmitJobResponse}.
7886+
* @since Chrome 135
7887+
*/
7888+
export function getJobStatus(jobId: string): Promise<`${JobStatus}`>;
7889+
export function getJobStatus(jobId: string, callback: (status: `${JobStatus}`) => void): void;
7890+
78847891
/**
78857892
* Returns the status and capabilities of the printer in CDD format. This call will fail with a runtime error if no printers with given id are installed.
78867893
* Can return its result via Promise in Manifest V3 or later since Chrome 100.
@@ -7905,7 +7912,7 @@ declare namespace chrome {
79057912
/**
79067913
* Event fired when the status of the job is changed. This is only fired for the jobs created by this extension.
79077914
*/
7908-
export const onJobStatusChanged: chrome.events.Event<(jobId: string, status: JobStatus) => void>;
7915+
export const onJobStatusChanged: chrome.events.Event<(jobId: string, status: `${JobStatus}`) => void>;
79097916
}
79107917

79117918
////////////////////

‎types/chrome/test/index.ts‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4659,6 +4659,13 @@ function testPrinting() {
46594659
// @ts-expect-error
46604660
chrome.printing.cancelJob("", () => {}).then(() => {});
46614661

4662+
chrome.printing.getJobStatus(""); // $ExpectType Promise<"PENDING" | "IN_PROGRESS" | "FAILED" | "CANCELED" | "PRINTED">
4663+
chrome.printing.getJobStatus("", status => { // $ExpectType void
4664+
status; // $ExpectType "PENDING" | "IN_PROGRESS" | "FAILED" | "CANCELED" | "PRINTED"
4665+
});
4666+
// @ts-expect-error
4667+
chrome.printing.getJobStatus("", status => {}).then(status => {});
4668+
46624669
chrome.printing.getPrinterInfo(""); // $ExpectType Promise<GetPrinterInfoResponse>
46634670
chrome.printing.getPrinterInfo("", response => {}); // $ExpectType void
46644671
// @ts-expect-error
@@ -4685,15 +4692,15 @@ function testPrinting() {
46854692

46864693
chrome.printing.onJobStatusChanged.addListener((jobId, status) => {
46874694
jobId; // $ExpectType string
4688-
status; // $ExpectType JobStatus
4695+
status; // $ExpectType "PENDING" | "IN_PROGRESS" | "FAILED" | "CANCELED" | "PRINTED"
46894696
});
46904697
chrome.printing.onJobStatusChanged.removeListener((jobId, status) => {
46914698
jobId; // $ExpectType string
4692-
status; // $ExpectType JobStatus
4699+
status; // $ExpectType "PENDING" | "IN_PROGRESS" | "FAILED" | "CANCELED" | "PRINTED"
46934700
});
46944701
chrome.printing.onJobStatusChanged.hasListener((jobId, status) => {
46954702
jobId; // $ExpectType string
4696-
status; // $ExpectType JobStatus
4703+
status; // $ExpectType "PENDING" | "IN_PROGRESS" | "FAILED" | "CANCELED" | "PRINTED"
46974704
});
46984705
chrome.printing.onJobStatusChanged.hasListeners();
46994706
}

0 commit comments

Comments
 (0)