grofc_utils 1.0.0 → 1.1.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/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './src/array.js';
2
2
  export * from './src/guard.js';
3
3
  export * from './src/missingData.js';
4
+ export * from './src/object.js';
4
5
  export * from './src/random.js';
5
6
  export * from './src/string.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grofc_utils",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,6 +26,10 @@
26
26
  "import": "./src/missingData.js",
27
27
  "types": "./types/src/missingData.d.ts"
28
28
  },
29
+ "./object": {
30
+ "import": "./src/object.js",
31
+ "types": "./types/src/object.d.ts"
32
+ },
29
33
  "./random": {
30
34
  "import": "./src/random.js",
31
35
  "types": "./types/src/random.d.ts"
@@ -40,6 +44,14 @@
40
44
  "license": "ISC",
41
45
  "type": "module",
42
46
  "devDependencies": {
47
+ "@eslint/js": "^9.39.1",
48
+ "eslint": "^9.39.1",
49
+ "globals": "^16.5.0",
43
50
  "vitest": "^4.0.6"
44
- }
51
+ },
52
+ "files": [
53
+ "index.js",
54
+ "/src",
55
+ "/types"
56
+ ]
45
57
  }
package/src/guard.js CHANGED
@@ -204,6 +204,30 @@ export function throwIfIsNotNonNegativeInteger(variable, name = "variable") {
204
204
  throwRangeErrorGiveValue(variable, name, "a non-negative integer");
205
205
  }
206
206
  }
207
+ //
208
+ // 字符串类型守卫函数
209
+ //
210
+ export function throwIfIsNotString(variable, name = "variable") {
211
+ if (typeof variable !== "string") {
212
+ throwTypeErrorGiveType(variable, name, "string")
213
+ }
214
+ }
215
+ //
216
+ // symbol类型守卫函数
217
+ //
218
+ export function throwIfIsNotSymbol(variable, name = "variable") {
219
+ if (typeof variable !== "symbol") {
220
+ throwTypeErrorGiveType(variable, name, "symbol")
221
+ }
222
+ }
223
+ //
224
+ // bigint类型守卫函数
225
+ //
226
+ export function throwIfIsNotBigInt(variable, name = "variable") {
227
+ if (typeof variable !== "bigint") {
228
+ throwTypeErrorGiveType(variable, name, "bigint")
229
+ }
230
+ }
207
231
  // ------------------------------------------------
208
232
  // 对象类型守卫函数
209
233
  // ------------------------------------------------
@@ -218,10 +242,25 @@ export function throwIfIsNotPlainObject(variable, name = "variable") {
218
242
  throwTypeErrorGiveType(variable, name, "a plain object");
219
243
  }
220
244
  }
245
+ /**
246
+ * 检查对象是否包含指定的键
247
+ * @param {*} variable - 要检查的对象
248
+ * @param {string} key - 要检查的键名
249
+ * @param {string} name - 变量名称(用于错误消息)
250
+ * @throws {TypeError} 当variable不是普通对象或key不是字符串时抛出类型错误
251
+ * @throws {Error} 当对象中找不到指定键时抛出错误
252
+ */
253
+ export function throwIfKeyMissing(variable, key, name = "variable") {
254
+ throwIfIsNotPlainObject(variable);
255
+ throwIfIsNotString(key);
256
+ if (!(key in variable)) {
257
+ throw new Error(`Expected ${name} to have key : "${key}", but cannot find.`)
258
+ }
259
+ }
221
260
  /**
222
261
  * 检查对象是否缺少所有指定的键
223
262
  * @param {*} variable - 要检查的对象
224
- * @param {string|string[]} keys - 要检查的键名或键名数组
263
+ * @param {string[]} keys - 要检查的键名数组
225
264
  * @param {string} name - 变量名称(用于错误消息)
226
265
  * @throws {TypeError} 当 variable 不是普通对象时抛出类型错误
227
266
  * @throws {GuardError} 当 keys 不是字符串或字符串数组时抛出守卫错误
@@ -229,18 +268,15 @@ export function throwIfIsNotPlainObject(variable, name = "variable") {
229
268
  */
230
269
  export function throwIfAllKeysMissing(variable, keys, name = "variable") {
231
270
  throwIfIsNotPlainObject(variable);
232
- if (!Array.isArray(keys)) {
233
- if (typeof keys === "string") keys = [keys];
234
- else safeGuardExecute(throwTypeErrorGiveType, keys, name, "string", "an array of string");
235
- }
271
+ safeGuardExecute(throwIfIsNotStringArray, keys, name, "an array of string");
236
272
  if (keys.every(key => !(key in variable))) {
237
- throw new Error(`Expected ${name} to have at least one attribute of [${keys.map(k => `'${k}'`).join(" ,")}], but cannot find.`)
273
+ throw new Error(`Expected ${name} to have at least one keys of [${keys.map(k => `'${k}'`).join(" ,")}], but cannot find.`)
238
274
  }
239
275
  }
