Skip to content

Commit 6b10eb5

Browse files
domdomeggclaude
andauthored
🤖 Merge PR DefinitelyTyped#73915 feat(google-apps-script): add subject option to Gmail draft reply methods by @domdomegg
Co-authored-by: Claude <[email protected]>
1 parent 11d9095 commit 6b10eb5

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

‎types/google-apps-script/google-apps-script.gmail.d.ts‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,15 @@ declare namespace GoogleAppsScript {
183183
*/
184184
replyTo?: string | undefined;
185185
}
186+
/**
187+
* Options for a Gmail draft reply.
188+
*/
189+
interface GmailReplyOptions extends GmailAdvancedOptions {
190+
/**
191+
* The subject line for the reply draft (up to 250 characters).
192+
*/
193+
subject?: string | undefined;
194+
}
186195
/** alias to GmailAdvancedOptions */
187196
type GmailDraftOptions = GmailAdvancedOptions;
188197
/**
@@ -220,9 +229,9 @@ declare namespace GoogleAppsScript {
220229
*/
221230
interface GmailMessage {
222231
createDraftReply(body: string): GmailDraft;
223-
createDraftReply(body: string, options: GmailAdvancedOptions): GmailDraft;
232+
createDraftReply(body: string, options: GmailReplyOptions): GmailDraft;
224233
createDraftReplyAll(body: string): GmailDraft;
225-
createDraftReplyAll(body: string, options: GmailAdvancedOptions): GmailDraft;
234+
createDraftReplyAll(body: string, options: GmailReplyOptions): GmailDraft;
226235
forward(recipient: string): GmailMessage;
227236
forward(recipient: string, options: GmailAdvancedOptions): GmailMessage;
228237
getAttachments(): GmailAttachment[];
@@ -264,9 +273,9 @@ declare namespace GoogleAppsScript {
264273
interface GmailThread {
265274
addLabel(label: GmailLabel): GmailThread;
266275
createDraftReply(body: string): GmailDraft;
267-
createDraftReply(body: string, options: GmailAdvancedOptions): GmailDraft;
276+
createDraftReply(body: string, options: GmailReplyOptions): GmailDraft;
268277
createDraftReplyAll(body: string): GmailDraft;
269-
createDraftReplyAll(body: string, options: GmailAdvancedOptions): GmailDraft;
278+
createDraftReplyAll(body: string, options: GmailReplyOptions): GmailDraft;
270279
getFirstMessageSubject(): string;
271280
getId(): string;
272281
getLabels(): GmailLabel[];

‎types/google-apps-script/test/google-apps-script-tests.ts‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,3 +1536,50 @@ function optionalFields() {
15361536
console.log("Found an element");
15371537
}
15381538
}
1539+
1540+
// GmailMessage.createDraftReply and createDraftReplyAll with subject option
1541+
function testGmailDraftReplyWithSubject() {
1542+
const message = GmailApp.getMessageById("message-id");
1543+
const thread = GmailApp.getThreadById("thread-id");
1544+
1545+
// Test GmailMessage.createDraftReply with subject option
1546+
message.createDraftReply("Reply body"); // $ExpectType GmailDraft
1547+
message.createDraftReply("Reply body", { subject: "Custom subject" }); // $ExpectType GmailDraft
1548+
// $ExpectType GmailDraft
1549+
message.createDraftReply("Reply body", {
1550+
subject: "Custom subject",
1551+
1552+
1553+
htmlBody: "<p>HTML reply</p>",
1554+
});
1555+
1556+
// Test GmailMessage.createDraftReplyAll with subject option
1557+
message.createDraftReplyAll("Reply all body"); // $ExpectType GmailDraft
1558+
message.createDraftReplyAll("Reply all body", { subject: "Custom subject for all" }); // $ExpectType GmailDraft
1559+
// $ExpectType GmailDraft
1560+
message.createDraftReplyAll("Reply all body", {
1561+
subject: "Custom subject for all",
1562+
1563+
htmlBody: "<p>HTML reply all</p>",
1564+
});
1565+
1566+
// Test GmailThread.createDraftReply with subject option
1567+
thread.createDraftReply("Thread reply body"); // $ExpectType GmailDraft
1568+
thread.createDraftReply("Thread reply body", { subject: "Thread custom subject" }); // $ExpectType GmailDraft
1569+
// $ExpectType GmailDraft
1570+
thread.createDraftReply("Thread reply body", {
1571+
subject: "Thread custom subject",
1572+
1573+
name: "Custom Name",
1574+
});
1575+
1576+
// Test GmailThread.createDraftReplyAll with subject option
1577+
thread.createDraftReplyAll("Thread reply all body"); // $ExpectType GmailDraft
1578+
thread.createDraftReplyAll("Thread reply all body", { subject: "Thread custom subject for all" }); // $ExpectType GmailDraft
1579+
// $ExpectType GmailDraft
1580+
thread.createDraftReplyAll("Thread reply all body", {
1581+
subject: "Thread custom subject for all",
1582+
replyTo: "[email protected]",
1583+
attachments: [DriveApp.getFileById("file-id").getBlob()],
1584+
});
1585+
}

0 commit comments

Comments
 (0)