Comments (6)
Ну как костыль для этого репозитория, может кому пригодится
let Calendar: any
async function getCalendar() {
if (!Calendar) {
const calendar = await (eval('import("telegram-inline-calendar")') as Promise<typeof import('telegram-inline-calendar')>);
Calendar = calendar.Calendar
}
return Calendar
}
const lCalnedar = await getCalendar()
calendar = new lCalnedar(false, {
date_format: 'DD-MM-YYYY',
});
from telegram-inline-calendar.
Полноценную версию под TS я ещё не выпускал, пока нет времени.
Если есть желание и время, вы можете сами создать форк и сделать полноценную поддержку TS(планирую им отдать версии серии 3.х.х.), став котрибьютером проекта.
Также скину вам ссылку на проект одного из пользователей, который переделал библиотеку под TS. - https://github.com/youjob13/tg-bot
from telegram-inline-calendar.
Добрый день, @almaziphone,
Как подключаете библиотеку?
Какую версию используете?
В какой момент отображается ошибка(запуске через npm/ VSCode просто подсвечивает)?
from telegram-inline-calendar.
ESM
Использую grammY
локально скачал библиотеку
Could not find a declaration file for module './calendar/Calendar.js'. 'e:/ProgJava/grammy_bot/src/bot/utilites/calendar/Calendar.js' implicitly has an 'any' type.ts(7016)
Если установить через npm:
Could not find a declaration file for module 'telegram-inline-calendar'. 'e:/ProgJava/grammy_bot/node_modules/telegram-inline-calendar/index.js' implicitly has an 'any' type.
Try npm i --save-dev @types/telegram-inline-calendar
if it exists or add a new declaration (.d.ts) file containing declare module 'telegram-inline-calendar';
ts(7016)
from telegram-inline-calendar.
Ответы на остальные два вопроса?
from telegram-inline-calendar.
Создал файл объявления типов. Клавиатуру запустил. Можете поправить?
// Calendar.d.ts
// Путь к файлу: #root/src/bot/utilites/calendar/src/calendar.d.ts
import { Context, InlineKeyboardMarkup } from "grammy";
export class Calendar {
chats: any;
constructor(bot?: any, options?: CalendarOptions);
NodeTelegramBotApi: BotApi;
Telegraf: BotApi;
Telebot: BotApi;
Grammy: BotApi;
DatetimeFunc: DatetimeFunc;
DateFunc: DateFunc;
addCustomStartMsg(): void;
libraryInitialization(): void;
dateFuncInitialization(): void;
datetimeFuncInitialization(): void;
weekDaysButtons(day: number): number;
startWeekDay(day: number): number;
twoDigits(num: number): string;
colRowNavigation(date: Date, cd: number): number;
howMuchDays(year: number, month: number): number;
createTimeSelector(date?: string, from_calendar?: boolean): InlineKeyboardMarkup;
createNavigationKeyboard(date: Date): InlineKeyboardMarkup;
startNavCalendar(ctx: any): void;
clickButtonCalendar(ctx: any): any;
}
interface CalendarOptions {
language?: string;
date_format?: string;
bot_api?: string;
close_calendar?: boolean;
start_week_day?: number;
time_selector_mod?: boolean;
time_range?: string;
time_step?: string;
start_date?: string | boolean;
stop_date?: string | boolean;
custom_start_msg?: string | boolean;
lock_datetime?: boolean;
lock_date?: boolean;
}
interface BotApi {
editMessageReplyMarkupCalendar(date: Date, queryOrCtx: any): void;
editMessageReplyMarkupTime(date: Date, queryOrCtx: any, from_calendar: boolean): void;
sendMessageCalendar(menu: any, msgOrCtx: any): void;
sendMessageTime(menu: any, msgOrCtx: any): void;
deleteMessage(queryOrCtx: any): void;
replyMarkupObject(cnk: any): any;
clickButtonCalendar(queryOrCtx: any): any;
startNavCalendar(msgOrCtx: any): void;
startTimeSelector(msgOrCtx: any): void;
}
interface DatetimeFunc {
withoutLockDatetime(stop: string, datetime: string, type: string): boolean;
withLockDatetime(stop: string, datetime: string, type: string): boolean;
}
interface DateFunc {
withoutLockDate(date: Date, d: number): boolean;
withLockDate(date: Date, d: number): boolean;
}
from telegram-inline-calendar.
Related Issues (11)
- 'Bad Request' Error HOT 4
- Could not find a declaration file for module HOT 18
- Is it possible to not display a specific date and time? HOT 9
- I can't switch months 😞 HOT 6
- Changing days order HOT 1
- Change message HOT 13
- Error when trying to move through months HOT 13
- TypeError: NavCalendar is not a constructor HOT 3
- Could not find a declaration file for module 'telegram-inline-calendar'. HOT 16
- Get the wrong time when calling clickButtonCalendar HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegram-inline-calendar.