diff --git a/types/lodash/common/array.d.ts b/types/lodash/common/array.d.ts index 59607aeb897ea7..6719936ac82967 100644 --- a/types/lodash/common/array.d.ts +++ b/types/lodash/common/array.d.ts @@ -849,6 +849,7 @@ declare module "../index" { * @param array The array to query. * @return Returns the last element of array. */ + last(array: readonly [...unknown[], T]): T; last(array: List | null | undefined): T | undefined; } interface Collection { diff --git a/types/lodash/common/math.d.ts b/types/lodash/common/math.d.ts index 656cd97f8601b2..588399f21de0b8 100644 --- a/types/lodash/common/math.d.ts +++ b/types/lodash/common/math.d.ts @@ -101,6 +101,7 @@ declare module "../index" { * @param array The array to iterate over. * @returns Returns the maximum value. */ + max(collection: readonly [T, ...T[]]): T; max(collection: List | null | undefined): T | undefined; } interface Collection { @@ -216,6 +217,7 @@ declare module "../index" { * @param array The array to iterate over. * @returns Returns the minimum value. */ + min(collection: readonly [T, ...T[]]): T; min(collection: List | null | undefined): T | undefined; } interface Collection { diff --git a/types/lodash/fp.d.ts b/types/lodash/fp.d.ts index 5f51f7ec4c08f5..037fc204c3483a 100644 --- a/types/lodash/fp.d.ts +++ b/types/lodash/fp.d.ts @@ -1169,7 +1169,10 @@ declare namespace _ { } type LodashFindLastKey1x1 = (object: object | null | undefined) => string | undefined; type LodashFindLastKey1x2 = (predicate: lodash.ValueIteratee) => string | undefined; - type LodashHead = (array: lodash.List | null | undefined) => T | undefined; + interface LodashHead { + (array: readonly [T, ...unknown[]]): T; + (array: lodash.List | null | undefined): T | undefined; + } interface LodashFlatMap { (iteratee: (value: T) => lodash.Many): LodashFlatMap1x1; (iteratee: lodash.__, collection: lodash.List | null | undefined): LodashFlatMap1x2; @@ -2030,7 +2033,10 @@ declare namespace _ { type LodashKebabCase = (string: string) => string; type LodashKeys = (object: any) => string[]; type LodashKeysIn = (object: any) => string[]; - type LodashLast = (array: lodash.List | null | undefined) => T | undefined; + interface LodashLast { + (array: readonly [...unknown[], T]): T; + (array: lodash.List | null | undefined): T | undefined; + } interface LodashLastIndexOf { (value: T): LodashLastIndexOf1x1; (value: lodash.__, array: lodash.List | null | undefined): LodashLastIndexOf1x2; @@ -2167,7 +2173,10 @@ declare namespace _ { } type LodashMatchesProperty1x1 = (srcValue: T) => (value: any) => boolean; type LodashMatchesProperty1x2 = (path: lodash.PropertyPath) => (value: any) => boolean; - type LodashMax = (collection: lodash.List | null | undefined) => T | undefined; + interface LodashMax { + (collection: readonly [T, ...T[]]): T; + (collection: lodash.List | null | undefined): T | undefined; + } interface LodashMaxBy { (iteratee: lodash.ValueIteratee): LodashMaxBy1x1; (iteratee: lodash.__, collection: lodash.List | null | undefined): LodashMaxBy1x2; @@ -2234,7 +2243,10 @@ declare namespace _ { type LodashMergeWith1x6 = (customizer: lodash.MergeWithCustomizer) => TObject & TSource; type LodashMethod = (path: lodash.PropertyPath) => (object: any) => any; type LodashMethodOf = (object: object) => (path: lodash.PropertyPath) => any; - type LodashMin = (collection: lodash.List | null | undefined) => T | undefined; + interface LodashMin { + (collection: readonly [T, ...T[]]): T; + (collection: lodash.List | null | undefined): T | undefined; + } interface LodashMinBy { (iteratee: lodash.ValueIteratee): LodashMinBy1x1; (iteratee: lodash.__, collection: lodash.List | null | undefined): LodashMinBy1x2; diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 52c5b6cede0f47..9c9f5ab54d5595 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -580,6 +580,14 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain fp.head("abc"); // $ExpectType string | undefined fp.head(list); // $ExpectType AbcObject | undefined + fp.head([1, 2, 3]); // $ExpectType number + fp.head([1, 2, 3] as number[]); // $ExpectType number | undefined + fp.head([]); // $ExpectType undefined + fp.head([] as []); // $ExpectType undefined + fp.head([1, 2, 3] as const); // $ExpectType 1 + fp.head([1, 2, 3] as [number, number, number]); // $ExpectType number + fp.head([1, 2, 3] as [...number[]]); // $ExpectType number | undefined + fp.head([1, 2, 3] as [number, ...number[]]); // $ExpectType number } // _.indexOf @@ -862,6 +870,14 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain { _.last("abc"); // $ExpectType string | undefined _.last(list); // $ExpectType AbcObject | undefined + _.last([1, 2, 3]); // $ExpectType number + _.last([1, 2, 3] as number[]); // $ExpectType number | undefined + _.last([]); // $ExpectType undefined + _.last([] as []); // $ExpectType undefined + _.last([1, 2, 3] as const); // $ExpectType 3 + _.last([1, 2, 3] as [number, number, number]); // $ExpectType number + _.last([1, 2, 3] as [...number[]]); // $ExpectType number | undefined + _.last([1, 2, 3] as [...number[], number]); // $ExpectType number _("abc").last(); // $ExpectType string | undefined _(list).last(); // $ExpectType AbcObject | undefined @@ -871,6 +887,14 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain fp.last("abc"); // $ExpectType string | undefined fp.last(list); // $ExpectType AbcObject | undefined + fp.last([1, 2, 3]); // $ExpectType number + fp.last([1, 2, 3] as number[]); // $ExpectType number | undefined + fp.last([]); // $ExpectType undefined + fp.last([] as []); // $ExpectType undefined + fp.last([1, 2, 3] as const); // $ExpectType 3 + fp.last([1, 2, 3] as [number, number, number]); // $ExpectType number + fp.last([1, 2, 3] as [...number[]]); // $ExpectType number | undefined + fp.last([1, 2, 3] as [...number[], number]); // $ExpectType number } // _.nth @@ -4965,14 +4989,24 @@ fp.now(); // $ExpectType number const list: ArrayLike = anything; _.max(list); // $ExpectType string | undefined - _(list).max(); // $ExpectType string | undefined + _(list).max(); // $ExpectType string | undefined _.chain(list).max(); // $ExpectType StringChain fp.max(list); // $ExpectType string | undefined _.min(list); // $ExpectType string | undefined - _(list).min(); // $ExpectType string | undefined + _(list).min(); // $ExpectType string | undefined _.chain(list).min(); // $ExpectType StringChain fp.min(list); // $ExpectType string | undefined + + _.max([1, 2]); // $ExpectType number + _([1, 2]).max(); // $ExpectType number | undefined + _.chain([1, 2]).max(); // $ExpectType PrimitiveChain + fp.max([1, 2]); // $ExpectType number + + _.min([1, 2]); // $ExpectType number + _([1, 2]).min(); // $ExpectType number | undefined + _.chain([1, 2]).min(); // $ExpectType PrimitiveChain + fp.min([1, 2]); // $ExpectType number } // _.maxBy diff --git a/types/node-telegram-bot-api/index.d.ts b/types/node-telegram-bot-api/index.d.ts index bf84818ce3e717..de590c4bcf730b 100644 --- a/types/node-telegram-bot-api/index.d.ts +++ b/types/node-telegram-bot-api/index.d.ts @@ -1525,6 +1525,19 @@ declare namespace TelegramBot { | BotCommandScopeChat | BotCommandScopeChatAdministrators | BotCommandScopeChatMember; + + interface BotName { + name: string; + } + + interface BotDescription { + description: string; + } + + interface BotShortDescription { + short_description: string; + } + interface WebAppInfo { url: string; } @@ -2177,16 +2190,37 @@ declare class TelegramBot extends TelegramBotEventEmitter; - getMyCommands(scope?: TelegramBot.BotCommandScope, language_code?: string): Promise; + getMyCommands( + form?: { scope?: TelegramBot.BotCommandScope; language_code?: string }, + ): Promise; setMyCommands( commands: TelegramBot.BotCommand[], - options?: { + form?: { language_code?: string; scope?: TelegramBot.BotCommandScope; }, ): Promise; + deleteMyCommands( + form?: { + language_code?: string; + scope?: TelegramBot.BotCommandScope; + }, + ): Promise; + + setMyName(form?: { name?: string; language_code?: string }): Promise; + + getMyName(form?: { language_code?: string }): Promise; + + setMyDescription(form?: { description?: string; language_code?: string }): Promise; + + getMyDescription(form?: { language_code?: string }): Promise; + + setMyShortDescription(form?: { short_description?: string; language_code?: string }): Promise; + + getMyShortDescription(form?: { language_code?: string }): Promise; + setChatMenuButton(form: { chat_id?: number; menu_button?: TelegramBot.MenuButton }): Promise; getChatMenuButton(form: { chat_id?: number }): Promise; diff --git a/types/node-telegram-bot-api/node-telegram-bot-api-tests.ts b/types/node-telegram-bot-api/node-telegram-bot-api-tests.ts index 7c7dbc1e83bac9..8eda3a95076bd7 100644 --- a/types/node-telegram-bot-api/node-telegram-bot-api-tests.ts +++ b/types/node-telegram-bot-api/node-telegram-bot-api-tests.ts @@ -478,6 +478,24 @@ MyTelegramBot.setMyCommands([{ command: "command", description: "description" }] // @ts-expect-error scope: { type: "default", chat_id: 1234 }, }); +MyTelegramBot.setMyName({ name: "My Bot" }); +MyTelegramBot.setMyName({ name: "My Bot", language_code: "ru" }); +MyTelegramBot.setMyName({}); +MyTelegramBot.getMyName(); +MyTelegramBot.getMyName({ language_code: "en" }); +MyTelegramBot.getMyName({ language_code: "ru" }); +MyTelegramBot.setMyDescription({ description: "My Bot Description" }); +MyTelegramBot.setMyDescription({ description: "My Bot Description", language_code: "ru" }); +MyTelegramBot.setMyDescription({}); +MyTelegramBot.getMyDescription(); +MyTelegramBot.getMyDescription({ language_code: "en" }); +MyTelegramBot.getMyDescription({ language_code: "ru" }); +MyTelegramBot.setMyShortDescription({ short_description: "Short Description" }); +MyTelegramBot.setMyShortDescription({ short_description: "Short Description", language_code: "ru" }); +MyTelegramBot.setMyShortDescription({}); +MyTelegramBot.getMyShortDescription(); +MyTelegramBot.getMyShortDescription({ language_code: "en" }); +MyTelegramBot.getMyShortDescription({ language_code: "ru" }); MyTelegramBot.banChatSenderChat(1234, 1234); MyTelegramBot.unbanChatSenderChat(1234, 1234); MyTelegramBot.setChatMenuButton({