Skip to content

Commit

Permalink
chore: comply with our Prettier overlords
Browse files Browse the repository at this point in the history
  • Loading branch information
MKRhere committed Sep 2, 2023
1 parent 684c51a commit 779e80e
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ type Shorthand<FName extends Exclude<keyof Telegram, keyof ApiClient>> = Tail<
*/
export type NarrowedContext<
C extends Context,
U extends tg.Update
U extends tg.Update,
> = Context<U> & Omit<C, keyof Context>

export type FilteredContext<
Ctx extends Context,
Filter extends tt.UpdateType | Guard<Ctx['update']>
Filter extends tt.UpdateType | Guard<Ctx['update']>,
> = Filter extends tt.UpdateType
? NarrowedContext<Ctx, Extract<tg.Update, Record<Filter, object>>>
: NarrowedContext<Ctx, Guarded<Filter>>
Expand Down
2 changes: 1 addition & 1 deletion src/core/helpers/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function hasPropType<
O extends object,
K extends PropertyKey,
T extends keyof Mapping,
V extends Mapping[T]
V extends Mapping[T],
>(obj: O | undefined, prop: K, type: T): obj is O & Record<K, V> {
return hasProp(obj, prop) && type === typeof obj[prop]
}
Expand Down
5 changes: 4 additions & 1 deletion src/core/helpers/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export interface FmtString {
}

export class FmtString implements FmtString {
constructor(public text: string, entities?: MessageEntity[]) {
constructor(
public text: string,
entities?: MessageEntity[]
) {
if (entities) {
this.entities = entities
// force parse_mode to undefined if entities are present
Expand Down
5 changes: 4 additions & 1 deletion src/core/network/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ interface ErrorPayload {
parameters?: ResponseParameters
}
export class TelegramError extends Error {
constructor(readonly response: ErrorPayload, readonly on = {}) {
constructor(
readonly response: ErrorPayload,
readonly on = {}
) {
super(`${response.error_code}: ${response.description}`)
}

Expand Down
4 changes: 2 additions & 2 deletions src/deunionize.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export type PropOr<
T extends object | undefined,
P extends string | symbol | number,
D = undefined
D = undefined,
> = T extends Partial<Record<P, unknown>> ? T[P] : D

export type UnionKeys<T> = T extends unknown ? keyof T : never
Expand All @@ -13,7 +13,7 @@ type AddOptionalKeys<K extends PropertyKey> = { readonly [P in K]?: never }
*/
export type Deunionize<
B extends object | undefined,
T extends B = B
T extends B = B,
> = T extends object ? T & AddOptionalKeys<Exclude<UnionKeys<B>, keyof T>> : T

/**
Expand Down
2 changes: 1 addition & 1 deletion src/future.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type ReplyContext = { [key in keyof Context & `reply${string}`]: Context[key] }

function makeReply<
C extends Context,
E extends { reply_to_message_id?: number }
E extends { reply_to_message_id?: number },
>(ctx: C, extra?: E) {
const reply_to_message_id = ctx.message?.message_id
return { reply_to_message_id, ...extra }
Expand Down
2 changes: 1 addition & 1 deletion src/markup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Markup<
| InlineKeyboardMarkup
| ReplyKeyboardMarkup
| ReplyKeyboardRemove
| ForceReply
| ForceReply,
> {
constructor(readonly reply_markup: T) {}

Expand Down
2 changes: 1 addition & 1 deletion src/scenes/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface SceneContextSceneOptions<D extends SceneSessionData> {

export default class SceneContextScene<
C extends SessionContext<SceneSession<D>>,
D extends SceneSessionData = SceneSessionData
D extends SceneSessionData = SceneSessionData,
> {
private readonly options: SceneContextSceneOptions<D>

Expand Down
2 changes: 1 addition & 1 deletion src/scenes/stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class Stage<
C extends SessionContext<SceneSession<D>> & {
scene: SceneContextScene<C, D>
},
D extends SceneSessionData = SceneSessionData
D extends SceneSessionData = SceneSessionData,
> extends Composer<C> {
options: Partial<SceneContextSceneOptions<D>>
scenes: Map<string, BaseScene<C>>
Expand Down
2 changes: 1 addition & 1 deletion src/scenes/wizard/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface WizardSession<S extends WizardSessionData = WizardSessionData>
export default class WizardContextWizard<
C extends SessionContext<WizardSession> & {
scene: SceneContextScene<C, WizardSessionData>
}
},
> {
readonly state: object
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/scenes/wizard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class WizardScene<
C extends Context & {
scene: SceneContextScene<C, WizardSessionData>
wizard: WizardContextWizard<C>
}
},
>
extends BaseScene<C>
implements MiddlewareObj<C>
Expand Down
2 changes: 1 addition & 1 deletion src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface SessionContext<S extends object> extends Context {
export function session<
S extends NonNullable<C[P]>,
C extends Context & { [key in P]?: C[P] },
P extends (ExclusiveKeys<C, Context> & string) | 'session' = 'session'
P extends (ExclusiveKeys<C, Context> & string) | 'session' = 'session',
// ^ Only allow prop names that aren't keys in base Context.
// At type level, this is cosmetic. To not get cluttered with all Context keys.
>(options?: SessionOptions<S, C, P>): MiddlewareFn<C> {
Expand Down
2 changes: 1 addition & 1 deletion src/telegram-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type WrapCaption<T> = T extends { caption?: string }
*/
type MakeExtra<
M extends keyof Telegram,
K extends keyof Omit<Opts<M>, 'chat_id'> = never
K extends keyof Omit<Opts<M>, 'chat_id'> = never,
> = WrapCaption<Omit<Opts<M>, 'chat_id' | K>>

export type ExtraAddStickerToSet = MakeExtra<
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type NonemptyReadonlyArray<T> = readonly [T, ...T[]]
export type ExclusiveKeys<A extends object, B extends object> = keyof Omit<A, keyof B>

export function fmtCaption<
Extra extends { caption?: string | FmtString } | undefined
Extra extends { caption?: string | FmtString } | undefined,
>(
extra?: Extra
): Extra extends undefined
Expand Down

0 comments on commit 779e80e

Please sign in to comment.