240
276
  /**
241
277
  * 检查对象是否缺少任意指定的键
242
278
  * @param {*} variable - 要检查的对象
243
- * @param {string|string[]} keys - 要检查的键名或键名数组
279
+ * @param {string[]} keys - 要检查的键名数组
244
280
  * @param {string} name - 变量名称(用于错误消息)
245
281
  * @throws {TypeError} 当 variable 不是普通对象时抛出类型错误
246
282
  * @throws {GuardError} 当 keys 不是字符串或字符串数组时抛出守卫错误
@@ -248,13 +284,58 @@ export function throwIfAllKeysMissing(variable, keys, name = "variable") {
248
284
  */
249
285
  export function throwIfSomeKeysMissing(variable, keys, name = "variable") {
250
286
  throwIfIsNotPlainObject(variable);
251
- if (!Array.isArray(keys)) {
252
- if (typeof keys === "string") keys = [keys];
253
- else safeGuardExecute(throwTypeErrorGiveType, keys, name, "string", "an array of string");
254
- }
287
+ safeGuardExecute(throwIfIsNotStringArray, keys, name, "an array of string");
255
288
  const l = keys.filter(key => !(key in variable))
256
289
  if (l.length) {
257
- throw new Error(`Expected ${name} to have at all attributes of [${keys.map(k => `'${k}'`).join(" ,")}], but missing [${l.map(k => `'${k}'`).join(" ,")}].`)
290
+ throw new Error(`Expected ${name} to have at all keys of [${keys.map(k => `'${k}'`).join(" ,")}], but missing [${l.map(k => `'${k}'`).join(" ,")}].`)
291
+ }
292
+ }
293
+ /**
294
+ * 检查对象是否包含指定的键
295
+ * @param {*} variable - 要检查的对象
296
+ * @param {string} property - 要检查的键名
297
+ * @param {string} name - 变量名称(用于错误消息)
298
+ * @throws {TypeError} 当variable不是普通对象或property不是字符串时抛出类型错误
299
+ * @throws {Error} 当对象中找不到指定键时抛出错误
300
+ */
301
+ export function throwIfOwnPropertyMissing(variable, property, name = "variable") {
302
+ throwIfIsNotPlainObject(variable);
303
+ throwIfIsNotString(property);
304
+ if (Object.hasOwn(variable, property)) {
305
+ throw new Error(`Expected ${name} to have own property : "${property}", but cannot find.`)
306
+ }
307
+ }
308
+ /**
309
+ * 检查对象是否缺少所有指定的键
310
+ * @param {*} variable - 要检查的对象
311
+ * @param {string[]}properties- 要检查的键名数组
312
+ * @param {string} name - 变量名称(用于错误消息)
313
+ * @throws {TypeError} 当 variable 不是普通对象时抛出类型错误
314
+ * @throws {GuardError} 当properties不是字符串或字符串数组时抛出守卫错误
315
+ * @throws {Error} 当对象缺少所有指定键时抛出错误
316
+ */
317
+ export function throwIfAllOwnPropertiesMissing(variable, properties, name = "variable") {
318
+ throwIfIsNotPlainObject(variable);
319
+ safeGuardExecute(throwIfIsNotStringArray, properties, name, "an array of string");
320
+ if (properties.every(p => !Object.hasOwn(variable, p))) {
321
+ throw new Error(`Expected ${name} to have at least one own property of [${properties.map(k => `'${k}'`).join(" ,")}], but cannot find.`)
322
+ }
323
+ }
324
+ /**
325
+ * 检查对象是否缺少任意指定的键
326
+ * @param {*} variable - 要检查的对象
327
+ * @param {string[]} properties - 要检查的键名数组
328
+ * @param {string} name - 变量名称(用于错误消息)
329
+ * @throws {TypeError} 当 variable 不是普通对象时抛出类型错误
330
+ * @throws {GuardError} 当 properties 不是字符串或字符串数组时抛出守卫错误
331
+ * @throws {Error} 当对象缺少任何一个指定键时抛出错误
332
+ */
333
+ export function throwIfSomeOwnPropertiesMissing(variable, properties, name = "variable") {
334
+ throwIfIsNotPlainObject(variable);
335
+ safeGuardExecute(throwIfIsNotStringArray, properties, name, "an array of string");
336
+ const l = properties.filter(p => !Object.hasOwn(variable, p))
337
+ if (l.length) {
338
+ throw new Error(`Expected ${name} to have at all own properties of [${properties.map(k => `'${k}'`).join(" ,")}], but missing [${l.map(k => `'${k}'`).join(" ,")}].`)
258
339
  }
259
340
  }
