diff --git a/.eslintrc.json b/.eslintrc.json index 52f270c..bf2b615 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -15,17 +15,38 @@ "sourceType": "module" }, "rules": { + "@typescript-eslint/no-unused-vars": "off", + "@typescript-eslint/no-non-null-assertion":"off", "accessor-pairs": "warn", "array-callback-return": "warn", - "array-bracket-newline": [ "warn", "consistent" ], - "array-bracket-spacing": [ "warn", "always", { "objectsInArrays": false, "arraysInArrays": false }], + "array-bracket-newline": [ + "warn", + "consistent" + ], + "array-bracket-spacing": [ + "warn", + "always", + { + "objectsInArrays": false, + "arraysInArrays": false + } + ], "arrow-spacing": "warn", "block-scoped-var": "warn", - "block-spacing": [ "warn", "always" ], - "brace-style": [ "warn", "1tbs" ], + "block-spacing": [ + "warn", + "always" + ], + "brace-style": [ + "warn", + "allman" + ], "callback-return": "warn", "camelcase": "warn", - "comma-dangle": [ "warn", "only-multiline" ], + "comma-dangle": [ + "warn", + "only-multiline" + ], "comma-spacing": [ "warn", { @@ -68,9 +89,25 @@ "implicit-arrow-linebreak": "warn", "indent": "warn", "init-declarations": "warn", - "jsx-quotes": [ "warn", "prefer-single" ], - "key-spacing": [ "warn", { "beforeColon": false, "afterColon": true }], - "keyword-spacing": [ "warn", { "after": true, "before": true }], + "quotes": ["error" , "single"], + "jsx-quotes": [ + "warn", + "prefer-single" + ], + "key-spacing": [ + "warn", + { + "beforeColon": false, + "afterColon": true + } + ], + "keyword-spacing": [ + "warn", + { + "after": true, + "before": true + } + ], "linebreak-style": [ "error", "unix" @@ -79,6 +116,24 @@ "lines-around-directive": "warn", "max-classes-per-file": "warn", "max-nested-callbacks": "warn", + "max-len": [ + "warn", + { + "code": 140, + "ignoreComments": true, + "ignoreStrings": true, + "ignoreTemplateLiterals": true, + "ignoreRegExpLiterals": true + } + ], + "max-lines-per-function": [ + "warn", + 100 + ], + "max-depth": [ + "warn", + 3 + ], "new-parens": "warn", "no-alert": "warn", "no-array-constructor": "warn", @@ -96,7 +151,6 @@ "no-extend-native": "warn", "no-extra-bind": "warn", "no-extra-label": "warn", - "no-extra-parens": "warn", "no-floating-decimal": "warn", "no-implicit-coercion": "warn", "no-implicit-globals": "warn", @@ -147,7 +201,7 @@ "no-unmodified-loop-condition": "warn", "no-unneeded-ternary": "error", "no-unused-expressions": "warn", - "no-use-before-define": "error", + "@typescript-eslint/no-use-before-define": "error", "no-useless-call": "warn", "no-useless-computed-key": "warn", "no-useless-concat": "warn", @@ -155,20 +209,39 @@ "no-useless-rename": "warn", "no-useless-return": "warn", "no-var": "warn", - "no-void": "warn", + // "no-void": "warn", "no-whitespace-before-property": "error", - "nonblock-statement-body-position": [ "warn", "below" ], + "nonblock-statement-body-position": [ + "warn", + "below" + ], "object-curly-spacing": [ "warn", "always" ], - "object-property-newline": [ "warn", { "allowAllPropertiesOnSameLine": true }], + "object-property-newline": [ + "warn", + { + "allowAllPropertiesOnSameLine": true + } + ], "object-shorthand": "warn", "one-var-declaration-per-line": "warn", "operator-assignment": "warn", - "operator-linebreak": [ "warn", "before" ], + "operator-linebreak": [ + "warn", + "before" + ], "padding-line-between-statements": "warn", - "padded-blocks": [ "warn", { "switches": "never" }, { "allowSingleLineBlocks": true }], + "padded-blocks": [ + "warn", + { + "switches": "never" + }, + { + "allowSingleLineBlocks": true + } + ], "prefer-arrow-callback": "warn", "prefer-const": "warn", "prefer-destructuring": "warn", @@ -189,12 +262,18 @@ "last" ], "space-before-blocks": "warn", - "space-before-function-paren": [ "error", "always" ], + "space-before-function-paren": [ + "error", + "always" + ], "space-in-parens": [ "warn", "never" ], - "spaced-comment": [ "warn", "always" ], + "spaced-comment": [ + "warn", + "always" + ], "strict": "warn", "switch-colon-spacing": "warn", "symbol-description": "warn", diff --git a/index.ts b/index.ts index fec6518..91db9cb 100644 --- a/index.ts +++ b/index.ts @@ -1,3 +1,4 @@ -import { WebhookClient } from "./src/WebhookClient.js"; +import { WebhookClient } from './src/WebhookClient.js'; +export { Payload, WebhookClientOptions } from './src/types/Webhook.js'; export { WebhookClient }; export default WebhookClient; \ No newline at end of file diff --git a/src/Http.ts b/src/Http.ts index 38b661f..f7cda5f 100644 --- a/src/Http.ts +++ b/src/Http.ts @@ -1,7 +1,8 @@ -import fetch from 'node-fetch'; + import RequestError from './util/RequestError.js'; import { ApiErrorData } from './types/Api.js'; import EventEmitter from 'events'; +import fetch from 'node-fetch'; type RequestOptions = { body?: string, @@ -21,7 +22,8 @@ type QueuedRequest = { reject: (err: RequestError) => void } -class HttpClient extends EventEmitter { +class HttpClient extends EventEmitter +{ userAgent: string; baseUrl: string | null; @@ -32,7 +34,8 @@ class HttpClient extends EventEmitter { } = { remaining: 5 }; #queue: QueuedRequest[]; - constructor ({ userAgent, baseUrl }: HttpClientOptions = {}) { + constructor ({ userAgent, baseUrl }: HttpClientOptions = {}) + { super(); @@ -45,7 +48,8 @@ class HttpClient extends EventEmitter { } - #parseRateLimit (limits: {[key: string]: string}) { + #parseRateLimit (limits: {[key: string]: string}) + { // const bucket = limits['x-ratelimit-bucket']; const limit = parseInt(limits['x-ratelimit-limit']); if (isNaN(limit)) // if this doesn't exist the headers weren't returned @@ -55,7 +59,8 @@ class HttpClient extends EventEmitter { const resetAfter = parseInt(limits['x-ratelimit-reset-after']) * 1000; this.#limit.remaining = remaining; if (this.#queue.length && !this.#limit.timeout) - this.#limit.timeout = setTimeout(async () => { + this.#limit.timeout = setTimeout(async () => + { this.#processQueue(); delete this.#limit.timeout; }, resetAfter); @@ -63,12 +68,15 @@ class HttpClient extends EventEmitter { } - async #processQueue () { + async #processQueue () + { const queue = [ ...this.#queue ]; this.#queue = []; - for (const req of queue) { + for (const req of queue) + { const { path, options, resolve, reject } = req; - if (!this.#limit.remaining) { + if (!this.#limit.remaining) + { this.#queue.push(req); continue; } @@ -78,7 +86,8 @@ class HttpClient extends EventEmitter { } } - async #_request (path: string, options: RequestOptions): Promise { + async #_request (path: string, options: RequestOptions): Promise + { let { headers } = options; const { body, method } = options; @@ -99,21 +108,25 @@ class HttpClient extends EventEmitter { const response = await fetch(url, request); const contentType = response.headers.get('Content-Type'); - const ratelimit = [ ...response.headers.entries() ].filter(([ key ]) => key.includes('x-ratelimit')).reduce((prev: {[key: string]: string}, [ key, val ]) => { + const ratelimit = [ ...response.headers.entries() ].filter(([ key ]) => key.includes('x-ratelimit')).reduce((prev: {[key: string]: string}, [ key, val ]) => + { prev[key] = val; return prev; }, {}); this.#parseRateLimit(ratelimit); - if (response.status === 429) { + if (response.status === 429) + { this.emit('rateLimited'); - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => + { this.#queue.push({ path, options, resolve, reject }); }); } - if (!response.ok) { + if (!response.ok) + { let message: ApiErrorData | null = null; if (contentType === 'application/json') message = await response.json() as ApiErrorData; @@ -134,9 +147,12 @@ class HttpClient extends EventEmitter { } - async request (path: string, options: RequestOptions): Promise { - if (!this.#limit.remaining) { - return new Promise((resolve, reject) => { + async request (path: string, options: RequestOptions): Promise + { + if (!this.#limit.remaining) + { + return new Promise((resolve, reject) => + { this.#queue.push({ path, options, resolve, reject }); }); } @@ -144,11 +160,13 @@ class HttpClient extends EventEmitter { return this.#_request(path, options); } - get (url: string) { + get (url: string) + { return this.request(url, { method: 'GET' }); } - post (url: string, body: object) { + post (url: string, body: object) + { const headers = { 'Content-Type': 'application/json' }; diff --git a/src/WebhookClient.ts b/src/WebhookClient.ts index 3f1f5ea..2ed4af2 100644 --- a/src/WebhookClient.ts +++ b/src/WebhookClient.ts @@ -7,7 +7,8 @@ import { RequestError, WebhookError } from './util/index.js'; const WebhookDestroyed = new WebhookError('Webhook does not exist'); -class WebhookClient extends EventEmitter { +class WebhookClient extends EventEmitter +{ // Discord credentials #url: string; @@ -24,14 +25,16 @@ class WebhookClient extends EventEmitter { #http: HttpClient; #destroyed = false; - constructor ({ url, token, id }: WebhookClientOptions) { + constructor ({ url, token, id }: WebhookClientOptions) + { super(); if (!url && (!token || !id)) throw new Error('Missing webhook credentials, either pass a url or token and id'); - if (url && (!id || !token)) { + if (url && (!id || !token)) + { const parts = url.split('/'); id = parts[parts.length - 2]; token = parts[parts.length - 1]; @@ -51,7 +54,8 @@ class WebhookClient extends EventEmitter { } - #patch (data: WebhookData) { + #patch (data: WebhookData) + { if (data.id) this.#id = data.id; @@ -69,14 +73,18 @@ class WebhookClient extends EventEmitter { return this; } - async fetch () { + async fetch () + { if (this.#destroyed) throw WebhookDestroyed; let result = null; - try { + try + { result = await this.#http.get(this.#url); - } catch (err) { + } + catch (err) + { if (err instanceof RequestError && err.httpCode === 404) this.#destroyed = true; throw err; @@ -84,7 +92,8 @@ class WebhookClient extends EventEmitter { return this.#patch(result as WebhookData); } - async send (content: string | Payload) { + async send (content: string | Payload) + { if (this.#destroyed) throw WebhookDestroyed; @@ -100,39 +109,48 @@ class WebhookClient extends EventEmitter { return response; } - get url () { + get url () + { return this.#url; } - get id () { + get id () + { return this.#id; } - get name () { + get name () + { return this.#name; } - get type () { + get type () + { return this.#type; } - get channelId () { + get channelId () + { return this.#channelId; } - get guildId () { + get guildId () + { return this.#guildId; } - get avatar () { + get avatar () + { return this.#avatar; } - get token () { + get token () + { return this.#token; } - get [Symbol.toStringTag] () { + get [Symbol.toStringTag] () + { return `{ name: ${this.name}, type: ${this.type}, diff --git a/src/util/RequestError.ts b/src/util/RequestError.ts index 32f2834..bf74592 100644 --- a/src/util/RequestError.ts +++ b/src/util/RequestError.ts @@ -1,9 +1,11 @@ -import { ApiErrorData } from "../types/Api.js"; +import { ApiErrorData } from '../types/Api.js'; -class RequestError extends Error { +class RequestError extends Error +{ code?: number; httpCode: number; - constructor (response: ApiErrorData) { + constructor (response: ApiErrorData) + { super(`[${response.code ?? response.httpCode}] ${response.message}`); this.code = response.code; diff --git a/src/util/index.ts b/src/util/index.ts index 4e62e0b..38d9073 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -1,4 +1,4 @@ -import RequestError from "./RequestError.js"; -import WebhookError from "./WebhookError.js"; +import RequestError from './RequestError.js'; +import WebhookError from './WebhookError.js'; export { RequestError, WebhookError }; \ No newline at end of file diff --git a/test/WebhookClient.test.js b/test/WebhookClient.test.js index c48db70..5f0b10a 100644 --- a/test/WebhookClient.test.js +++ b/test/WebhookClient.test.js @@ -1,5 +1,5 @@ import WebhookClient from '../build/esm/index.js'; -import EventEmitter from "events"; +import EventEmitter from 'events'; const webhook = new WebhookClient({ url: 'https://discord.com/api/webhooks/1093874668886294548/uDMRD6g1lmq_2EZynsbKytzWoMM-0N4te0m61r_cv1BsSnDKDxG3fvI6sxSoG5t5b_xn' }); // new WebhookClient({ token: 'uDMRD6g1lmq_2EZynsbKytzWoMM-0N4te0m61r_cv1BsSnDKDxG3fvI6sxSoG5t5b_xn', id: '1093874668886294548' }); diff --git a/tsconfig.json b/tsconfig.json index 2311167..ec7721c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,113 +1,113 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - "lib": ["ES2022"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "ES2022", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - "typeRoots": [ - "./node_modules/@types", - "./@types" - ], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ - // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ - // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ - // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - "allowJs": false, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "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. */ - "outDir": "./build/esm", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "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. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - }, - "compileOnSave": true +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + "lib": ["ES2022"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "ES2022", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + "typeRoots": [ + "./node_modules/@types", + "./@types" + ], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + "allowJs": false, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "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. */ + "outDir": "./build/esm", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "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. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + }, + "compileOnSave": true } \ No newline at end of file