Skip to content

Commit

Permalink
Fix edit transform return type (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
smigles authored Oct 7, 2023
1 parent f37a887 commit 5388018
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ export interface MwnOptions {
suppressInvalidDateWarning?: boolean;
}

export type EditTransform = (rev: {
content: string;
timestamp: string;
}) => string | ApiEditPageParams | Promise<string | ApiEditPageParams>;

type editConfigType = {
conflictRetries?: number;
suppressNochangeWarning?: boolean;
Expand Down Expand Up @@ -976,7 +981,7 @@ export class Mwn {
*/
async edit(
title: string | number,
transform: (rev: { content: string; timestamp: string }) => string | ApiEditPageParams,
transform: EditTransform,
editConfig?: editConfigType
): Promise<ApiEditResponse> {
editConfig = editConfig || this.options.editConfig;
Expand Down
6 changes: 3 additions & 3 deletions src/page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MwnError } from './error';

import type { Mwn, MwnTitle } from './bot';
import type { Mwn, MwnTitle, EditTransform } from './bot';
import type {
ApiDeleteParams,
ApiEditPageParams,
Expand Down Expand Up @@ -155,7 +155,7 @@ export interface MwnPage extends MwnTitle {
* @see https://wikiwho.wmflabs.org/
*/
queryAuthors(): Promise<AuthorshipData>;
edit(transform: (rev: { content: string; timestamp: string }) => string | ApiEditPageParams): Promise<any>;
edit(transform: EditTransform): Promise<any>;
save(text: string, summary?: string, options?: ApiEditPageParams): Promise<any>;
newSection(header: string, message: string, additionalParams?: ApiEditPageParams): Promise<any>;
move(target: string, summary: string, options?: ApiMoveParams): Promise<any>;
Expand Down Expand Up @@ -651,7 +651,7 @@ export default function (bot: Mwn): MwnPageStatic {
/**** Post operations *****/
// Defined in bot.js

edit(transform: (rev: { content: string; timestamp: string }) => string | ApiEditPageParams) {
edit(transform: EditTransform) {
return bot.edit(this.toString(), transform);
}

Expand Down

0 comments on commit 5388018

Please sign in to comment.