260
341
  // ------------------------------------------------
@@ -311,6 +392,25 @@ export function throwIfIsNotNonEmptyArray(variable, name = "variable") {
311
392
  throwRangeErrorGiveValue(variable, name, "a non-empty array");
312
393
  }
313
394
  }
395
+
396
+ export function throwIfIsNotStringArray(variable, name = "variable", generalTerm = `all elements of ${name || "array"}`) {
397
+ throwIfIsNotArray(variable, name);
398
+ const acceptType = "strings";
399
+ for (const e of variable) {
400
+ if (typeof e !== "string") {
401
+ throwTypeErrorForArray(generalTerm, acceptType, `a non-string value of type ${getType(e)}`)
402
+ }
403
+ }
404
+ }
405
+ export function throwIfIsNotNumberArray(variable, name = "variable", generalTerm = `all elements of ${name || "array"}`) {
406
+ throwIfIsNotArray(variable, name);
407
+ const acceptType = "numbers";
408
+ for (const e of variable) {
409
+ if (typeof e !== "number") {
410
+ throwTypeErrorForArray(generalTerm, acceptType, `a non-number value of type ${getType(e)}`)
411
+ }
412
+ }
413
+ }
314
414
  /**
315
415
  * 检查变量是否为仅包含非NaN数字的数组,如果不是则抛出类型错误
316
416
  *
package/src/object.js ADDED
@@ -0,0 +1,13 @@
1
+ import { throwIfIsNotPlainObject, throwIfKeyMissing } from "./guard";
2
+
3
+ export function setReadOnlyProperty(obj, name) {
4
+ throwIfIsNotPlainObject(obj);
5
+ throwIfKeyMissing(obj, name, "obj");
6
+ const descriptor = Object.getOwnPropertyDescriptor(obj, name);
7
+ Object.defineProperty(obj, name, {
8
+ value: descriptor.value,
9
+ writable: false,
10
+ configurable: false,
11
+ enumerable: descriptor.enumerable ?? true
12
+ })
13
+ }
package/src/random.js CHANGED
@@ -151,7 +151,7 @@ export function randomVectors(len, dim = 2, mod = 1, generator = randomGaussian)
151
151
  * @param {(r: number, c: number) => number} generator 用于生成矩阵元素的函数,接收行列索引作为参数,默认生成0-10的随机整数
152
152
  * @returns {number[][]} 二维数组表示的矩阵,大小为rows×cols
153
153
  */
