http-snapshotter 0.1.2 → 0.1.4

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
@@ -2,6 +2,8 @@
2
2
 
3
3
  Take snapshots of HTTP requests for purpose of tests (on node.js).
4
4
 
5
+ Use-case: Let's say you are testing a server end-point, that makes several external network requests before giving a response. In a unit test you would want any external network call to be stubbed/mocked. What one wants is to test the end-point for a fixed input and fixed responses of external network calls. Stubs take quite a while to write, rather create snapshots of the requests automatically by HTTP Snapshotter and only write test code for the end-point input and output.
6
+
5
7
  WARNING: This module isn't concurrent or thread safe yet. You can only use it on serial test runners like `tape`.
6
8
 
7
9
  Example (test.js):
@@ -43,6 +45,8 @@ Tip: When you do `SNAPSHOT=update` to create snapshots, run it against a single
43
45
 
44
46
  Finally after getting all your tests to use snapshots, run your test runner against all your tests and then take a look at `<snapshots directory>/unused-snapshots.log` file to see which snapshot files haven't been used by your final test suite. You can delete unused snapshot files.
45
47
 
48
+ The tests of this library uses this library itself, check the `tests/` directory and try the tests `npm ci; npm test`.
49
+
46
50
  ## About snapshot files and its names
47
51
 
48
52
  A snapshot file name unique identifies a request. By default it is a combination of HTTP method + URL + body that makes a request unique.
package/index.d.ts ADDED
@@ -0,0 +1,92 @@
1
+ export type SnapshotText = {
2
+ responseType: 'text';
3
+ fileSuffixKey: string;
4
+ request: {
5
+ method: string;
6
+ url: string;
7
+ headers: string[][];
8
+ body: string | undefined;
9
+ };
10
+ response: {
11
+ status: number;
12
+ statusText: string;
13
+ headers: string[][];
14
+ body: string | undefined;
15
+ };
16
+ };
17
+ export type SnapshotJson = {
18
+ responseType: 'json';
19
+ fileSuffixKey: string;
20
+ request: {
21
+ method: string;
22
+ url: string;
23
+ headers: string[][];
24
+ body: string | undefined;
25
+ };
26
+ response: {
27
+ status: number;
28
+ statusText: string;
29
+ headers: string[][];
30
+ body: object | undefined;
31
+ };
32
+ };
33
+ export type Snapshot = SnapshotText | SnapshotJson;
34
+ export type ClientRequestInterceptorType = import('@mswjs/interceptors/ClientRequest').ClientRequestInterceptor;
35
+ export type FetchInterceptorType = import('@mswjs/interceptors/fetch').FetchInterceptor;
36
+ /**
37
+ * @param {Request} request
38
+ */
39
+ export function defaultSnapshotFileNameGenerator(request: Request): Promise<{
40
+ filePrefix: string;
41
+ fileSuffixKey: string;
42
+ }>;
43
+ /**
44
+ * Attach snapshot filename generator function
45
+ *
46
+ * Here's your opportunity to uniquely identify a request with a snapshot file name.
47
+ * The default generator uses HTTP method, slugified URL (check @sindresorhus/slugify
48
+ * npm package) as the file name prefix
49
+ * And <HTTP method>#<url>#<body text> concatenated as file name suffix key
50
+ * (which then is SHA256 hashed and the hash is used as the actual file name suffix).
51
+ *
52
+ * Use cases (not limited to):
53
+ * 1. if a request body has a dynamic random id or timestamp, you can remove it from
54
+ * cache key computation
55
+ * 2. if a specific test does not use the default snapshot, you can prefix the snapshot
56
+ * file name for the test.
57
+ *
58
+ * WARNING: Attaching a function on a per-test basis may not be concurrent safe. i.e. If you tests
59
+ * run sequentially, then it is safe. But if your test runner runs test suites concurrently,
60
+ * then it is better to attach a function only once ever.
61
+ * @param {(req: Request) => Promise<{ filePrefix: string, fileSuffixKey: string }>} func
62
+ */
63
+ export function attachSnapshotFilenameGenerator(func: (req: Request) => Promise<{
64
+ filePrefix: string;
65
+ fileSuffixKey: string;
66
+ }>): void;
67
+ /** Reset snapshot filename generator to default */
68
+ export function resetSnapshotFilenameGenerator(): void;
69
+ /**
70
+ * Attach response transformer function.
71
+ *
72
+ * Here is an opportunity to modify the response (loaded from snapshot) on-the-fly right before
73
+ * the response is sent to consumers.
74
+ *
75
+ * WARNING: Attaching a function on a per-test basis may not be concurrent safe. i.e. If you tests
76
+ * run sequentially, then it is safe. But if your test runner runs test suites concurrently,
77
+ * then it is better to attach a function only once ever.
78
+ * @param {(response: Response, request: Request) => Promise<Response>} func
79
+ */
80
+ export function attachResponseTransformer(func: (response: Response, request: Request) => Promise<Response>): void;
81
+ /** Reset response transformer */
82
+ export function resetResponseTransformer(): void;
83
+ /**
84
+ * Start the interceptor
85
+ * @param {object} opts
86
+ * @param {string|null} opts.snapshotDirectory Full absolute path to snapshot directory
87
+ */
88
+ export function start({ snapshotDirectory: _snapshotDirectory, }?: {
89
+ snapshotDirectory: string | null;
90
+ }): void;
91
+ /** Stop the interceptor */
92
+ export function stop(): void;
package/index.js CHANGED
@@ -35,6 +35,9 @@ const { resolve } = require('node:path');
35
35
  const SNAPSHOT = process.env.SNAPSHOT || 'read';
