pols-logger 1.1.2 → 2.0.1

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.
package/README.md CHANGED
@@ -1,3 +1,192 @@
1
- # Pols-Utils
2
-
3
- Utils methods
1
+ # pols-logger
2
+
3
+ `pols-logger` es una librería robusta y ligera de logging para Node.js escrita en TypeScript. Permite registrar mensajes formateados tanto en la consola como en archivos físicos, ofreciendo serialización automática de objetos, formateo limpio de errores y pilas de llamadas (stack traces), gestión de directorios automatizada y hooks de finalización personalizados.
4
+
5
+ ## Características
6
+
7
+ * **Salidas flexibles:** Registra logs en consola, en archivos locales o en ambos a la vez de forma condicional.
8
+ * **Serialización automática de datos:** Soporta cuerpos de log (`body`) del tipo `string`, `number`, `object` (JSON estructurado), `Error` (con stack trace seguro) y arreglos mixtos.
9
+ * **Ruteo inteligente de consola:** Redirecciona automáticamente los logs de temas críticos (`ERROR`, `FATAL`) a `console.error` y el resto a `console.log`.
10
+ * **Escritura eficiente en disco:** Optimiza las comprobaciones de directorios mediante una verificación perezosa (evita llamar a `fs.existsSync` repetidamente).
11
+ * **Finalización de procesos controlada:** El método `fatal` detiene el proceso automáticamente con código de salida `1` por defecto, permitiendo configurar códigos de salida específicos en cualquier entrada de log.
12
+ * **Eventos personalizados:** Permite registrar un hook `onEntryFinish` para reaccionar al terminar de escribir una entrada de log (útil para telemetría, alertas, etc.).
13
+
14
+ ---
15
+
16
+ ## Instalación
17
+
18
+ Instala el paquete y sus dependencias en tu proyecto:
19
+
20
+ ```bash
21
+ npm install pols-logger
22
+ ```
23
+
24
+ ---
25
+
26
+ ## Configuración y API
27
+
28
+ ### `PLogger`
29
+
30
+ La clase principal que maneja los registros.
31
+
32
+ #### Constructor
33
+
34
+ ```typescript
35
+ const logger = new PLogger(config?: PLoggerParams)
36
+ ```
37
+
38
+ Donde `PLoggerParams` tiene la siguiente estructura:
39
+
40
+ * **`destinationPath?: string`**: Directorio donde se guardarán los archivos log. Obligatorio si el guardado en archivo está activado.
41
+ * **`fileName?: ({ theme: PThemes, now: Date }) => string`**: Función personalizada para nombrar los archivos log dinámicamente. Por defecto genera nombres con el formato `LOG_YYYY-MM-DD.log`.
42
+ * **`showIn?: PLoggerShowInConfig`**: Configura dónde mostrar cada tema de log.
43
+
44
+ #### `PLoggerShowInConfig`
45
+
46
+ Define si las salidas van a la consola o a archivos. Puede ser un booleano global o un objeto de grano fino para cada tipo de log:
47
+
48
+ ```typescript
49
+ export type PLoggerShowInParams = boolean | {
50
+ info?: boolean
51
+ warning?: boolean
52
+ error?: boolean
53
+ debug?: boolean
54
+ system?: boolean
55
+ fatal?: boolean
56
+ }
57
+
58
+ export type PLoggerShowInConfig = {
59
+ console?: PLoggerShowInParams
60
+ file?: PLoggerShowInParams
61
+ }
62
+ ```
63
+
64
+ *Por defecto, `console` está activado (`true` para todos) y `file` está desactivado (`false`).*
65
+
66
+ ---
67
+
68
+ ### Métodos de Logging
69
+
70
+ Todos los métodos aceptan un objeto del tipo `PLoggerLogParams` y formatean la salida con la estructura: `[THEME] DD/MM/YYYY HH:MM:SS.lll :: LABEL :: DESCRIPTION [TAG1] [TAG2]` seguido del contenido de `body`.
71
+
72
+ * `logger.info(params)`
73
+ * `logger.warning(params)`
74
+ * `logger.error(params)`
75
+ * `logger.debug(params)`
76
+ * `logger.system(params)`
77
+ * `logger.fatal(params)` *(provoca salida del proceso al finalizar)*
78
+
79
+ ---
80
+
81
+ ### Estructura de Parámetros (`PLoggerLogParams`)
82
+
83
+ * **`label: string`** (Requerido): Etiqueta identificadora o título de la entrada.
84
+ * **`description?: string`**: Descripción breve adicional del evento.
85
+ * **`tags?: string[]`**: Etiquetas contextuales que se mostrarán al final de la cabecera (ej: `['database', 'retry']`).
86
+ * **`body?: string | Record<string, any> | any[] | Error`**: Contenido o carga útil a registrar.
87
+ * **`exit?: boolean | number`**: Si es `true` o un número, terminará la ejecución del proceso al finalizar el registro. Si es un número, se utilizará como código de salida.
88
+
89
+ ---
90
+
91
+ ## Ejemplos de Uso
92
+
93
+ ### 1. Inicialización Básica (Solo Consola)
94
+
95
+ ```typescript
96
+ import { PLogger } from 'pols-logger'
97
+
98
+ const logger = new PLogger()
99
+
100
+ logger.info({
101
+ label: 'APP_START',
102
+ description: 'Iniciando la aplicación en modo producción'
103
+ })
104
+ ```
105
+
106
+ ### 2. Guardado en Archivo con Rotación Personalizada
107
+
108
+ Puedes generar archivos de logs separados por horas, turnos o días utilizando la fecha actual en la función `fileName`:
109
+
110
+ ```typescript
111
+ import { PLogger } from 'pols-logger'
112
+ import { PUtilsDate, PUtilsNumber } from 'pols-utils'
113
+
114
+ const logger = new PLogger({
115
+ showIn: {
116
+ console: true,
117
+ file: true
118
+ },
119
+ destinationPath: __dirname + '/logs',
120
+ fileName: ({ now }) => {
121
+ // Crea un archivo diferente cada 6 horas (ej: LOG 2026-07-07 06-00.log)
122
+ const hourRange = PUtilsNumber.padStart(Math.floor(now.getHours() / 6) * 6, 2)
123
+ return PUtilsDate.format(now, `LOG @y-@mm-@dd ${hourRange}-00.log`)
124
+ }
125
+ })
126
+
127
+ logger.system({
128
+ label: 'DB_SYNC',
129
+ description: 'Sincronización de esquemas completada'
130
+ })
131
+ ```
132
+
133
+ ### 3. Registro de Datos Complejos (Objetos, Arreglos y Errores)
134
+
135
+ `pols-logger` detecta automáticamente el tipo de dato del `body` y lo formatea de manera óptima para lectura humana.
136
+
137
+ ```typescript
138
+ // 1. Registrar un Objeto (JSON formateado con espacios)
139
+ logger.info({
140
+ label: 'USER_LOGIN',
141
+ body: {
142
+ userId: 1042,
143
+ role: 'admin',
144
+ session: { active: true }
145
+ }
146
+ })
147
+
148
+ // 2. Registrar un Error (Muestra mensaje y stack trace limpio)
149
+ try {
150
+ throw new Error('Conexión perdida con el host remoto')
151
+ } catch (error) {
152
+ logger.error({
153
+ label: 'CONNECTION_FAILURE',
154
+ body: error
155
+ })
156
+ }
157
+
158
+ // 3. Registrar un Arreglo Mixto (Formatea recursivamente cada elemento)
159
+ logger.warning({
160
+ label: 'BATCH_PROCESS',
161
+ body: [
162
+ 'Procesando lote #54',
163
+ 404,
164
+ { itemId: 'A-12' },
165
+ new Error('Fallo de validación local')
166
+ ]
167
+ })
168
+ ```
169
+
170
+ ### 4. Uso del Hook de Evento `onEntryFinish`
171
+
172
+ Útil para reenviar alertas a servicios de mensajería (como Slack, Telegram) o registrar auditorías adicionales:
173
+
174
+ ```typescript
175
+ const logger = new PLogger({
176
+ destinationPath: './logs',
177
+ showIn: { console: true, file: true }
178
+ })
179
+
180
+ // Hook que se ejecuta al finalizar la escritura de cada log
181
+ logger.onEntryFinish = (entry) => {
182
+ if (entry.exit) {
183
+ console.log(`El logger provocó una salida del sistema con etiqueta: ${entry.label}`)
184
+ }
185
+ }
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Licencia
191
+
192
+ Este proyecto está bajo la Licencia ISC.
package/dist/index.d.ts CHANGED
@@ -32,12 +32,13 @@ export type PLoggerLogParams = {
32
32
  description?: string;
33
33
  tags?: string[];
34
34
  body?: string | PRecord | unknown[] | Error;
35
- exit?: boolean;
35
+ exit?: boolean | number;
36
36
  };
37
37
  export declare class PLogger {
38
38
  destinationPath?: string;
39
39
  showIn?: PLoggerShowInConfig;
40
40
  fileName?: PLoggerParams['fileName'];
41
+ _dirChecked?: string;
41
42
  onEntryFinish?: (params: PLoggerLogParams) => void;
42
43
  constructor(params?: PLoggerParams);
43
44
  info(params: PLoggerLogParams): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAc,MAAM,YAAY,CAAA;AAEhD,oBAAY,OAAO;IAClB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,KAAK,UAAU;CACf;AAED,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG;IAC3C,IAAI,CAAC,EAAE,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KAAK,CAAA;IAC3C,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;CACvB,CAAA;AA2HD,qBAAa,OAAO;IACnB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,MAAM,CAAC,EAAE,mBAAmB,CAAA;IAC5B,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IACpC,WAAW,CAAC,EAAE,MAAM,CAAA;IACZ,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAA;gBAE9C,MAAM,CAAC,EAAE,aAAa;IAMlC,IAAI,CAAC,MAAM,EAAE,gBAAgB;IAI7B,OAAO,CAAC,MAAM,EAAE,gBAAgB;IAIhC,KAAK,CAAC,MAAM,EAAE,gBAAgB;IAI9B,KAAK,CAAC,MAAM,EAAE,gBAAgB;IAI9B,MAAM,CAAC,MAAM,EAAE,gBAAgB;IAI/B,KAAK,CAAC,MAAM,EAAE,gBAAgB;CAG9B"}
package/dist/index.js CHANGED
@@ -22,13 +22,14 @@ const check = (theme, value, def) => {
22
22
  if (typeof value == 'boolean')
23
23
  return value;
24
24
  switch (theme) {
25
- case PThemes.INFO: return value.info;
26
- case PThemes.WARNING: return value.warning;
27
- case PThemes.ERROR: return value.error;
28
- case PThemes.DEBUG: return value.debug;
29
- case PThemes.SYSTEM: return value.system;
30
- case PThemes.FATAL: return value.fatal;
25
+ case PThemes.INFO: return value.info ?? def;
26
+ case PThemes.WARNING: return value.warning ?? def;
27
+ case PThemes.ERROR: return value.error ?? def;
28
+ case PThemes.DEBUG: return value.debug ?? def;
29
+ case PThemes.SYSTEM: return value.system ?? def;
30
+ case PThemes.FATAL: return value.fatal ?? def;
31
31
  }
32
+ return def;
32
33
  };
33
34
  const logger = (theme, pLogger, { label, description, body, exit = false, tags }, executeEvent = true) => {
34
35
  const now = new Date;
@@ -44,7 +45,7 @@ const logger = (theme, pLogger, { label, description, body, exit = false, tags }
44
45
  if (b instanceof Error) {
45
46
  return [
46
47
  'Error: ' + b.message,
47
- b.stack.replace(/^Error.*?\n/, '')
48
+ b.stack?.replace(/^Error.*?\n/, '') ?? ''
48
49
  ];
49
50
  }
50
51
  else if (typeof b == 'string') {
@@ -56,20 +57,45 @@ const logger = (theme, pLogger, { label, description, body, exit = false, tags }
56
57
  else if (b == null) {
57
58
  return '';
58
59
  }
60
+ else if (typeof b == 'object') {
61
+ try {
62
+ return JSON.stringify(b, null, 2);
63
+ }
64
+ catch {
65
+ return b.toString();
66
+ }
67
+ }
59
68
  else {
60
- b.toString();
69
+ return String(b);
61
70
  }
62
71
  }).flat());
63
72
  }
64
73
  else if (body instanceof Error) {
65
- textBody.push('Error: ' + body.message, body.stack.replace(/^Error.*?\n/, ''));
74
+ textBody.push('Error: ' + body.message, body.stack?.replace(/^Error.*?\n/, '') ?? '');
66
75
  }
67
76
  else if (typeof body == 'string') {
68
77
  textBody.push(body);
69
78
  }
79
+ else if (typeof body == 'number') {
80
+ textBody.push(body.toString());
81
+ }
82
+ else if (body == null) {
83
+ // do nothing
84
+ }
85
+ else if (typeof body == 'object') {
86
+ try {
87
+ textBody.push(JSON.stringify(body, null, 2));
88
+ }
89
+ catch {
90
+ textBody.push(body.toString());
91
+ }
92
+ }
93
+ else {
94
+ textBody.push(String(body));
95
+ }
70
96
  /* Por defecto, muestra el mensaje en consola */
71
97
  if (check(theme, pLogger.showIn?.console, true)) {
72
- if ([].includes(theme)) {
98
+ if ([PThemes.ERROR, PThemes.FATAL].includes(theme)) {
73
99
  console.error(headers.join(' '));
74
100
  if (textBody.length)
75
101
  console.error(textBody.join('\n'));
@@ -86,20 +112,25 @@ const logger = (theme, pLogger, { label, description, body, exit = false, tags }
86
112
  if (!pLogger.destinationPath)
87
113
  throw new Error(`La propiedad 'destinationPath' es requerida si la entrada debe ir a un archivo`);
88
114
  const filePath = path_1.default.join(pLogger.destinationPath, fileName);
89
- if (!fs_1.default.existsSync(pLogger.destinationPath)) {
90
- /* Si no existe la carpeta para los logs, se intentará crear automáticamente */
91
- try {
92
- fs_1.default.mkdirSync(pLogger.destinationPath, { recursive: true });
93
- }
94
- catch (error) {
95
- throw new Error(`No fue posible crear el directorio '${pLogger.destinationPath}': ${error.message}`);
115
+ if (pLogger._dirChecked !== pLogger.destinationPath) {
116
+ if (!fs_1.default.existsSync(pLogger.destinationPath)) {
117
+ /* Si no existe la carpeta para los logs, se intentará crear automáticamente */
118
+ try {
119
+ fs_1.default.mkdirSync(pLogger.destinationPath, { recursive: true });
120
+ }
121
+ catch (error) {
122
+ const errMsg = error instanceof Error ? error.message : String(error);
123
+ throw new Error(`No fue posible crear el directorio '${pLogger.destinationPath}': ${errMsg}`);
124
+ }
96
125
  }
126
+ pLogger._dirChecked = pLogger.destinationPath;
97
127
  }
98
128
  try {
99
129
  fs_1.default.appendFileSync(filePath, `${headers.join(' ')}${textBody.length ? `\n${textBody.join('\n')}` : ''}\n`, { encoding: 'utf-8' });
100
130
  }
101
131
  catch (error) {
102
- throw new Error(`No fue posible registrar la entrada en el archivo '${filePath}': ${error.message}`);
132
+ const errMsg = error instanceof Error ? error.message : String(error);
133
+ throw new Error(`No fue posible registrar la entrada en el archivo '${filePath}': ${errMsg}`);
103
134
  }
104
135
  }
105
136
  /* Ejecuta el evento del pLogger */
@@ -112,13 +143,16 @@ const logger = (theme, pLogger, { label, description, body, exit = false, tags }
112
143
  }
113
144
  }
114
145
  /* Si se ha dado la opción, se sale del programa */
115
- if (exit)
116
- process.exit();
146
+ if (exit) {
147
+ const exitCode = typeof exit === 'number' ? exit : (theme === PThemes.FATAL || theme === PThemes.ERROR ? 1 : 0);
148
+ process.exit(exitCode);
149
+ }
117
150
  };
118
151
  class PLogger {
119
152
  destinationPath;
120
153
  showIn;
121
154
  fileName;
155
+ _dirChecked;
122
156
  constructor(params) {
123
157
  this.destinationPath = params?.destinationPath;
124
158
  this.showIn = params?.showIn;
package/package.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "name": "pols-logger",
3
- "version": "1.1.2",
3
+ "version": "2.0.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
- "build:cjs": "npx tsc --project tsconfig.cjs.json",
9
- "build:esm": "npx tsc --project tsconfig.esm.json",
10
8
  "build": "npx tsc",
11
9
  "test": "npx ts-node-dev -r tsconfig-paths/register --project tsconfig.json",
12
10
  "export": "npm run build && npm publish"
@@ -30,6 +28,6 @@
30
28
  "typescript-eslint": "^8.11.0"
31
29
  },
32
30
  "dependencies": {
33
- "pols-utils": "^5.9.3"
31
+ "pols-utils": "^6.0.1"
34
32
  }
35
33
  }
@@ -1,22 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "npm run test",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "runtimeExecutable": "npm",
15
- "runtimeArgs": [
16
- "run",
17
- "test",
18
- "test/logger.ts"
19
- ]
20
- }
21
- ]
22
- }
@@ -1,3 +0,0 @@
1
- {
2
- "typescript.tsdk": "node_modules\\typescript\\lib"
3
- }
package/eslint.config.mjs DELETED
@@ -1,19 +0,0 @@
1
- import globals from "globals";
2
- import pluginJs from "@eslint/js";
3
- import tseslint from "typescript-eslint";
4
-
5
- export default [
6
- {
7
- files: ["**/*.{ts}"],
8
- },
9
- { languageOptions: { globals: globals.node } },
10
- pluginJs.configs.recommended,
11
- ...tseslint.configs.recommended,
12
- {
13
- rules: {
14
- "@typescript-eslint/no-unused-vars": "warn",
15
- "@typescript-eslint/no-explicit-any": false,
16
- "no-use-before-define": "off"
17
- }
18
- }
19
- ];
package/tsconfig.cjs.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "module": "commonjs",
5
- "moduleResolution": "Node",
6
- "outDir": "./dist/cjs"
7
- }
8
- }
package/tsconfig.esm.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "outDir": "./dist/esm"
7
- }
8
- }
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "esModuleInterop": true,
7
- "forceConsistentCasingInFileNames": true,
8
- "strict": false,
9
- "skipLibCheck": true,
10
- "declaration": true,
11
- "declarationMap": true,
12
- "outDir": "./dist"
13
- },
14
- "include": [
15
- "src/**/*.ts"
16
- ],
17
- "exclude": [
18
- "node_modules"
19
- ]
20
- }
package/tsconfig.old.json DELETED
@@ -1,102 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig to read more about this file */
4
- /* Projects */
5
- // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
6
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
7
- // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
8
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
9
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
10
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
11
- /* Language and Environment */
12
- "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
13
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
14
- // "jsx": "preserve", /* Specify what JSX code is generated. */
15
- // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
16
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
17
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
18
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
19
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
20
- // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
21
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
22
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
23
- // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
24
- /* Modules */
25
- "module": "commonjs", /* Specify what module code is generated. */
26
- // "rootDir": "./", /* Specify the root folder within your source files. */
27
- // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
28
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
29
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
30
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
31
- // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
32
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
33
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
34
- // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
35
- // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
36
- // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
37
- // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
38
- // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
39
- // "noUncheckedSideEffectImports": true, /* Check side effect imports. */
40
- // "resolveJsonModule": true, /* Enable importing .json files. */
41
- // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
42
- // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
43
- /* JavaScript Support */
44
- // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
45
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
46
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
47
- /* Emit */
48
- // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
49
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
50
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
51
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
52
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
53
- // "noEmit": true, /* Disable emitting files from a compilation. */
54
- // "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. */
55
- // "outDir": "./", /* Specify an output folder for all emitted files. */
56
- // "removeComments": true, /* Disable emitting comments. */
57
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
58
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
59
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
60
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
61
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
- // "newLine": "crlf", /* Set the newline character for emitting files. */
64
- // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65
- // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
- // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
- /* Interop Constraints */
70
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
71
- // "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. */
72
- // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
73
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77
- /* Type Checking */
78
- "strict": true, /* Enable all strict type-checking options. */
79
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
80
- // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
81
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
82
- // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
83
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
84
- // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
85
- // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86
- // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88
- // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98
- /* Completeness */
99
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
100
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
101
- }
102
- }