154
- export function randomMatrix(rows = 2, cols = rows, generator = (_r, _c) => randomInt(0, 10)) {
154
+ export function randomMatrix(rows = 2, cols = rows, generator = () => randomInt(0, 10)) {
155
155
  throwIfIsNotNonNegativeInteger(rows, "rows");
156
156
  throwIfIsNotNonNegativeInteger(cols, "cols");
157
157
  throwIfIsNotFunction(generator, "generator");
@@ -166,7 +166,7 @@ export function randomMatrix(rows = 2, cols = rows, generator = (_r, _c) => rand
166
166
  * @param {(r: number, c: number) => number} generator 用于生成矩阵元素的函数,接收行列索引作为参数,默认生成0-10的随机整数
167
167
  * @returns {number[][][]} 包含len个矩阵的数组,每个矩阵都是二维数组
168
168
  */
169
- export function randomMatrices(len, rows = 2, cols = rows, generator = (_r, _c) => randomInt(0, 10)) {
169
+ export function randomMatrices(len, rows = 2, cols = rows, generator = () => randomInt(0, 10)) {
170
170
  throwIfIsNotNonNegativeInteger(len, "len");
171
171
  return Array.from({ length: len }, () => randomMatrix(rows, cols, generator))
172
172
  }
package/types/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./src/array.js";
2
2
  export * from "./src/guard.js";
3
3
  export * from "./src/missingData.js";
4
+ export * from "./src/object.js";
4
5
  export * from "./src/random.js";
5
6
  export * from "./src/string.js";
@@ -82,6 +82,9 @@ export function throwIfIsNotNegativeInteger(variable: any, name?: string): void;
82
82
  * @throws {RangeError} 当变量不是非负整数时抛出范围错误
83
83
  */
84
84
  export function throwIfIsNotNonNegativeInteger(variable: any, name?: string): void;
85
+ export function throwIfIsNotString(variable: any, name?: string): void;
86
+ export function throwIfIsNotSymbol(variable: any, name?: string): void;
87
+ export function throwIfIsNotBigInt(variable: any, name?: string): void;
85
88
  /**
86
89
  * 检查变量是否为普通对象(非 null,非数组)
87
90
  * @param {*} variable - 要检查的变量
@@ -89,26 +92,64 @@ export function throwIfIsNotNonNegativeInteger(variable: any, name?: string): vo
89
92
  * @throws {TypeError} 当变量不是普通对象时抛出类型错误
90
93
  */
91
94
  export function throwIfIsNotPlainObject(variable: any, name?: string): void;
95
+ /**
96
+ * 检查对象是否包含指定的键
97
+ * @param {*} variable - 要检查的对象
98
+ * @param {string} key - 要检查的键名
99
+ * @param {string} name - 变量名称(用于错误消息)
100
+ * @throws {TypeError} 当variable不是普通对象或key不是字符串时抛出类型错误
101
+ * @throws {Error} 当对象中找不到指定键时抛出错误
102
+ */
103
+ export function throwIfKeyMissing(variable: any, key: string, name?: string): void;
92
104
  /**
93
105
  * 检查对象是否缺少所有指定的键
94
106
  * @param {*} variable - 要检查的对象
95
- * @param {string|string[]} keys - 要检查的键名或键名数组
107
+ * @param {string[]} keys - 要检查的键名数组
96
108
  * @param {string} name - 变量名称(用于错误消息)
97
109
  * @throws {TypeError} 当 variable 不是普通对象时抛出类型错误
98
110
  * @throws {GuardError} 当 keys 不是字符串或字符串数组时抛出守卫错误
99
111
  * @throws {Error} 当对象缺少所有指定键时抛出错误
100
112
  */
101
- export function throwIfAllKeysMissing(variable: any, keys: string | string[], name?: string): void;
113
+ export function throwIfAllKeysMissing(variable: any, keys: string[], name?: string): void;
102
114
  /**
103
115
  * 检查对象是否缺少任意指定的键
104
116
  * @param {*} variable - 要检查的对象
105
- * @param {string|string[]} keys - 要检查的键名或键名数组
117
+ * @param {string[]} keys - 要检查的键名数组
106
118
  * @param {string} name - 变量名称(用于错误消息)
107
119
  * @throws {TypeError} 当 variable 不是普通对象时抛出类型错误
108
120
  * @throws {GuardError} 当 keys 不是字符串或字符串数组时抛出守卫错误
109
121
  * @throws {Error} 当对象缺少任何一个指定键时抛出错误
110
122
  */
111
- export function throwIfSomeKeysMissing(variable: any, keys: string | string[], name?: string): void;
123
+ export function throwIfSomeKeysMissing(variable: any, keys: string[], name?: string): void;
124
+ /**
125
+ * 检查对象是否包含指定的键
126
+ * @param {*} variable - 要检查的对象
127
+ * @param {string} property - 要检查的键名
128
+ * @param {string} name - 变量名称(用于错误消息)
129
+ * @throws {TypeError} 当variable不是普通对象或property不是字符串时抛出类型错误
130
+ * @throws {Error} 当对象中找不到指定键时抛出错误
131
+ */
132
+ export function throwIfOwnPropertyMissing(variable: any, property: string, name?: string): void;
133
+ /**
134
+ * 检查对象是否缺少所有指定的键
135
+ * @param {*} variable - 要检查的对象
136
+ * @param {string[]}properties- 要检查的键名数组
137
+ * @param {string} name - 变量名称(用于错误消息)
138
+ * @throws {TypeError} 当 variable 不是普通对象时抛出类型错误
139
+ * @throws {GuardError} 当properties不是字符串或字符串数组时抛出守卫错误
140
+ * @throws {Error} 当对象缺少所有指定键时抛出错误
141
+ */
142
+ export function throwIfAllOwnPropertiesMissing(variable: any, properties: any, name?: string): void;
143
+ /**
144
+ * 检查对象是否缺少任意指定的键
145
+ * @param {*} variable - 要检查的对象
146
+ * @param {string[]} properties - 要检查的键名数组
147
+ * @param {string} name - 变量名称(用于错误消息)
148
+ * @throws {TypeError} 当 variable 不是普通对象时抛出类型错误
149
+ * @throws {GuardError} 当 properties 不是字符串或字符串数组时抛出守卫错误
150
+ * @throws {Error} 当对象缺少任何一个指定键时抛出错误
151
+ */
152
+ export function throwIfSomeOwnPropertiesMissing(variable: any, properties: string[], name?: string): void;
112
153
  /**
113
154
  * 检查变量是否为函数类型,如果不是则抛出类型错误
114
155
  * @param {*} variable - 要检查的变量
@@ -132,6 +173,8 @@ export function throwIfIsNotIterable(variable: any, name?: string): void;
132
173
  export function throwIfIsNotIterableObject(variable: any, name?: string): void;
133
174
  export function throwIfIsNotArray(variable: any, name?: string): void;
134
175
  export function throwIfIsNotNonEmptyArray(variable: any, name?: string): void;
176
+ export function throwIfIsNotStringArray(variable: any, name?: string, generalTerm?: string): void;
177
+ export function throwIfIsNotNumberArray(variable: any, name?: string, generalTerm?: string): void;
135
178
  /**
136
179
  * 检查变量是否为仅包含非NaN数字的数组,如果不是则抛出类型错误
137
180
  *
@@ -0,0 +1 @@
1
+ export function setReadOnlyProperty(obj: any, name: any): void;
@@ -1,51 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
- const projectRoot = path.resolve(__dirname);
8
-
9
- function generateExports() {
10
- const srcDir = path.join(projectRoot, 'src');
11
-
12
- // 获取src目录下所有的js文件
13
- const jsFiles = fs.readdirSync(srcDir)
14
- .filter(file => fs.statSync(path.join(srcDir, file)).isFile() && path.extname(file) === '.js')
15
- .map(file => path.basename(file, '.js'))
16
- .sort();
17
-
18
- // 生成 index.js 内容
19
- const exportLines = jsFiles.map(file => `export * from './src/${file}.js';`);
20
- const indexContent = exportLines.join('\n') + '\n';
21
-
22
- // 写入 index.js 文件
23
- fs.writeFileSync(path.join(projectRoot, 'index.js'), indexContent);
24
- console.log('index.js 文件已生成');
25
-
26
- // 构建 package.json 的 exports 字段
27
- const exports = {
28
- ".": {
29
- "import": "./index.js",
30
- "types": "./types/index.d.ts"
31
- }
32
- };
33
-
34
- // 为每个文件添加导出配置
35
- jsFiles.forEach(file => {
36
- exports[`./${file}`] = {
37
- "import": `./src/${file}.js`,
38
- "types": `./types/src/${file}.d.ts`
39
- };
40
- });
41
-
42
- // 更新 package.json
43
- const packagePath = path.join(projectRoot, 'package.json');
44
- const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
45
- packageJson.exports = exports;
46
- fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2) + '\n');
47
-
48
- console.log('Exports 字段已更新');
49
- }
50
-
51
- generateExports();
package/readme.md DELETED
@@ -1,4 +0,0 @@
1
- ### 如何使用?
2
- ```
3
- npm install github:xinyuan-noname/grofc_utils
4
- ```
package/tsconfig.json DELETED
@@ -1,112 +0,0 @@
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": "es2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
- // "jsx": "preserve", /* Specify what JSX code is generated. */
17
- // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
18
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
- // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
- // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
-
27
- /* Modules */
28
- "module": "commonjs", /* Specify what module code is generated. */
29
- // "rootDir": "./", /* Specify the root folder within your source files. */
30
- // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
31
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
- // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
- // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
- // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
39
- // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
40
- // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
41
- // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
42
- // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
43
- // "noUncheckedSideEffectImports": true, /* Check side effect 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
- // "noEmit": true, /* Disable emitting files from a compilation. */
60
- // "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. */
61
- "outDir": "./types", /* Specify an output folder for all emitted files. */
62
- // "removeComments": true, /* Disable emitting comments. */
63
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
64
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
65
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
66
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
67
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
68
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
69
- // "newLine": "crlf", /* Set the newline character for emitting files. */
70
- // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
71
- // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
72
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
73
- // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
74
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
75
-
76
- /* Interop Constraints */
77
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
78
- // "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. */
79
- // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
80
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
81
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
82
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
83
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
84
-
85
- /* Type Checking */
86
- "strict": true, /* Enable all strict type-checking options. */
87
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
88
- // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
89
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
90
- // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
91
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
92
- // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
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
- "exclude": ["./src","types","./generate.exports.js"]
112
- }