telegram-botbuilder 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ import TelegramBot from 'node-telegram-bot-api';
2
+ import { Schema, Action } from './bot-struct';
3
+ import EventEmitter from 'events';
4
+ export interface ActionCallback {
5
+ chatid: number;
6
+ }
7
+ export declare class EasyBot {
8
+ private _bot;
9
+ private _schema;
10
+ ActionSystem: EventEmitter;
11
+ private _userdialogs;
12
+ constructor(schema: Schema, token: string, options?: TelegramBot.ConstructorOptions);
13
+ private _getDialog;
14
+ private _getButton;
15
+ private _activateButton;
16
+ ChangeDialog(chat: number, id: string): Promise<void>;
17
+ AttachDataWait(chat: number, descriptor: string): void;
18
+ Message(chat: number, content: string): Promise<TelegramBot.Message>;
19
+ }
20
+ export declare function ChangeDialog(id: string): Action;
21
+ export declare function CallbackAction(descriptor: string): Action;
22
+ export declare function WaitForData(descriptor: string): Action;
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.EasyBot = void 0;
43
+ exports.ChangeDialog = ChangeDialog;
44
+ exports.CallbackAction = CallbackAction;
45
+ exports.WaitForData = WaitForData;
46
+ var node_telegram_bot_api_1 = __importDefault(require("node-telegram-bot-api"));
47
+ var events_1 = __importDefault(require("events"));
48
+ var crypto_1 = require("crypto");
49
+ var fs_1 = require("fs");
50
+ var EasyBot = /** @class */ (function () {
51
+ function EasyBot(schema, token, options) {
52
+ var _this = this;
53
+ this._bot = new node_telegram_bot_api_1.default(token, options);
54
+ this._schema = schema;
55
+ this._schema.buttons = [];
56
+ for (var x = 0; x < this._schema.content.length; x++) {
57
+ for (var y = 0; y < this._schema.content[x].buttons.length; y++) {
58
+ for (var b = 0; b < this._schema.content[x].buttons[y].length; b++) {
59
+ this._schema.content[x].buttons[y][b]._callback = (0, crypto_1.randomInt)(281474976710655).toFixed(0);
60
+ this._schema.buttons.push(this._schema.content[x].buttons[y][b]);
61
+ }
62
+ }
63
+ }
64
+ this.ActionSystem = new events_1.default();
65
+ this._userdialogs = {};
66
+ this._bot.onText(/\/start/, function (msg) {
67
+ if (!_this._userdialogs[msg.chat.id])
68
+ _this._userdialogs[msg.chat.id] = { dialog: _this._schema.start, lastid: -1, waiter: { statewait: false, descriptor: '' } };
69
+ _this._bot.deleteMessage(msg.chat.id, msg.message_id).catch(function () { return undefined; });
70
+ _this.ChangeDialog(msg.chat.id, _this._schema.start);
71
+ });
72
+ this._bot.on('callback_query', function (query) {
73
+ if (!_this._userdialogs[query.message.chat.id])
74
+ _this._userdialogs[query.message.chat.id] = { dialog: _this._schema.start, lastid: -1, waiter: { statewait: false, descriptor: '' } };
75
+ _this._activateButton(query.message.chat.id, query.data);
76
+ });
77
+ this._bot.onText(/.+/g, function (msg) {
78
+ var chat = msg.chat.id;
79
+ if (_this._userdialogs[chat].waiter.statewait) {
80
+ _this._userdialogs[chat].waiter.statewait = false;
81
+ _this._bot.deleteMessage(chat, msg.message_id).catch(function () { return undefined; });
82
+ _this.ActionSystem.emit(_this._userdialogs[chat].waiter.descriptor, chat, msg.text);
83
+ }
84
+ });
85
+ this._bot.on('document', function (msg) {
86
+ if (!msg.document)
87
+ return;
88
+ var chat = msg.chat.id;
89
+ if (!_this._userdialogs[chat].waiter.statewait)
90
+ return;
91
+ _this._bot.downloadFile(msg.document.file_id, './').then(function (x) {
92
+ _this._userdialogs[chat].waiter.statewait = false;
93
+ _this._bot.deleteMessage(chat, msg.message_id).catch(function () { return undefined; });
94
+ var content = (0, fs_1.readFileSync)(x, 'utf8');
95
+ (0, fs_1.rmSync)(x);
96
+ _this.ActionSystem.emit(_this._userdialogs[chat].waiter.descriptor, chat, content);
97
+ });
98
+ });
99
+ }
100
+ EasyBot.prototype._getDialog = function (id) {
101
+ return this._schema.content.find(function (x) { return x.id === id; });
102
+ };
103
+ EasyBot.prototype._getButton = function (callback) {
104
+ return this._schema.buttons.find(function (x) { return x._callback === callback; });
105
+ };
106
+ EasyBot.prototype._activateButton = function (chat, btn) {
107
+ return __awaiter(this, void 0, void 0, function () {
108
+ var _btn, _i, _a, act;
109
+ return __generator(this, function (_b) {
110
+ switch (_b.label) {
111
+ case 0:
112
+ if (typeof btn === 'string')
113
+ _btn = this._getButton(btn);
114
+ else
115
+ _btn = btn;
116
+ if (!Array.isArray(_btn === null || _btn === void 0 ? void 0 : _btn.action)) return [3 /*break*/, 5];
117
+ _i = 0, _a = _btn === null || _btn === void 0 ? void 0 : _btn.action;
118
+ _b.label = 1;
119
+ case 1:
120
+ if (!(_i < _a.length)) return [3 /*break*/, 4];
121
+ act = _a[_i];
122
+ return [4 /*yield*/, act(chat, this)];
123
+ case 2:
124
+ _b.sent();
125
+ _b.label = 3;
126
+ case 3:
127
+ _i++;
128
+ return [3 /*break*/, 1];
129
+ case 4: return [3 /*break*/, 7];
130
+ case 5:
131
+ if (!(_btn === null || _btn === void 0 ? void 0 : _btn.action)) return [3 /*break*/, 7];
132
+ return [4 /*yield*/, (_btn === null || _btn === void 0 ? void 0 : _btn.action)(chat, this)];
133
+ case 6:
134
+ _b.sent();
135
+ _b.label = 7;
136
+ case 7: return [2 /*return*/];
137
+ }
138
+ });
139
+ });
140
+ };
141
+ EasyBot.prototype.ChangeDialog = function (chat, id) {
142
+ return __awaiter(this, void 0, void 0, function () {
143
+ var dialog, markup, b, _i, _a, btn, text_1, _b, text, _c, _d, msg;
144
+ return __generator(this, function (_e) {
145
+ switch (_e.label) {
146
+ case 0:
147
+ this._userdialogs[chat].dialog = id;
148
+ if (this._userdialogs[chat].waiter.statewait) {
149
+ this._userdialogs[chat].waiter.statewait = false;
150
+ this.ActionSystem.emit("cancel_".concat(this._userdialogs[chat].waiter.descriptor), chat);
151
+ }
152
+ dialog = this._getDialog(id);
153
+ markup = undefined;
154
+ if (!((dialog === null || dialog === void 0 ? void 0 : dialog.buttons.length) > 0)) return [3 /*break*/, 8];
155
+ markup = [];
156
+ b = 0;
157
+ _e.label = 1;
158
+ case 1:
159
+ if (!(b < (dialog === null || dialog === void 0 ? void 0 : dialog.buttons.length))) return [3 /*break*/, 8];
160
+ markup[b] = [];
161
+ _i = 0, _a = dialog === null || dialog === void 0 ? void 0 : dialog.buttons[b];
162
+ _e.label = 2;
163
+ case 2:
164
+ if (!(_i < _a.length)) return [3 /*break*/, 7];
165
+ btn = _a[_i];
166
+ if (!(typeof btn.text === 'function')) return [3 /*break*/, 4];
167
+ return [4 /*yield*/, btn.text(chat)];
168
+ case 3:
169
+ _b = _e.sent();
170
+ return [3 /*break*/, 5];
171
+ case 4:
172
+ _b = btn.text;
173
+ _e.label = 5;
174
+ case 5:
175
+ text_1 = _b;
176
+ markup[b].push({ text: text_1, callback_data: btn._callback });
177
+ _e.label = 6;
178
+ case 6:
179
+ _i++;
180
+ return [3 /*break*/, 2];
181
+ case 7:
182
+ b++;
183
+ return [3 /*break*/, 1];
184
+ case 8:
185
+ if (!(typeof (dialog === null || dialog === void 0 ? void 0 : dialog.text) === 'function')) return [3 /*break*/, 10];
186
+ return [4 /*yield*/, (dialog === null || dialog === void 0 ? void 0 : dialog.text(chat))];
187
+ case 9:
188
+ _c = _e.sent();
189
+ return [3 /*break*/, 11];
190
+ case 10:
191
+ _c = dialog === null || dialog === void 0 ? void 0 : dialog.text;
192
+ _e.label = 11;
193
+ case 11:
194
+ text = _c;
195
+ _e.label = 12;
196
+ case 12:
197
+ _e.trys.push([12, 14, , 16]);
198
+ return [4 /*yield*/, this._bot.editMessageText(text || "404", { chat_id: chat, message_id: this._userdialogs[chat].lastid, reply_markup: { inline_keyboard: markup || [] } })];
199
+ case 13:
200
+ _e.sent();
201
+ return [3 /*break*/, 16];
202
+ case 14:
203
+ _d = _e.sent();
204
+ return [4 /*yield*/, this._bot.sendMessage(chat, text || "404", { reply_markup: { inline_keyboard: markup || [] } })];
205
+ case 15:
206
+ msg = _e.sent();
207
+ this._userdialogs[chat].lastid = msg.message_id;
208
+ return [3 /*break*/, 16];
209
+ case 16: return [2 /*return*/];
210
+ }
211
+ });
212
+ });
213
+ };
214
+ EasyBot.prototype.AttachDataWait = function (chat, descriptor) {
215
+ this._userdialogs[chat].waiter.descriptor = descriptor;
216
+ this._userdialogs[chat].waiter.statewait = true;
217
+ };
218
+ EasyBot.prototype.Message = function (chat, content) {
219
+ return this._bot.sendMessage(chat, content);
220
+ };
221
+ return EasyBot;
222
+ }());
223
+ exports.EasyBot = EasyBot;
224
+ function ChangeDialog(id) {
225
+ var _this = this;
226
+ return function (chat, _bot) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
227
+ switch (_a.label) {
228
+ case 0: return [4 /*yield*/, _bot.ChangeDialog(chat, id)];
229
+ case 1:
230
+ _a.sent();
231
+ return [2 /*return*/];
232
+ }
233
+ }); }); };
234
+ }
235
+ function CallbackAction(descriptor) {
236
+ var _this = this;
237
+ return function (chat, _bot) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
238
+ _bot.ActionSystem.emit(descriptor, { chatid: chat });
239
+ return [2 /*return*/];
240
+ }); }); };
241
+ }
242
+ function WaitForData(descriptor) {
243
+ return function (chat, _bot) {
244
+ _bot.AttachDataWait(chat, descriptor);
245
+ return new Promise(function (r) {
246
+ _bot.ActionSystem.once(descriptor, r);
247
+ _bot.ActionSystem.once("cancel_".concat(descriptor), r);
248
+ });
249
+ };
250
+ }
@@ -0,0 +1,25 @@
1
+ import { EasyBot } from "./bot-service";
2
+ export type Action = (chat: number, _bot: EasyBot) => Promise<void>;
3
+ export interface Dialog {
4
+ id: string;
5
+ text: string | ((chat: number) => Promise<string>);
6
+ buttons: Button[][];
7
+ }
8
+ export interface BotDialog extends Dialog {
9
+ buttons: BotButton[][];
10
+ }
11
+ export interface Button {
12
+ text: string | ((chat: number) => Promise<string>);
13
+ action: Action[] | Action;
14
+ }
15
+ export interface BotButton extends Button {
16
+ _callback: string;
17
+ }
18
+ export interface Schema {
19
+ start: string;
20
+ content: Dialog[];
21
+ }
22
+ export interface BotSchema extends Schema {
23
+ content: BotDialog[];
24
+ buttons: BotButton[];
25
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/index.d.ts ADDED
File without changes
package/lib/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "telegram-botbuilder",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "keywords": [],
9
+ "author": "",
10
+ "license": "ISC",
11
+ "description": "",
12
+ "dependencies": {
13
+ "node-telegram-bot-api": "^0.66.0",
14
+ "ts-node": "^10.9.2",
15
+ "typescript": "^5.5.3"
16
+ },
17
+ "devDependencies": {
18
+ "@types/node-telegram-bot-api": "^0.64.7"
19
+ }
20
+ }
@@ -0,0 +1,144 @@
1
+ import TelegramBot, { InlineKeyboardButton } from 'node-telegram-bot-api';
2
+ import { Schema, Action, BotSchema, Button, BotButton } from './bot-struct';
3
+ import EventEmitter from 'events';
4
+ import { randomInt } from 'crypto';
5
+ import { readFileSync, rmSync } from 'fs';
6
+
7
+
8
+ interface UserDialog {
9
+ [key: number]: {dialog: string, lastid: number, waiter: { statewait: boolean, descriptor: string }};
10
+ }
11
+
12
+ export interface ActionCallback {
13
+ chatid: number;
14
+ }
15
+
16
+ export class EasyBot {
17
+ private _bot: TelegramBot;
18
+ private _schema: BotSchema;
19
+ public ActionSystem: EventEmitter;
20
+ private _userdialogs: UserDialog;
21
+
22
+ constructor (schema: Schema, token: string, options?: TelegramBot.ConstructorOptions) {
23
+ this._bot = new TelegramBot(token, options);
24
+ this._schema = schema as BotSchema;
25
+ this._schema.buttons = [];
26
+
27
+ for (let x = 0; x < this._schema.content.length; x++) {
28
+ for (let y = 0; y < this._schema.content[x].buttons.length; y++) {
29
+ for (let b = 0; b < this._schema.content[x].buttons[y].length; b++) {
30
+ this._schema.content[x].buttons[y][b]._callback = randomInt(281474976710655).toFixed(0);
31
+ this._schema.buttons.push(this._schema.content[x].buttons[y][b]);
32
+ }
33
+ }
34
+ }
35
+
36
+ this.ActionSystem = new EventEmitter();
37
+ this._userdialogs = {};
38
+
39
+ this._bot.onText(/\/start/, (msg) => {
40
+ if (!this._userdialogs[msg.chat.id]) this._userdialogs[msg.chat.id] = {dialog: this._schema.start, lastid: -1, waiter: { statewait: false, descriptor: '' }}
41
+ this._bot.deleteMessage(msg.chat.id, msg.message_id).catch(() => undefined);
42
+ this.ChangeDialog(msg.chat.id, this._schema.start);
43
+ });
44
+
45
+ this._bot.on('callback_query', (query) => {
46
+ if (!this._userdialogs[query.message!.chat.id]) this._userdialogs[query.message!.chat.id] = {dialog: this._schema.start, lastid: -1, waiter: { statewait: false, descriptor: '' }}
47
+ this._activateButton(query.message!.chat.id, query.data!)
48
+ });
49
+
50
+ this._bot.onText(/.+/g, (msg) => {
51
+ let chat = msg.chat.id;
52
+ if (this._userdialogs[chat].waiter.statewait) {
53
+ this._userdialogs[chat].waiter.statewait = false;
54
+ this._bot.deleteMessage(chat, msg.message_id).catch(() => undefined);
55
+ this.ActionSystem.emit(this._userdialogs[chat].waiter.descriptor, chat, msg.text);
56
+ }
57
+ })
58
+
59
+ this._bot.on('document', (msg) => {
60
+ if (!msg.document) return;
61
+ let chat = msg.chat.id;
62
+ if (!this._userdialogs[chat].waiter.statewait) return;
63
+ this._bot.downloadFile(msg.document.file_id, './').then((x) => {
64
+ this._userdialogs[chat].waiter.statewait = false;
65
+ this._bot.deleteMessage(chat, msg.message_id).catch(() => undefined);
66
+ let content = readFileSync(x, 'utf8');
67
+ rmSync(x);
68
+ this.ActionSystem.emit(this._userdialogs[chat].waiter.descriptor, chat, content);
69
+ })
70
+ })
71
+ }
72
+
73
+ private _getDialog(id: string) {
74
+ return this._schema.content.find(x => x.id === id);
75
+ }
76
+ private _getButton(callback: string) {
77
+ return this._schema.buttons.find(x => x._callback === callback);
78
+ }
79
+ private async _activateButton(chat: number, btn: string | BotButton) {
80
+ let _btn;
81
+ if (typeof btn === 'string') _btn = this._getButton(btn);
82
+ else _btn = btn;
83
+
84
+ if (Array.isArray(_btn?.action)) {
85
+ for (let act of (_btn?.action as Action[])) {
86
+ await act(chat, this);
87
+ }
88
+ } else if (_btn?.action as Action) {
89
+ await (_btn?.action as Action)(chat, this);
90
+ }
91
+ }
92
+
93
+ public async ChangeDialog(chat: number, id: string) {
94
+ this._userdialogs[chat].dialog = id;
95
+ if (this._userdialogs[chat].waiter.statewait) {
96
+ this._userdialogs[chat].waiter.statewait = false;
97
+ this.ActionSystem.emit(`cancel_${this._userdialogs[chat].waiter.descriptor}`, chat)
98
+ }
99
+
100
+ let dialog = this._getDialog(id);
101
+ let markup: InlineKeyboardButton[][] | undefined = undefined;
102
+ if (dialog?.buttons.length! > 0) {
103
+ markup = [];
104
+ for (let b = 0; b < dialog?.buttons.length!; b++) {
105
+ markup[b] = [];
106
+ for (let btn of dialog?.buttons[b]!) {
107
+ let text = typeof btn.text === 'function' ? await btn.text(chat) : btn.text;
108
+ markup[b].push({ text, callback_data: btn._callback});
109
+ }
110
+ }
111
+ }
112
+
113
+ let text = typeof dialog?.text === 'function' ? await dialog?.text(chat) : dialog?.text;
114
+ try {
115
+ await this._bot.editMessageText(text || "404", { chat_id: chat, message_id: this._userdialogs[chat].lastid, reply_markup: { inline_keyboard: markup || [] }})
116
+ } catch {
117
+ let msg = await this._bot.sendMessage(chat, text || "404", { reply_markup: { inline_keyboard: markup || [] }});
118
+ this._userdialogs[chat].lastid = msg.message_id;
119
+ }
120
+ }
121
+ public AttachDataWait(chat: number, descriptor: string) {
122
+ this._userdialogs[chat].waiter.descriptor = descriptor;
123
+ this._userdialogs[chat].waiter.statewait = true;
124
+ }
125
+ public Message(chat: number, content: string) {
126
+ return this._bot.sendMessage(chat, content);
127
+ }
128
+ }
129
+
130
+ export function ChangeDialog(id: string): Action {
131
+ return async (chat: number, _bot: EasyBot) => { await _bot.ChangeDialog(chat, id); };
132
+ }
133
+ export function CallbackAction(descriptor: string): Action {
134
+ return async (chat: number, _bot: EasyBot) => { _bot.ActionSystem.emit(descriptor, {chatid: chat}); };
135
+ }
136
+ export function WaitForData(descriptor: string): Action {
137
+ return (chat: number, _bot: EasyBot) => {
138
+ _bot.AttachDataWait(chat, descriptor);
139
+ return new Promise(r => {
140
+ _bot.ActionSystem.once(descriptor, r);
141
+ _bot.ActionSystem.once(`cancel_${descriptor}`, r);
142
+ });
143
+ };
144
+ }
@@ -0,0 +1,31 @@
1
+ import { EasyBot } from "./bot-service";
2
+
3
+
4
+ export type Action = (chat: number, _bot: EasyBot) => Promise<void>;
5
+
6
+ export interface Dialog {
7
+ id: string;
8
+ text: string | ((chat: number) => Promise<string>);
9
+ buttons: Button[][]
10
+ }
11
+ export interface BotDialog extends Dialog {
12
+ buttons: BotButton[][]
13
+ }
14
+
15
+ export interface Button {
16
+ text: string | ((chat: number) => Promise<string>);
17
+ action: Action[] | Action;
18
+ }
19
+ export interface BotButton extends Button {
20
+ _callback: string;
21
+ }
22
+
23
+ export interface Schema {
24
+ start: string;
25
+ content: Dialog[];
26
+ }
27
+
28
+ export interface BotSchema extends Schema {
29
+ content: BotDialog[];
30
+ buttons: BotButton[];
31
+ }
package/src/index.ts ADDED
File without changes
package/tsconfig.json ADDED
@@ -0,0 +1,108 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "ES5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
17
+ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
+
27
+ /* Modules */
28
+ "module": "commonjs", /* Specify what module code is generated. */
29
+ "rootDir": "./src/", /* Specify the root folder within your source files. */
30
+ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
31
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
+ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
39
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
40
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
41
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
42
+ // "resolveJsonModule": true, /* Enable importing .json files. */
43
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
44
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
45
+
46
+ /* JavaScript Support */
47
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
48
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
49
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
50
+
51
+ /* Emit */
52
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
53
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
54
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
55
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
56
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
58
+ "outDir": "./lib/", /* Specify an output folder for all emitted files. */
59
+ // "removeComments": true, /* Disable emitting comments. */
60
+ // "noEmit": true, /* Disable emitting files from a compilation. */
61
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
62
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
63
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
64
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
65
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
66
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
67
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
68
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
69
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
70
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
71
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
72
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
73
+
74
+ /* Interop Constraints */
75
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
76
+ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
77
+ // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
78
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
79
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
80
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
81
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
82
+
83
+ /* Type Checking */
84
+ "strict": true, /* Enable all strict type-checking options. */
85
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
86
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
87
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
88
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
89
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
90
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
91
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
92
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
93
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
94
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
95
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
96
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
97
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
98
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
99
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
100
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
101
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
102
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
103
+
104
+ /* Completeness */
105
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
106
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
107
+ }
108
+ }