Skip to content

Commit

Permalink
Deprecate .guard, .filter, and MountMap
Browse files Browse the repository at this point in the history
  • Loading branch information
wojpawlik committed Nov 10, 2022
1 parent 52b5582 commit e73b595
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class Composer<C extends Context> implements MiddlewareObj<C> {
/**
* Registers middleware for handling updates
* matching given type guard function.
* @deprecated use `Composer::on`
*/
guard<U extends tg.Update>(
guardFn: (update: tg.Update) => update is U,
Expand Down Expand Up @@ -155,6 +156,7 @@ export class Composer<C extends Context> implements MiddlewareObj<C> {
return this.use(Composer.drop(predicate))
}

/** @deprecated use `Composer::drop` */
filter(predicate: Predicate<C>) {
return this.use(Composer.filter(predicate))
}
Expand Down Expand Up @@ -337,6 +339,7 @@ export class Composer<C extends Context> implements MiddlewareObj<C> {
)
}

/** @deprecated use `Composer.drop` */
static filter<C extends Context>(predicate: Predicate<C>): MiddlewareFn<C> {
return Composer.branch(predicate, Composer.passThru(), anoop)
}
Expand Down Expand Up @@ -386,6 +389,7 @@ export class Composer<C extends Context> implements MiddlewareObj<C> {
* @param guardFn predicate to decide whether to run the middleware based on the `ctx.update` object
* @param fns middleware to run if the predicate returns true
* @see `Composer.optional` for a more generic version of this method that allows the predicate to operate on `ctx` itself
* @deprecated use `Composer.on`
*/
static guard<C extends Context, U extends tg.Update>(
guardFn: (u: tg.Update) => u is U,
Expand Down
1 change: 1 addition & 0 deletions src/telegram-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ type ExtractPartial<T extends object, U extends object> = T extends unknown

/**
* Maps [[`Composer.on`]]'s `updateType` or `messageSubType` to a `tt.Update` subtype.
* @deprecated
*/
export type MountMap = {
[T in UpdateType]: Extract<Update, Record<T, object>>
Expand Down

0 comments on commit e73b595

Please sign in to comment.