Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions types/lodash/common/array.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ declare module "../index" {
* @param array The array to query.
* @return Returns the last element of array.
*/
last<T>(array: readonly [...unknown[], T]): T;
last<T>(array: List<T> | null | undefined): T | undefined;
}
interface Collection<T> {
Expand Down
2 changes: 2 additions & 0 deletions types/lodash/common/math.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ declare module "../index" {
* @param array The array to iterate over.
* @returns Returns the maximum value.
*/
max<T>(collection: readonly [T, ...T[]]): T;
max<T>(collection: List<T> | null | undefined): T | undefined;
}
interface Collection<T> {
Expand Down Expand Up @@ -216,6 +217,7 @@ declare module "../index" {
* @param array The array to iterate over.
* @returns Returns the minimum value.
*/
min<T>(collection: readonly [T, ...T[]]): T;
min<T>(collection: List<T> | null | undefined): T | undefined;
}
interface Collection<T> {
Expand Down
20 changes: 16 additions & 4 deletions types/lodash/fp.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,10 @@ declare namespace _ {
}
type LodashFindLastKey1x1<T> = (object: object | null | undefined) => string | undefined;
type LodashFindLastKey1x2<T> = (predicate: lodash.ValueIteratee<T[keyof T]>) => string | undefined;
type LodashHead = <T>(array: lodash.List<T> | null | undefined) => T | undefined;
interface LodashHead {
<T>(array: readonly [T, ...unknown[]]): T;
<T>(array: lodash.List<T> | null | undefined): T | undefined;
}
interface LodashFlatMap {
<T, TResult>(iteratee: (value: T) => lodash.Many<TResult>): LodashFlatMap1x1<T, TResult>;
<T>(iteratee: lodash.__, collection: lodash.List<T> | null | undefined): LodashFlatMap1x2<T>;
Expand Down Expand Up @@ -2030,7 +2033,10 @@ declare namespace _ {
type LodashKebabCase = (string: string) => string;
type LodashKeys = (object: any) => string[];
type LodashKeysIn = (object: any) => string[];
type LodashLast = <T>(array: lodash.List<T> | null | undefined) => T | undefined;
interface LodashLast {
<T>(array: readonly [...unknown[], T]): T;
<T>(array: lodash.List<T> | null | undefined): T | undefined;
}
interface LodashLastIndexOf {
<T>(value: T): LodashLastIndexOf1x1<T>;
<T>(value: lodash.__, array: lodash.List<T> | null | undefined): LodashLastIndexOf1x2<T>;
Expand Down Expand Up @@ -2167,7 +2173,10 @@ declare namespace _ {
}
type LodashMatchesProperty1x1 = <T>(srcValue: T) => (value: any) => boolean;
type LodashMatchesProperty1x2 = (path: lodash.PropertyPath) => (value: any) => boolean;
type LodashMax = <T>(collection: lodash.List<T> | null | undefined) => T | undefined;
interface LodashMax {
<T>(collection: readonly [T, ...T[]]): T;
<T>(collection: lodash.List<T> | null | undefined): T | undefined;
}
interface LodashMaxBy {
<T>(iteratee: lodash.ValueIteratee<T>): LodashMaxBy1x1<T>;
<T>(iteratee: lodash.__, collection: lodash.List<T> | null | undefined): LodashMaxBy1x2<T>;
Expand Down Expand Up @@ -2234,7 +2243,10 @@ declare namespace _ {
type LodashMergeWith1x6<TObject, TSource> = (customizer: lodash.MergeWithCustomizer) => TObject & TSource;
type LodashMethod = (path: lodash.PropertyPath) => (object: any) => any;
type LodashMethodOf = (object: object) => (path: lodash.PropertyPath) => any;
type LodashMin = <T>(collection: lodash.List<T> | null | undefined) => T | undefined;
interface LodashMin {
<T>(collection: readonly [T, ...T[]]): T;
<T>(collection: lodash.List<T> | null | undefined): T | undefined;
}
interface LodashMinBy {
<T>(iteratee: lodash.ValueIteratee<T>): LodashMinBy1x1<T>;
<T>(iteratee: lodash.__, collection: lodash.List<T> | null | undefined): LodashMinBy1x2<T>;
Expand Down
38 changes: 36 additions & 2 deletions types/lodash/lodash-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,14 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain<number>

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
Expand Down Expand Up @@ -862,6 +870,14 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain<number>
{
_.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
Expand All @@ -871,6 +887,14 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain<number>

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
Expand Down Expand Up @@ -4965,14 +4989,24 @@ fp.now(); // $ExpectType number
const list: ArrayLike<string> = anything;

_.max(list); // $ExpectType string | undefined
_(list).max(); // $ExpectType string | undefined
_(list).max(); // $ExpectType string | undefined
_.chain(list).max(); // $ExpectType StringChain<string>
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<string>
fp.min(list); // $ExpectType string | undefined

_.max([1, 2]); // $ExpectType number
_([1, 2]).max(); // $ExpectType number | undefined
_.chain([1, 2]).max(); // $ExpectType PrimitiveChain<number>
fp.max([1, 2]); // $ExpectType number

_.min([1, 2]); // $ExpectType number
_([1, 2]).min(); // $ExpectType number | undefined
_.chain([1, 2]).min(); // $ExpectType PrimitiveChain<number>
fp.min([1, 2]); // $ExpectType number
}

// _.maxBy
Expand Down
38 changes: 36 additions & 2 deletions types/node-telegram-bot-api/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -2177,16 +2190,37 @@ declare class TelegramBot extends TelegramBotEventEmitter<TelegramBot.TelegramEv

setChatAdministratorCustomTitle(chatId: TelegramBot.ChatId, userId: number, customTitle: string): Promise<boolean>;

getMyCommands(scope?: TelegramBot.BotCommandScope, language_code?: string): Promise<TelegramBot.BotCommand[]>;
getMyCommands(
form?: { scope?: TelegramBot.BotCommandScope; language_code?: string },
): Promise<TelegramBot.BotCommand[]>;

setMyCommands(
commands: TelegramBot.BotCommand[],
options?: {
form?: {
language_code?: string;
scope?: TelegramBot.BotCommandScope;
},
): Promise<boolean>;

deleteMyCommands(
form?: {
language_code?: string;
scope?: TelegramBot.BotCommandScope;
},
): Promise<boolean>;

setMyName(form?: { name?: string; language_code?: string }): Promise<boolean>;

getMyName(form?: { language_code?: string }): Promise<TelegramBot.BotName>;

setMyDescription(form?: { description?: string; language_code?: string }): Promise<boolean>;

getMyDescription(form?: { language_code?: string }): Promise<TelegramBot.BotDescription>;

setMyShortDescription(form?: { short_description?: string; language_code?: string }): Promise<boolean>;

getMyShortDescription(form?: { language_code?: string }): Promise<TelegramBot.BotShortDescription>;

setChatMenuButton(form: { chat_id?: number; menu_button?: TelegramBot.MenuButton }): Promise<boolean>;

getChatMenuButton(form: { chat_id?: number }): Promise<TelegramBot.MenuButton>;
Expand Down
18 changes: 18 additions & 0 deletions types/node-telegram-bot-api/node-telegram-bot-api-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down