diff --git a/packages/client/scripts/generate-client.cjs b/packages/client/scripts/generate-client.cjs index 1f2363c7..c78af227 100644 --- a/packages/client/scripts/generate-client.cjs +++ b/packages/client/scripts/generate-client.cjs @@ -356,7 +356,9 @@ async function addSingleMethod(state, fileName) { state.imports[module] = new Set() } - state.imports[module].add(name) + if (!isManual || isManual.split('=')[1] !== 'noemit') { + state.imports[module].add(name) + } } } } else if (stmt.kind === ts.SyntaxKind.InterfaceDeclaration) { diff --git a/packages/client/src/client.ts b/packages/client/src/client.ts index 5a3b2bc4..7157d730 100644 --- a/packages/client/src/client.ts +++ b/packages/client/src/client.ts @@ -21,7 +21,6 @@ import { getPasswordHint } from './methods/auth/get-password-hint.js' import { logOut } from './methods/auth/log-out.js' import { recoverPassword } from './methods/auth/recover-password.js' import { resendCode } from './methods/auth/resend-code.js' -import { run } from './methods/auth/run.js' import { sendCode } from './methods/auth/send-code.js' import { sendRecoveryCode } from './methods/auth/send-recovery-code.js' import { signIn } from './methods/auth/sign-in.js' @@ -566,6 +565,7 @@ export interface TelegramClient extends BaseTelegramClient { * * @param params Parameters to be passed to {@link start} * @param then Function to be called after {@link start} returns + * @manual=noemit */ run(params: Parameters[1], then?: (user: User) => void | Promise): void /** @@ -5185,10 +5185,6 @@ TelegramClient.prototype.resendCode = function (...args) { return resendCode(this, ...args) } -TelegramClient.prototype.run = function (...args) { - return run(this, ...args) -} - TelegramClient.prototype.sendCode = function (...args) { return sendCode(this, ...args) } @@ -6127,6 +6123,18 @@ TelegramClient.prototype.updateProfile = function (...args) { return updateProfile(this, ...args) } +TelegramClient.prototype.run = + // @manual-impl=run + /** @internal */ + function _run( + this: TelegramClient, + params: Parameters[1], + then?: (user: User) => void | Promise, + ) { + this.start(params) + .then(then) + .catch((err) => this._emitError(err)) + } TelegramClient.prototype.start = // @manual-impl=start /** @internal */ diff --git a/packages/client/src/methods/auth/run.ts b/packages/client/src/methods/auth/run.ts index 7a00fb13..0a074435 100644 --- a/packages/client/src/methods/auth/run.ts +++ b/packages/client/src/methods/auth/run.ts @@ -1,5 +1,6 @@ import { BaseTelegramClient } from '@mtcute/core' +import { TelegramClient } from '../../index.js' import { User } from '../../types/index.js' import { start } from './start.js' @@ -13,6 +14,7 @@ import { start } from './start.js' * * @param params Parameters to be passed to {@link start} * @param then Function to be called after {@link start} returns + * @manual=noemit */ export function run( client: BaseTelegramClient, @@ -23,3 +25,11 @@ export function run( .then(then) .catch((err) => client._emitError(err)) } + +// @manual-impl=run +/** @internal */ +function _run(this: TelegramClient, params: Parameters[1], then?: (user: User) => void | Promise) { + this.start(params) + .then(then) + .catch((err) => this._emitError(err)) +}