diff --git a/.eslintrc b/.eslintrc index 871ae6f..b9c229b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,6 +9,9 @@ "prettier" ], "rules": { - "prettier/prettier": 2 // Means error + "@typescript-eslint/no-non-null-assertion": 0, + "@typescript-eslint/no-explicit-any": 0, + "@typescript-eslint/explicit-module-boundary-types": 0, + "prettier/prettier": 2 } } diff --git a/package-lock.json b/package-lock.json index 65d8307..fafa03f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "server", - "version": "0.0.1-alpha", + "name": "@pbot-plus/bot", + "version": "1.0.0-beta", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -49,6 +49,21 @@ } } }, + "@discordjs/collection": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz", + "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ==" + }, + "@discordjs/form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, "@eslint/eslintrc": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.1.tgz", @@ -121,6 +136,16 @@ "integrity": "sha512-7EIraBEyRHEe7CH+Fm1XvgqU6uwZN8Q7jppJGcqjROMT29qhAuuOxYB1uEY5UMYQKEmA5D+5tBnhdaPXSsLONA==", "dev": true }, + "@types/node-fetch": { + "version": "2.5.10", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.10.tgz", + "integrity": "sha512-IpkX0AasN44hgEad0gEF/V6EgR5n69VEqPEgnmoM8GsIGro3PowbWs4tR6IhxUTyPLpOn+fiGG6nrQhcmoCuIQ==", + "dev": true, + "requires": { + "@types/node": "*", + "form-data": "^3.0.0" + } + }, "@typescript-eslint/eslint-plugin": { "version": "4.25.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.25.0.tgz", @@ -204,6 +229,14 @@ "eslint-visitor-keys": "^2.0.0" } }, + "abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "requires": { + "event-target-shim": "^5.0.0" + } + }, "acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", @@ -270,6 +303,11 @@ "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", "dev": true }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -367,6 +405,14 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -399,6 +445,11 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, "dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -408,6 +459,29 @@ "path-type": "^4.0.0" } }, + "discord.js": { + "version": "12.5.3", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.3.tgz", + "integrity": "sha512-D3nkOa/pCkNyn6jLZnAiJApw2N9XrIsXUAdThf01i7yrEuqUmDGc7/CexVWwEcgbQR97XQ+mcnqJpmJ/92B4Aw==", + "requires": { + "@discordjs/collection": "^0.1.6", + "@discordjs/form-data": "^3.0.1", + "abort-controller": "^3.0.0", + "node-fetch": "^2.6.1", + "prism-media": "^1.2.9", + "setimmediate": "^1.0.5", + "tweetnacl": "^1.0.3", + "ws": "^7.4.4" + } + }, + "discord.js-light": { + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/discord.js-light/-/discord.js-light-3.5.11.tgz", + "integrity": "sha512-FaOdReT+8CJsHXnjxlG7oK08uqVtIVaEXsbpS7V1O5DK6WSar29KsewkUcDHnCkU89MRhXsgNXhk7cVg0qYkGA==", + "requires": { + "discord.js": "12.5.3" + } + }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -612,6 +686,11 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, + "event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" + }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -693,6 +772,17 @@ "integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==", "dev": true }, + "form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -923,6 +1013,19 @@ "picomatch": "^2.2.3" } }, + "mime-db": { + "version": "1.47.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.47.0.tgz", + "integrity": "sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw==" + }, + "mime-types": { + "version": "2.1.30", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.30.tgz", + "integrity": "sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==", + "requires": { + "mime-db": "1.47.0" + } + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -944,6 +1047,11 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -1021,6 +1129,11 @@ "fast-diff": "^1.1.2" } }, + "prism-media": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.9.tgz", + "integrity": "sha512-UHCYuqHipbTR1ZsXr5eg4JUmHER8Ss4YEb9Azn+9zzJ7/jlTtD1h0lc4g6tNx3eMlB8Mp6bfll0LPMAV4R6r3Q==" + }, "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -1090,6 +1203,11 @@ "lru-cache": "^6.0.0" } }, + "setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" + }, "shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -1253,6 +1371,11 @@ "tslib": "^1.8.1" } }, + "tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" + }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -1310,6 +1433,11 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, + "ws": { + "version": "7.4.6", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", + "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==" + }, "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", diff --git a/package.json b/package.json index 9713315..0be416b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pbot-plus/bot", - "version": "1.0.0-beta", + "version": "1.0.1-beta", "description": "A multi-purpose Discord bot with Typescript", "main": "src/main.ts", "scripts": { @@ -24,6 +24,7 @@ }, "devDependencies": { "@types/node": "^15.6.1", + "@types/node-fetch": "^2.5.10", "@typescript-eslint/eslint-plugin": "^4.25.0", "@typescript-eslint/parser": "^4.25.0", "eslint": "^7.27.0", @@ -31,5 +32,8 @@ "eslint-plugin-prettier": "^3.4.0", "prettier": "^2.3.0", "typescript": "^4.3.2" + }, + "dependencies": { + "discord.js-light": "^3.5.11" } } diff --git a/src/bot.ts b/src/bot.ts new file mode 100644 index 0000000..88e5be3 --- /dev/null +++ b/src/bot.ts @@ -0,0 +1,75 @@ +import { Client, Constants, Message, MessageEmbed } from 'discord.js-light'; + +import { ILogger, Logger, Config } from './services'; + +export default class PbotPlus { + /** + * Custom logger for Pbot-plus + */ + public logger: ILogger = Logger; + + /** + * Configuration files for Pbot-plus + */ + public readonly config = Config; + + /** + * @param client Client + */ + constructor(private client: Client) {} + + /** + * Initialize the bot + */ + public async initialize(): Promise { + try { + this.registerListeners(); + await this.client.login(this.config.client.token); + } catch (err) { + this.logger.error('Failed while initializing to the bot', err); + } + } + + /** + * Register listeners + */ + private registerListeners(): void { + // on message + this.client.on(Constants.Events.MESSAGE_CREATE, (message: Message) => + this.onMessage(message) + ); + + // on ready + this.client.on(Constants.Events.CLIENT_READY, () => this.onReady()); + } + + /** + * On message + * @param message + * @returns + */ + private onMessage(message: Message): void { + if (message.author.bot ?? !message.guild?.member) return; + + const DevelopingErrorEmbed = new MessageEmbed({ + color: this.config.color.error, + description: + 'I am currently under development so only my developers can use my commands' + }); + + if ( + message.content.match(new RegExp(`^<@!?${this.client.user?.id}>( |)$`)) + ) { + message.channel.send(DevelopingErrorEmbed); + } else if (message.content.startsWith(this.config.client.prefix)) { + message.channel.send(DevelopingErrorEmbed); + } + } + + /** + * On ready + */ + private onReady(): void { + this.logger.info(`Signed in as ${this.client.user?.tag}`); + } +} diff --git a/src/extensions/custom-client/custom-client.ts b/src/extensions/custom-client/custom-client.ts new file mode 100644 index 0000000..66dd306 --- /dev/null +++ b/src/extensions/custom-client/custom-client.ts @@ -0,0 +1,26 @@ +import { + ActivityType, + Client, + ClientOptions, + Presence +} from 'discord.js-light'; + +export class CustomClient extends Client { + constructor(clientOptions: ClientOptions) { + super(clientOptions); + } + + public async setPresence( + type: ActivityType, + name: string, + url: string + ): Promise { + return await this.user!.setPresence({ + activity: { + type, + name, + url + } + }); + } +} diff --git a/src/extensions/index.ts b/src/extensions/index.ts new file mode 100644 index 0000000..6733265 --- /dev/null +++ b/src/extensions/index.ts @@ -0,0 +1 @@ +export { CustomClient } from './custom-client/custom-client'; diff --git a/src/main.ts b/src/main.ts index ef142f9..ae73257 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1 +1,33 @@ -console.log('hello guys'); +import PbotPlus from './bot'; +import { CustomClient } from './extensions'; +import { Logger, Config } from './services'; + +async function initialize(): Promise { + const client = new CustomClient({ + ws: { intents: Config.client.intents }, + partials: Config.client.partials, + messageCacheMaxSize: Config.client.caches.messages.size, + messageCacheLifetime: Config.client.caches.messages.lifetime, + messageSweepInterval: Config.client.caches.messages.sweepInterval, + cacheGuilds: Config.client.caches.guilds, + cacheRoles: Config.client.caches.roles, + cacheEmojis: Config.client.caches.emojis, + cacheChannels: Config.client.caches.channels, + cacheOverwrites: Config.client.caches.overwrites, + cachePresences: Config.client.caches.presences, + disabledEvents: Config.client.disabledEvents + }); + + const bot = new PbotPlus(client); + await bot.initialize(); + + return bot; +} + +process.on('unhandledRejection', (reason) => { + Logger.error('An unhandled promise rejection ocurred.', reason); +}); + +initialize().catch((error) => { + Logger.error('An unspecified error ocurred.', error); +}); diff --git a/src/services/config/config.interface.ts b/src/services/config/config.interface.ts new file mode 100644 index 0000000..b319a2e --- /dev/null +++ b/src/services/config/config.interface.ts @@ -0,0 +1,31 @@ +import { IntentsString, PartialTypes } from 'discord.js-light'; +import { EventTypes } from './event.type'; + +export interface ConfigTypes { + client: { + prefix: string; + token: string; + intents: Array; + disabledEvents: Array; + partials: Array; + caches: { + guilds: boolean; + roles: boolean; + emojis: boolean; + channels: boolean; + overwrites: boolean; + presences: boolean; + messages: { + size: number; + lifetime: number; + sweepInterval: number; + }; + }; + }; + color: { + success: string; + error: string; + warn: string; + info: string; + }; +} diff --git a/src/services/config/config.ts b/src/services/config/config.ts new file mode 100644 index 0000000..af2581d --- /dev/null +++ b/src/services/config/config.ts @@ -0,0 +1,36 @@ +import { ConfigTypes } from './config.interface'; + +export const Config: ConfigTypes = { + client: { + prefix: '!', + token: 'ODM1MjU4OTg3ODAwODIxNzkx.YIM1jQ.Uj2JtZ9Ie2tWWucBHWEydS_hH6s', + intents: [ + 'GUILDS', + 'GUILD_MESSAGES', + 'GUILD_MESSAGE_REACTIONS', + 'DIRECT_MESSAGES', + 'DIRECT_MESSAGE_REACTIONS' + ], + disabledEvents: [], + partials: ['MESSAGE', 'CHANNEL', 'REACTION'], + caches: { + guilds: true, + roles: true, + emojis: false, + channels: true, + overwrites: true, + presences: false, + messages: { + size: 0, + lifetime: 0, + sweepInterval: 0 + } + } + }, + color: { + success: '#2ecc71', + error: '#e74c3c', + warn: '#e7c83c', + info: '#7578da' + } +}; diff --git a/src/services/config/event.type.ts b/src/services/config/event.type.ts new file mode 100644 index 0000000..e6a3dd8 --- /dev/null +++ b/src/services/config/event.type.ts @@ -0,0 +1,51 @@ +export type EventTypes = + | 'channelCreate' + | 'channelDelete' + | 'channelPinsUpdate' + | 'channelUpdate' + | 'debug' + | 'warn' + | 'disconnect' + | 'emojiCreate' + | 'emojiDelete' + | 'emojiUpdate' + | 'error' + | 'guildBanAdd' + | 'guildBanRemove' + | 'guildCreate' + | 'guildDelete' + | 'guildUnavailable' + | 'guildIntegrationsUpdate' + | 'guildMemberAdd' + | 'guildMemberAvailable' + | 'guildMemberRemove' + | 'guildMembersChunk' + | 'guildMemberSpeaking' + | 'guildMemberUpdate' + | 'guildUpdate' + | 'inviteCreate' + | 'inviteDelete' + | 'message' + | 'messageDelete' + | 'messageReactionRemoveAll' + | 'messageReactionRemoveEmoji' + | 'messageDeleteBulk' + | 'messageReactionAdd' + | 'messageReactionRemove' + | 'messageUpdate' + | 'presenceUpdate' + | 'rateLimit' + | 'ready' + | 'invalidated' + | 'roleCreate' + | 'roleDelete' + | 'roleUpdate' + | 'typingStart' + | 'userUpdate' + | 'voiceStateUpdate' + | 'webhookUpdate' + | 'shardDisconnect' + | 'shardError' + | 'shardReady' + | 'shardReconnecting' + | 'shardResume'; diff --git a/src/services/index.ts b/src/services/index.ts new file mode 100644 index 0000000..21dc3a3 --- /dev/null +++ b/src/services/index.ts @@ -0,0 +1,6 @@ +export { Logger } from './logger/logger'; +export { ILogger } from './logger/logger.interface'; + +export { Config } from './config/config'; +export { ConfigTypes } from './config/config.interface'; +export { EventTypes } from './config/event.type'; diff --git a/src/services/logger/logger.interface.ts b/src/services/logger/logger.interface.ts new file mode 100644 index 0000000..976f1b0 --- /dev/null +++ b/src/services/logger/logger.interface.ts @@ -0,0 +1,5 @@ +export interface ILogger { + info(message: string): void; + warn(message: string): void; + error(message: string, error?: any): Promise; +} diff --git a/src/services/logger/logger.ts b/src/services/logger/logger.ts new file mode 100644 index 0000000..5ba9bd9 --- /dev/null +++ b/src/services/logger/logger.ts @@ -0,0 +1,59 @@ +import { DiscordAPIError } from 'discord.js-light'; +import { Response } from 'node-fetch'; + +export class Logger { + public static info(message: string): void { + const log = `[INFO] ${message}`; + console.log(log); + } + + public static warn(message: string): void { + const log = `[WARN] ${message}`; + console.warn(log); + } + + public static async error(message: string, error?: any): Promise { + const log = `[ERROR] ${message}`; + console.error(log); + + if (!error) { + return; + } + + switch (error.constructor) { + case Response: { + const res = error as Response; + let resText: string; + try { + resText = await res.text(); + } catch (err) { + this.error(err); + } + console.error({ + path: res.url, + statusCode: res.status, + statusName: res.statusText, + headers: res.headers.raw(), + body: resText! + }); + break; + } + case DiscordAPIError: { + const discordError = error as DiscordAPIError; + console.error({ + message: discordError.message, + code: discordError.code, + statusCode: discordError.httpStatus, + method: discordError.method, + path: discordError.path, + stack: discordError.stack + }); + break; + } + default: { + console.error(error); + break; + } + } + } +} diff --git a/tsconfig.json b/tsconfig.json index 907d3dc..745e05a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,74 +1,74 @@ { - "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ - /* Basic Options */ - // "incremental": true, /* Enable incremental compilation */ - "target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */, - "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, - "lib": [ - "ESNext" - ] /* Specify library files to be included in the compilation. */, - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - "sourceMap": true /* Generates corresponding '.map' file. */, - // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./dist" /* Redirect output structure to the directory. */, - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ + "target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */, + "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, + "lib": [ + "ESNext" + ] /* Specify library files to be included in the compilation. */, + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ + "sourceMap": true /* Generates corresponding '.map' file. */, + // "outFile": "./", /* Concatenate and emit output to single file. */ + "outDir": "./dist" /* Redirect output structure to the directory. */, + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "composite": true, /* Enable project compilation */ + // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */, - "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */, + "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ + // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + /* Source Map Options */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - /* Advanced Options */ - "skipLibCheck": true /* Skip type checking of declaration files. */, - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - } + /* Advanced Options */ + "skipLibCheck": true /* Skip type checking of declaration files. */, + "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + } }