From 6f54f13f92b0aa03aaeb04be2812376ceb8308fa Mon Sep 17 00:00:00 2001 From: KnorpelSenf Date: Tue, 24 Dec 2024 20:44:23 +0100 Subject: [PATCH] Fix return type (#1172) (#1173) Co-authored-by: Mobin Askari <132358316+MobinAskari@users.noreply.github.com> Co-authored-by: LWJerri Co-authored-by: MasedMSD <68379695+MasedMSD@users.noreply.github.com> Co-authored-by: Roj --- site/docs/advanced/transformers.md | 4 ++-- site/docs/es/advanced/transformers.md | 4 ++-- site/docs/id/advanced/transformers.md | 4 ++-- site/docs/ru/advanced/transformers.md | 4 ++-- site/docs/uk/advanced/transformers.md | 4 ++-- site/docs/zh/advanced/transformers.md | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/site/docs/advanced/transformers.md b/site/docs/advanced/transformers.md index df36011c0..e2b19ba8a 100644 --- a/site/docs/advanced/transformers.md +++ b/site/docs/advanced/transformers.md @@ -35,8 +35,8 @@ bot.use((ctx, next) => next()); Here is an example of a transformer function that prevents all API calls from happening: ```ts -// Incorrectly return undefined instead of the respective object types. -bot.api.config.use((prev, method, payload) => undefined as any); +// Incorrectly return `{ ok: true } as any` instead of the respective object types. +bot.api.config.use((prev, method, payload, signal) => ({ ok: true }) as any); ``` You can also install transformer functions on the context object's API object. diff --git a/site/docs/es/advanced/transformers.md b/site/docs/es/advanced/transformers.md index 06da73c2e..f29441708 100644 --- a/site/docs/es/advanced/transformers.md +++ b/site/docs/es/advanced/transformers.md @@ -34,8 +34,8 @@ bot.use((ctx, next) => next()); Aquí hay un ejemplo de una función transformadora que evita que se produzcan todas las llamadas a la API: ```ts -// Devuelve incorrectamente undefined en lugar de los respectivos tipos de objetos. -bot.api.config.use((prev, method, payload) => undefined as any); +// Devuelve incorrectamente `{ ok: true } as any` en lugar de los respectivos tipos de objetos. +bot.api.config.use((prev, method, payload, signal) => ({ ok: true } as any)); ``` También puedes instalar funciones transformadoras en el objeto API del objeto de contexto. diff --git a/site/docs/id/advanced/transformers.md b/site/docs/id/advanced/transformers.md index 505c398ce..c14a5e513 100644 --- a/site/docs/id/advanced/transformers.md +++ b/site/docs/id/advanced/transformers.md @@ -36,8 +36,8 @@ bot.use((ctx, next) => next()); Berikut contoh function transformer yang mencegah semua pemanggilan API: ```ts -// Mengembalikan undefined alih-alih type object yang bersangkutan. -bot.api.config.use((prev, method, payload) => undefined as any); +// Mengembalikan `{ ok: true } as any` alih-alih type object yang bersangkutan. +bot.api.config.use((prev, method, payload, signal) => ({ ok: true } as any)); ``` Kamu juga bisa memasang function transformer di object API milik object context. diff --git a/site/docs/ru/advanced/transformers.md b/site/docs/ru/advanced/transformers.md index 546960725..a4943c042 100644 --- a/site/docs/ru/advanced/transformers.md +++ b/site/docs/ru/advanced/transformers.md @@ -35,8 +35,8 @@ bot.use((ctx, next) => next()); Вот пример трансформирующей функции, которая предотвращает все вызовы API: ```ts -// Некорректно возвращают undefined вместо соответствующих типов объектов. -bot.api.config.use((prev, method, payload) => undefined as any); +// Некорректно возвращают `{ ok: true } as any` вместо соответствующих типов объектов. +bot.api.config.use((prev, method, payload, signal) => ({ ok: true }) as any); ``` Вы также можете установить трансформирующие функции в API-объект контекстного объекта. diff --git a/site/docs/uk/advanced/transformers.md b/site/docs/uk/advanced/transformers.md index 4f986b5ab..2fbd023b6 100644 --- a/site/docs/uk/advanced/transformers.md +++ b/site/docs/uk/advanced/transformers.md @@ -35,8 +35,8 @@ bot.use((ctx, next) => next()); Ось приклад перетворювача, який запобігає всім викликам API: ```ts -// Неправильно повертаємо `undefined` замість відповідних типів обʼєктів. -bot.api.config.use((prev, method, payload) => undefined as any); +// Неправильно повертаємо `{ ok: true } as any` замість відповідних типів обʼєктів. +bot.api.config.use((prev, method, payload, signal) => ({ ok: true } as any)); ``` Ви також можете встановити перетворювачі на обʼєкті API обʼєкта контексту. diff --git a/site/docs/zh/advanced/transformers.md b/site/docs/zh/advanced/transformers.md index 7d690ddd2..5a634bb97 100644 --- a/site/docs/zh/advanced/transformers.md +++ b/site/docs/zh/advanced/transformers.md @@ -34,8 +34,8 @@ bot.use((ctx, next) => next()); 这是一个 transformer 函数从发生时阻止所有 API 调用的例子: ```ts -// 错误的返回 undefined 而不是各自的对象类型。 -bot.api.config.use((prev, method, payload) => undefined as any); +// 错误的返回 `{ ok: true } as any` 而不是各自的对象类型。 +bot.api.config.use((prev, method, payload, signal) => ({ ok: true } as any)); ``` 你也可以在上下文对象的 API 对象中安装 transformer 函数。