36
36
  const LOG_REQ = process.env.LOG_REQ === '1' || process.env.LOG_REQ === 'true';
37
37
  const unusedSnapshotsLogFile = 'unused-snapshots.log';
38
+ /**
39
+ * @type {import("node:fs").PathLike | null}
40
+ */
38
41
  let snapshotDirectory = null;
39
42
 
40
43
  /**
@@ -72,9 +75,13 @@ let snapshotDirectory = null;
72
75
  * @typedef {SnapshotText | SnapshotJson} Snapshot
73
76
  */
74
77
 
78
+ /** @type {(res: any) => any} */
75
79
  const identity = (response) => response;
76
80
 
77
81
  const defaultKeyDerivationProps = ['method', 'url', 'body'];
82
+ /**
83
+ * @param {Request} request
84
+ */
78
85
  async function defaultSnapshotFileNameGenerator(request) {
79
86
  const url = new URL(request.url);
80
87
  const filePrefix = [
@@ -89,6 +96,7 @@ async function defaultSnapshotFileNameGenerator(request) {
89
96
  if (key === 'body') {
90
97
  return request.clone().text();
91
98
  }
99
+ // @ts-ignore
92
100
  return request[key];
93
101
  }),
94
102
  );
@@ -124,7 +132,7 @@ async function getSnapshotFileName(request) {
124
132
  const fileName = `${filePrefix}-${hash}.json`;
125
133
 
126
134
  return {
127
- absoluteFilePath: resolve(snapshotDirectory, fileName),
135
+ absoluteFilePath: resolve(/** @type {string} */ (snapshotDirectory), fileName),
128
136
  fileName,
129
137
  filePrefix,
130
138
  fileSuffixKey,
@@ -180,7 +188,9 @@ async function saveSnapshot(request, response) {
180
188
  return fileName;
181
189
  }
182
190
 
191
+ /** @type {Record<string, Snapshot>} */
183
192
  const snapshotCache = {};
193
+
184
194
  /**
185
195
  * @param {Request} request
186
196
  */
@@ -230,7 +240,9 @@ async function enforceSnapshotResponse(request) {
230
240
  } = snapshot;
231
241
 
232
242
  let newResponse = new Response(
233
- responseType === 'json' ? JSON.stringify(body) : body,
243
+ responseType === 'json'
244
+ ? JSON.stringify(body)
245
+ : /** @type {string} */ (body),
234
246
  {
235
247
  status,
236
248
  statusText,
@@ -246,8 +258,10 @@ async function enforceSnapshotResponse(request) {
246
258
  return newResponse;
247
259
  }
248
260
 
261
+ /** @typedef {import('@mswjs/interceptors/ClientRequest').ClientRequestInterceptor} ClientRequestInterceptorType */
262
+ /** @typedef {import('@mswjs/interceptors/fetch').FetchInterceptor} FetchInterceptorType */
249
263
  /**
250
- * @type {import('@mswjs/interceptors').BatchInterceptor|null}
264
+ * @type {import('@mswjs/interceptors').BatchInterceptor<(ClientRequestInterceptorType|FetchInterceptorType)[]>|null}
251
265
  */
252
266
  let interceptor = null;
253
267
 
@@ -258,22 +272,24 @@ process.on('beforeExit', async () => {
258
272
  beforeExitEventSeen = true;
259
273
  let files;
260
274
  try {
275
+ // @ts-ignore
261
276
  files = await fs.readdir(snapshotDirectory);
262
277
  } catch (err) {
263
278
  return;
264
279
  }
280
+ let dir = /** @type {string} */(snapshotDirectory);
265
281
  unusedFiles = files.filter((file) => !readFiles.has(file) && file !== unusedSnapshotsLogFile);
266
282
  if (unusedFiles.length) {
267
283
  await fs
268
284
  .writeFile(
269
- resolve(snapshotDirectory, unusedSnapshotsLogFile),
285
+ resolve(dir, unusedSnapshotsLogFile),
270
286
  unusedFiles.join('\n'),
271
287
  'utf-8',
272
288
  )
273
289
  .catch((err) => console.error(err));
274
290
  } else {
275
291
  await fs
276
- .unlink(resolve(snapshotDirectory, unusedSnapshotsLogFile))
292
+ .unlink(resolve(dir, unusedSnapshotsLogFile))
277
293
  .catch((err) => {
278
294
  if (err.code !== 'ENOENT') {
279
295
  console.error(err);
@@ -283,27 +299,60 @@ process.on('beforeExit', async () => {
283
299
  }
284
300
  });
285
301
 
286
- // Attach snapshot filename generator function
302
+ /**
303
+ * Attach snapshot filename generator function
304
+ *
305
+ * Here's your opportunity to uniquely identify a request with a snapshot file name.
306
+ * The default generator uses HTTP method, slugified URL (check @sindresorhus/slugify
307
+ * npm package) as the file name prefix
308
+ * And <HTTP method>#<url>#<body text> concatenated as file name suffix key
309
+ * (which then is SHA256 hashed and the hash is used as the actual file name suffix).
310
+ *
311
+ * Use cases (not limited to):
312
+ * 1. if a request body has a dynamic random id or timestamp, you can remove it from
313
+ * cache key computation
314
+ * 2. if a specific test does not use the default snapshot, you can prefix the snapshot
315
+ * file name for the test.
316
+ *
317
+ * WARNING: Attaching a function on a per-test basis may not be concurrent safe. i.e. If you tests
318
+ * run sequentially, then it is safe. But if your test runner runs test suites concurrently,
319
+ * then it is better to attach a function only once ever.
320
+ * @param {(req: Request) => Promise<{ filePrefix: string, fileSuffixKey: string }>} func
321
+ */
287
322
  function attachSnapshotFilenameGenerator(func) {
288
323
  snapshotFileNameGenerator = func;
289
324
  }
290
325
 
291
- // Reset snapshot filename generator to default
326
+ /** Reset snapshot filename generator to default */
292
327
  function resetSnapshotFilenameGenerator() {
293
328
  snapshotFileNameGenerator = defaultSnapshotFileNameGenerator;
294
329
  }
295
330
 
296
- // Attach response transformer function
331
+ /**
332
+ * Attach response transformer function.
333
+ *
334
+ * Here is an opportunity to modify the response (loaded from snapshot) on-the-fly right before
335
+ * the response is sent to consumers.
336
+ *
337
+ * WARNING: Attaching a function on a per-test basis may not be concurrent safe. i.e. If you tests
338
+ * run sequentially, then it is safe. But if your test runner runs test suites concurrently,
339
+ * then it is better to attach a function only once ever.
340
+ * @param {(response: Response, request: Request) => Promise<Response>} func
341
+ */
297
342
  function attachResponseTransformer(func) {
298
343
  responseTransformer = func;
299
344
  }
300
345
 
301
- // Reset response transformer
346
+ /** Reset response transformer */
302
347
  function resetResponseTransformer() {
303
348
  responseTransformer = identity;
304
349
  }
305
350
 
306
- // Start the interceptor
351
+ /**
352
+ * Start the interceptor
353
+ * @param {object} opts
354
+ * @param {string|null} opts.snapshotDirectory Full absolute path to snapshot directory
355
+ */
307
356
  function start({
308
357
  snapshotDirectory: _snapshotDirectory = null,
309
358
  } = { snapshotDirectory: null }) {
@@ -311,6 +360,9 @@ function start({
311
360
  throw new Error('Please specify full path to a directory for storing/reading snapshots');
312
361
  }
313
362
  snapshotDirectory = _snapshotDirectory;
363
+ /**
364
+ * @type {Promise<any>|undefined}
365
+ */
314
366
  let dirCreatePromise;
315
367
 
316
368
  interceptor = new BatchInterceptor({
@@ -321,37 +373,43 @@ function start({
321
373
  ],
322
374
  });
323
375
 
376
+ // @ts-ignore
324
377
  interceptor.on('request', async ({ request }) => {
325
378
  if (SNAPSHOT === 'read') {
326
379
  await enforceSnapshotResponse(request);
327
380
  }
328
381
  });
329
- interceptor.on('response', async ({ request, response }) => {
330
- if (SNAPSHOT === 'update') {
331
- if (!dirCreatePromise) {
332
- dirCreatePromise = fs.mkdir(snapshotDirectory, { recursive: true });
382
+ interceptor.on(
383
+ // @ts-ignore
384
+ 'response',
385
+ /** @type {(params: { request: Request, response: Response }) => Promise<void>} */
386
+ async ({ request, response }) => {
387
+ if (SNAPSHOT === 'update') {
388
+ if (!dirCreatePromise) {
389
+ dirCreatePromise = fs.mkdir( /** @type {string} */(snapshotDirectory), { recursive: true });
390
+ }
391
+ await dirCreatePromise;
392
+ saveSnapshot(request, response);
333
393
  }
334
- await dirCreatePromise;
335
- saveSnapshot(request, response);
336
- }
337
- if (LOG_REQ) {
338
- const { fileName, fileSuffixKey } = await getSnapshotFileName(request);
339
- console.debug('Request', {
340
- request: {
341
- url: request.url,
342
- method: request.method,
343
- headers: Object.fromEntries([...request.headers.entries()]),
344
- body: await request.clone().text(),
345
- },
346
- wouldBeFileName: fileName,
347
- wouldBeFileSuffixKey: fileSuffixKey,
348
- });
349
- }
350
- });
394
+ if (LOG_REQ) {
395
+ const { fileName, fileSuffixKey } = await getSnapshotFileName(request);
396
+ console.debug('Request', {
397
+ request: {
398
+ url: request.url,
399
+ method: request.method,
400
+ headers: Object.fromEntries([...request.headers.entries()]),
401
+ body: await request.clone().text(),
402
+ },
403
+ wouldBeFileName: fileName,
404
+ wouldBeFileSuffixKey: fileSuffixKey,
405
+ });
406
+ }
407
+ },
408
+ );
351
409
  interceptor.apply();
352
410
  }
353
411
 
354
- // Stop the interceptor
412
+ /** Stop the interceptor */
355
413
  function stop() {
356
414
  if (interceptor) {
357
415
  interceptor.dispose();
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "http-snapshotter",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Snapshot HTTP requests for tests (node.js)",
5
5
  "main": "index.cjs",
6
+ "types": "index.d.ts",
6
7
  "exports": {
7
8
  "import": "./index.mjs",
8
9
  "require": "./index.js"
9
10
  },
10
11
  "scripts": {
11
- "test": "tape tests/**/*.test.* | tap-diff"
12
+ "test": "tape tests/**/*.test.* | tap-diff",
13
+ "tsc": "tsc"
12
14
  },
13
15
  "keywords": [
14
16
  "snapshot",
@@ -25,6 +27,7 @@
25
27
  "@sindresorhus/slugify": "^1.1.2"
26
28
  },
27
29
  "devDependencies": {
30
+ "@types/node": "^20.6.2",
28
31
  "tap-diff": "^0.1.1",
29
32
  "tape": "^5.6.6",
30
33
  "typescript": "^5.2.2"
@@ -0,0 +1,76 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
+
5
+ /* Basic Options */
6
+ // "incremental": true, /* Enable incremental compilation */
7
+ "target": "ESNext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
8
+ "module": "nodenext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9
+ // "lib": [], /* Specify library files to be included in the compilation. */
10
+ "allowJs": true, /* Allow javascript files to be compiled. */
11
+ "checkJs": true, /* Report errors in .js files. */
12
+ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
13
+ "declaration": true, /* Generates corresponding '.d.ts' file. */
14
+ "emitDeclarationOnly": true, /* Generates only a '.d.ts' file. */
15
+ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
16
+ // "sourceMap": true, /* Generates corresponding '.map' file. */
17
+ // "outFile": "./", /* Concatenate and emit output to single file. */
18
+ // "outDir": "./", /* Redirect output structure to the directory. */
19
+ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
20
+ // "composite": true, /* Enable project compilation */
21
+ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
22
+ // "removeComments": true, /* Do not emit comments to output. */
23
+ // "noEmit": true, /* Do not emit outputs. */
24
+ "noEmitOnError": true, /* Don't generate on error. */
25
+ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
26
+ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
27
+ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
28
+
29
+ /* Strict Type-Checking Options */
30
+ "strict": true, /* Enable all strict type-checking options. */
31
+ "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
32
+ "strictNullChecks": true, /* Enable strict null checks. */
33
+ "strictFunctionTypes": true, /* Enable strict checking of function types. */
34
+ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
35
+ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
36
+ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
37
+ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
38
+
39
+ /* Additional Checks */
40
+ "noUnusedLocals": true, /* Report errors on unused locals. */
41
+ // "noUnusedParameters": true, /* Report errors on unused parameters. */
42
+ "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
43
+ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
44
+
45
+ /* Module Resolution Options */
46
+ "moduleResolution": "NodeNext", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
47
+ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
48
+ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
49
+ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
50
+ "typeRoots": [
51
+ "./node_modules/@types"
52
+ ], /* List of folders to include type definitions from. */
53
+ // "types": [], /* Type declaration files to be included in compilation. */
54
+ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
55
+ "esModuleInterop": false, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
56
+ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
57
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
58
+
59
+ /* Source Map Options */
60
+ // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
61
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
62
+ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
63
+ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
64
+
65
+ /* Experimental Options */
66
+ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
67
+ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
68
+
69
+ /* Advanced Options */
70
+ "skipLibCheck": true, /* Skip type checking of declaration files. */
71
+ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
72
+ },
73
+ "include": [
74
+ "src/index.js"
75
+ ]
76
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,114 @@
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": "ESNext", /* 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": "NodeNext", /* Specify what module code is generated. */
29
+ // "rootDir": "./", /* 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": [
35
+ "./node_modules/@types"
36
+ ], /* Specify multiple folders that act like './node_modules/@types'. */
37
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
38
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
39
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
40
+ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
41
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
42
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
43
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
44
+ // "resolveJsonModule": true, /* Enable importing .json files. */
45
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
46
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
47
+
48
+ /* JavaScript Support */
49
+ "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
50
+ "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
51
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
52
+
53
+ /* Emit */
54
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
55
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
56
+ "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
57
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
58
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
59
+ // "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. */
60
+ // "outDir": "./", /* Specify an output folder for all emitted files. */
61
+ // "removeComments": true, /* Disable emitting comments. */
62
+ // "noEmit": true, /* Disable emitting files from a compilation. */
63
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
64
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
65
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
66
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
67
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
68
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
69
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
70
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
71
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
72
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
73
+ "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
74
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
75
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
76
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
77
+
78
+ /* Interop Constraints */
79
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
80
+ // "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. */
81
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
82
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
83
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
84
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
85
+
86
+ /* Type Checking */
87
+ "strict": true, /* Enable all strict type-checking options. */
88
+ "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
89
+ "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
90
+ "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
91
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
92
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
93
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
94
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
95
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
96
+ "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
97
+ "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
98
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
99
+ "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
100
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
101
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
102
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
103
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
104
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
105
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
106
+
107
+ /* Completeness */
108
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
109
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
110
+ },
111
+ "include": [
112
+ "index.js"
113
+ ]
114
+ }