mathjs 11.3.0 → 11.3.2

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.
@@ -18,6 +18,9 @@ var _array = require("../../utils/array.js");
18
18
  var _latex = require("../../utils/latex.js");
19
19
  var _operators = require("../operators.js");
20
20
  var _factory = require("../../utils/factory.js");
21
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
22
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
21
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
22
25
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
23
26
  var name = 'FunctionAssignmentNode';
@@ -69,6 +72,24 @@ var createFunctionAssignmentNode = /* #__PURE__ */(0, _factory.factory)(name, de
69
72
  if (_keywords.keywords.has(name)) {
70
73
  throw new Error('Illegal function name, "' + name + '" is a reserved keyword');
71
74
  }
75
+ var paramNames = new Set();
76
+ var _iterator = _createForOfIteratorHelper(params),
77
+ _step;
78
+ try {
79
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
80
+ var param = _step.value;
81
+ var _name = typeof param === 'string' ? param : param.name;
82
+ if (paramNames.has(_name)) {
83
+ throw new Error("Duplicate parameter name \"".concat(_name, "\""));
84
+ } else {
85
+ paramNames.add(_name);
86
+ }
87
+ }
88
+ } catch (err) {
89
+ _iterator.e(err);
90
+ } finally {
91
+ _iterator.f();
92
+ }
72
93
  _this.name = name;
73
94
  _this.params = params.map(function (param) {
74
95
  return param && param.name || param;
package/lib/cjs/header.js CHANGED
@@ -6,8 +6,8 @@
6
6
  * It features real and complex numbers, units, matrices, a large set of
7
7
  * mathematical functions, and a flexible expression parser.
8
8
  *
9
- * @version 11.3.0
10
- * @date 2022-10-11
9
+ * @version 11.3.2
10
+ * @date 2022-10-25
11
11
  *
12
12
  * @license
13
13
  * Copyright (C) 2013-2022 Jos de Jong <wjosdejong@gmail.com>
@@ -2753,56 +2753,56 @@ var createUnitClass = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
2753
2753
  K: {
2754
2754
  name: 'K',
2755
2755
  base: BASE_UNITS.TEMPERATURE,
2756
- prefixes: PREFIXES.NONE,
2756
+ prefixes: PREFIXES.SHORT,
2757
2757
  value: 1,
2758
2758
  offset: 0
2759
2759
  },
2760
2760
  degC: {
2761
2761
  name: 'degC',
2762
2762
  base: BASE_UNITS.TEMPERATURE,
2763
- prefixes: PREFIXES.NONE,
2763
+ prefixes: PREFIXES.SHORT,
2764
2764
  value: 1,
2765
2765
  offset: 273.15
2766
2766
  },
2767
2767
  degF: {
2768
2768
  name: 'degF',
2769
2769
  base: BASE_UNITS.TEMPERATURE,
2770
- prefixes: PREFIXES.NONE,
2770
+ prefixes: PREFIXES.SHORT,
2771
2771
  value: 1 / 1.8,
2772
2772
  offset: 459.67
2773
2773
  },
2774
2774
  degR: {
2775
2775
  name: 'degR',
2776
2776
  base: BASE_UNITS.TEMPERATURE,
2777
- prefixes: PREFIXES.NONE,
2777
+ prefixes: PREFIXES.SHORT,
2778
2778
  value: 1 / 1.8,
2779
2779
  offset: 0
2780
2780
  },
2781
2781
  kelvin: {
2782
2782
  name: 'kelvin',
2783
2783
  base: BASE_UNITS.TEMPERATURE,
2784
- prefixes: PREFIXES.NONE,
2784
+ prefixes: PREFIXES.LONG,
2785
2785
  value: 1,
2786
2786
  offset: 0
2787
2787
  },
2788
2788
  celsius: {
2789
2789
  name: 'celsius',
2790
2790
  base: BASE_UNITS.TEMPERATURE,
2791
- prefixes: PREFIXES.NONE,
2791
+ prefixes: PREFIXES.LONG,
2792
2792
  value: 1,
2793
2793
  offset: 273.15
2794
2794
  },
2795
2795
  fahrenheit: {
2796
2796
  name: 'fahrenheit',
2797
2797
  base: BASE_UNITS.TEMPERATURE,
2798
- prefixes: PREFIXES.NONE,
2798
+ prefixes: PREFIXES.LONG,
2799
2799
  value: 1 / 1.8,
2800
2800
  offset: 459.67
2801
2801
  },
2802
2802
  rankine: {
2803
2803
  name: 'rankine',
2804
2804
  base: BASE_UNITS.TEMPERATURE,
2805
- prefixes: PREFIXES.NONE,
2805
+ prefixes: PREFIXES.LONG,
2806
2806
  value: 1 / 1.8,
2807
2807
  offset: 0
2808
2808
  },
@@ -3677,14 +3677,9 @@ var createUnitClass = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
3677
3677
  * base unit, the name of the newly create base unit. Otherwise, this property
3678
3678
  * has no effect.
3679
3679
  *
3680
- * @param {Object} options (optional) An object containing any of the following
3681
- * properties:
3682
- * - override {boolean} Whether this unit should be allowed to override existing
3683
- * units.
3684
- *
3685
3680
  * @return {Unit}
3686
3681
  */
3687
- Unit.createUnitSingle = function (name, obj, options) {
3682
+ Unit.createUnitSingle = function (name, obj) {
3688
3683
  if (typeof obj === 'undefined' || obj === null) {
3689
3684
  obj = {};
3690
3685
  }
@@ -24,7 +24,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
24
24
  * forwarding on to the SafeProperty functions. Over time, the codebase
25
25
  * will stop using this method, as all objects will be Maps, rather than
26
26
  * more security prone objects.
27
- */var ObjectWrappingMap = /*#__PURE__*/function () {
27
+ */
28
+ var ObjectWrappingMap = /*#__PURE__*/function () {
28
29
  function ObjectWrappingMap(object) {
29
30
  (0, _classCallCheck2["default"])(this, ObjectWrappingMap);
30
31
  this.wrappedObject = object;
@@ -52,11 +53,12 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
52
53
  }
53
54
  }]);
54
55
  return ObjectWrappingMap;
55
- }(); /**
56
- * Creates an empty map, or whatever your platform's polyfill is.
57
- *
58
- * @returns an empty Map or Map like object.
59
- */
56
+ }();
57
+ /**
58
+ * Creates an empty map, or whatever your platform's polyfill is.
59
+ *
60
+ * @returns an empty Map or Map like object.
61
+ */
60
62
  exports.ObjectWrappingMap = ObjectWrappingMap;
61
63
  function createEmptyMap() {
62
64
  return new Map();
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- var version = '11.3.0';
7
+ var version = '11.3.2';
8
8
  // Note: This file is automatically generated when building math.js.
9
9
  // Changes made in this file will be overwritten.
10
10
  exports.version = version;
@@ -53,6 +53,15 @@ export var createFunctionAssignmentNode = /* #__PURE__ */factory(name, dependenc
53
53
  if (keywords.has(name)) {
54
54
  throw new Error('Illegal function name, "' + name + '" is a reserved keyword');
55
55
  }
56
+ var paramNames = new Set();
57
+ for (var param of params) {
58
+ var _name = typeof param === 'string' ? param : param.name;
59
+ if (paramNames.has(_name)) {
60
+ throw new Error("Duplicate parameter name \"".concat(_name, "\""));
61
+ } else {
62
+ paramNames.add(_name);
63
+ }
64
+ }
56
65
  this.name = name;
57
66
  this.params = params.map(function (param) {
58
67
  return param && param.name || param;
@@ -2739,56 +2739,56 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
2739
2739
  K: {
2740
2740
  name: 'K',
2741
2741
  base: BASE_UNITS.TEMPERATURE,
2742
- prefixes: PREFIXES.NONE,
2742
+ prefixes: PREFIXES.SHORT,
2743
2743
  value: 1,
2744
2744
  offset: 0
2745
2745
  },
2746
2746
  degC: {
2747
2747
  name: 'degC',
2748
2748
  base: BASE_UNITS.TEMPERATURE,
2749
- prefixes: PREFIXES.NONE,
2749
+ prefixes: PREFIXES.SHORT,
2750
2750
  value: 1,
2751
2751
  offset: 273.15
2752
2752
  },
2753
2753
  degF: {
2754
2754
  name: 'degF',
2755
2755
  base: BASE_UNITS.TEMPERATURE,
2756
- prefixes: PREFIXES.NONE,
2756
+ prefixes: PREFIXES.SHORT,
2757
2757
  value: 1 / 1.8,
2758
2758
  offset: 459.67
2759
2759
  },
2760
2760
  degR: {
2761
2761
  name: 'degR',
2762
2762
  base: BASE_UNITS.TEMPERATURE,
2763
- prefixes: PREFIXES.NONE,
2763
+ prefixes: PREFIXES.SHORT,
2764
2764
  value: 1 / 1.8,
2765
2765
  offset: 0
2766
2766
  },
2767
2767
  kelvin: {
2768
2768
  name: 'kelvin',
2769
2769
  base: BASE_UNITS.TEMPERATURE,
2770
- prefixes: PREFIXES.NONE,
2770
+ prefixes: PREFIXES.LONG,
2771
2771
  value: 1,
2772
2772
  offset: 0
2773
2773
  },
2774
2774
  celsius: {
2775
2775
  name: 'celsius',
2776
2776
  base: BASE_UNITS.TEMPERATURE,
2777
- prefixes: PREFIXES.NONE,
2777
+ prefixes: PREFIXES.LONG,
2778
2778
  value: 1,
2779
2779
  offset: 273.15
2780
2780
  },
2781
2781
  fahrenheit: {
2782
2782
  name: 'fahrenheit',
2783
2783
  base: BASE_UNITS.TEMPERATURE,
2784
- prefixes: PREFIXES.NONE,
2784
+ prefixes: PREFIXES.LONG,
2785
2785
  value: 1 / 1.8,
2786
2786
  offset: 459.67
2787
2787
  },
2788
2788
  rankine: {
2789
2789
  name: 'rankine',
2790
2790
  base: BASE_UNITS.TEMPERATURE,
2791
- prefixes: PREFIXES.NONE,
2791
+ prefixes: PREFIXES.LONG,
2792
2792
  value: 1 / 1.8,
2793
2793
  offset: 0
2794
2794
  },
@@ -3663,14 +3663,9 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
3663
3663
  * base unit, the name of the newly create base unit. Otherwise, this property
3664
3664
  * has no effect.
3665
3665
  *
3666
- * @param {Object} options (optional) An object containing any of the following
3667
- * properties:
3668
- * - override {boolean} Whether this unit should be allowed to override existing
3669
- * units.
3670
- *
3671
3666
  * @return {Unit}
3672
3667
  */
3673
- Unit.createUnitSingle = function (name, obj, options) {
3668
+ Unit.createUnitSingle = function (name, obj) {
3674
3669
  if (typeof obj === 'undefined' || obj === null) {
3675
3670
  obj = {};
3676
3671
  }
@@ -1,3 +1,3 @@
1
- export var version = '11.3.0';
1
+ export var version = '11.3.2';
2
2
  // Note: This file is automatically generated when building math.js.
3
3
  // Changes made in this file will be overwritten.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mathjs",
3
- "version": "11.3.0",
3
+ "version": "11.3.2",
4
4
  "description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
5
5
  "author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
6
6
  "homepage": "https://mathjs.org",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.19.4",
29
29
  "complex.js": "^2.1.1",
30
- "decimal.js": "^10.4.1",
30
+ "decimal.js": "^10.4.2",
31
31
  "escape-latex": "^1.2.0",
32
32
  "fraction.js": "^4.2.0",
33
33
  "javascript-natural-sort": "^0.7.1",
@@ -36,31 +36,31 @@
36
36
  "typed-function": "^4.1.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "7.19.3",
39
+ "@babel/core": "7.19.6",
40
40
  "@babel/plugin-transform-object-assign": "7.18.6",
41
- "@babel/plugin-transform-runtime": "7.19.1",
41
+ "@babel/plugin-transform-runtime": "7.19.6",
42
42
  "@babel/preset-env": "7.19.4",
43
43
  "@babel/register": "7.18.9",
44
44
  "@types/assert": "1.5.6",
45
45
  "@types/mocha": "10.0.0",
46
- "@typescript-eslint/eslint-plugin": "5.40.0",
47
- "@typescript-eslint/parser": "5.40.0",
46
+ "@typescript-eslint/eslint-plugin": "5.41.0",
47
+ "@typescript-eslint/parser": "5.41.0",
48
48
  "assert": "2.0.0",
49
49
  "babel-loader": "8.2.5",
50
50
  "benchmark": "2.1.4",
51
51
  "codecov": "3.8.3",
52
- "core-js": "3.25.5",
52
+ "core-js": "3.26.0",
53
53
  "del": "6.1.1",
54
54
  "dtslint": "4.2.1",
55
- "eslint": "8.25.0",
55
+ "eslint": "8.26.0",
56
56
  "eslint-config-prettier": "8.5.0",
57
57
  "eslint-config-standard": "17.0.0",
58
58
  "eslint-plugin-import": "2.26.0",
59
59
  "eslint-plugin-mocha": "10.1.0",
60
60
  "eslint-plugin-n": "15.3.0",
61
61
  "eslint-plugin-prettier": "4.2.1",
62
- "eslint-plugin-promise": "6.0.1",
63
- "expect-type": "0.14.2",
62
+ "eslint-plugin-promise": "6.1.1",
63
+ "expect-type": "0.15.0",
64
64
  "expr-eval": "2.0.2",
65
65
  "fancy-log": "2.0.0",
66
66
  "glob": "8.0.3",
@@ -77,7 +77,7 @@
77
77
  "karma-webpack": "5.0.0",
78
78
  "math-expression-evaluator": "1.4.0",
79
79
  "mkdirp": "1.0.4",
80
- "mocha": "10.0.0",
80
+ "mocha": "10.1.0",
81
81
  "mocha-junit-reporter": "2.1.0",
82
82
  "ndarray": "1.0.19",
83
83
  "ndarray-determinant": "1.0.0",
@@ -162,7 +162,7 @@
162
162
  "test:all": "npm run test:src && npm run test:generated && npm run test:node && npm run test:types",
163
163
  "test:browser": "karma start test/browser-test-config/local-karma.js",
164
164
  "test:browserstack": "karma start test/browser-test-config/browserstack-karma.js",
165
- "test:types": "cd types && tsc -p ./tsconfig.json && node --loader ts-node/esm ./index.ts",
165
+ "test:types": " tsc -p ./tsconfig.json && node --loader ts-node/esm ./test/typescript-tests/testTypes.ts",
166
166
  "coverage": "nyc --reporter=lcov --reporter=text-summary mocha test/unit-tests && echo \"\nDetailed coverage report is available at ./coverage/lcov-report/index.html\"",
167
167
  "prepublishOnly": "npm run test:all && npm run lint",
168
168
  "update-authors": "node ./tools/update-authors.js"
package/types/index.d.ts CHANGED
@@ -165,119 +165,159 @@ declare namespace math {
165
165
  new (): MathNode
166
166
  }
167
167
 
168
- interface AccessorNode extends MathNode {
168
+ interface AccessorNode<TObject extends MathNode = MathNode> extends MathNode {
169
169
  type: 'AccessorNode'
170
170
  isAccessorNode: true
171
- object: MathNode
171
+ object: TObject
172
172
  index: IndexNode
173
173
  name: string
174
174
  }
175
175
  interface AccessorNodeCtor {
176
- new (object: MathNode, index: IndexNode): AccessorNode
176
+ new <TObject extends MathNode = MathNode>(
177
+ object: TObject,
178
+ index: IndexNode
179
+ ): AccessorNode<TObject>
177
180
  }
178
181
 
179
- interface ArrayNode extends MathNode {
182
+ interface ArrayNode<TItems extends MathNode[] = MathNode[]> extends MathNode {
180
183
  type: 'ArrayNode'
181
184
  isArrayNode: true
182
- items: MathNode[]
185
+ items: TItems
183
186
  }
184
187
  interface ArrayNodeCtor {
185
- new (items: MathNode[]): ArrayNode
188
+ new <TItems extends MathNode[] = MathNode[]>(
189
+ items: MathNode[]
190
+ ): ArrayNode<TItems>
186
191
  }
187
192
 
188
- interface AssignmentNode extends MathNode {
193
+ interface AssignmentNode<TValue extends MathNode = MathNode>
194
+ extends MathNode {
189
195
  type: 'AssignmentNode'
190
196
  isAssignmentNode: true
191
197
  object: SymbolNode | AccessorNode
192
198
  index: IndexNode | null
193
- value: MathNode
199
+ value: TValue
194
200
  name: string
195
201
  }
196
202
  interface AssignmentNodeCtor {
197
- new (object: SymbolNode, value: MathNode): AssignmentNode
198
- new (
203
+ new <TValue extends MathNode = MathNode>(
204
+ object: SymbolNode,
205
+ value: TValue
206
+ ): AssignmentNode<TValue>
207
+ new <TValue extends MathNode = MathNode>(
199
208
  object: SymbolNode | AccessorNode,
200
209
  index: IndexNode,
201
- value: MathNode
202
- ): AssignmentNode
210
+ value: TValue
211
+ ): AssignmentNode<TValue>
203
212
  }
204
213
 
205
- interface BlockNode extends MathNode {
214
+ interface BlockNode<TNode extends MathNode = MathNode> extends MathNode {
206
215
  type: 'BlockNode'
207
216
  isBlockNode: true
208
- blocks: Array<{ node: MathNode; visible: boolean }>
217
+ blocks: Array<{ node: TNode; visible: boolean }>
209
218
  }
210
219
  interface BlockNodeCtor {
211
- new (
212
- arr: Array<{ node: MathNode } | { node: MathNode; visible: boolean }>
220
+ new <TNode extends MathNode = MathNode>(
221
+ arr: Array<{ node: TNode } | { node: TNode; visible: boolean }>
213
222
  ): BlockNode
214
223
  }
215
224
 
216
- interface ConditionalNode extends MathNode {
225
+ interface ConditionalNode<
226
+ TCond extends MathNode = MathNode,
227
+ TTrueNode extends MathNode = MathNode,
228
+ TFalseNode extends MathNode = MathNode
229
+ > extends MathNode {
217
230
  type: 'ConditionalNode'
218
231
  isConditionalNode: boolean
219
- condition: MathNode
220
- trueExpr: MathNode
221
- falseExpr: MathNode
232
+ condition: TCond
233
+ trueExpr: TTrueNode
234
+ falseExpr: TFalseNode
222
235
  }
223
236
  interface ConditionalNodeCtor {
224
- new (
225
- condition: MathNode,
226
- trueExpr: MathNode,
227
- falseExpr: MathNode
237
+ new <
238
+ TCond extends MathNode = MathNode,
239
+ TTrueNode extends MathNode = MathNode,
240
+ TFalseNode extends MathNode = MathNode
241
+ >(
242
+ condition: TCond,
243
+ trueExpr: TTrueNode,
244
+ falseExpr: TFalseNode
228
245
  ): ConditionalNode
229
246
  }
230
247
 
231
- interface ConstantNode extends MathNode {
248
+ interface ConstantNode<TValue extends string | number = number>
249
+ extends MathNode {
232
250
  type: 'ConstantNode'
233
251
  isConstantNode: true
234
252
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
235
- value: any
253
+ value: TValue
236
254
  }
237
255
 
238
256
  interface ConstantNodeCtor {
239
- new (constant: number): ConstantNode
257
+ new <TValue extends string | number = string>(
258
+ value: TValue
259
+ ): ConstantNode<TValue>
240
260
  }
241
261
 
242
- interface FunctionAssignmentNode extends MathNode {
262
+ interface FunctionAssignmentNode<TExpr extends MathNode = MathNode>
263
+ extends MathNode {
243
264
  type: 'FunctionAssignmentNode'
244
265
  isFunctionAssignmentNode: true
245
266
  name: string
246
267
  params: string[]
247
- expr: MathNode
268
+ expr: TExpr
248
269
  }
249
270
  interface FunctionAssignmentNodeCtor {
250
- new (name: string, params: string[], expr: MathNode): FunctionAssignmentNode
271
+ new <TExpr extends MathNode = MathNode>(
272
+ name: string,
273
+ params: string[],
274
+ expr: TExpr
275
+ ): FunctionAssignmentNode<TExpr>
251
276
  }
252
277
 
253
- interface FunctionNode extends MathNode {
278
+ interface FunctionNode<
279
+ TFn = SymbolNode,
280
+ TArgs extends MathNode[] = MathNode[]
281
+ > extends MathNode {
254
282
  type: 'FunctionNode'
255
283
  isFunctionNode: true
256
- fn: SymbolNode
257
- args: MathNode[]
284
+ fn: TFn
285
+ args: TArgs
258
286
  }
259
287
  interface FunctionNodeCtor {
260
- new (fn: MathNode | string, args: MathNode[]): FunctionNode
288
+ new <TFn = SymbolNode, TArgs extends MathNode[] = MathNode[]>(
289
+ fn: TFn,
290
+ args: SymbolNode
291
+ ): FunctionNode<TransferFunction, TArgs>
292
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
293
+ onUndefinedFunction: (name: string) => any
261
294
  }
262
295
 
263
- interface IndexNode extends MathNode {
296
+ interface IndexNode<TDims extends MathNode[] = MathNode[]> extends MathNode {
264
297
  type: 'IndexNode'
265
298
  isIndexNode: true
266
- dimensions: MathNode[]
299
+ dimensions: TDims
267
300
  dotNotation: boolean
268
301
  }
269
302
  interface IndexNodeCtor {
270
- new (dimensions: MathNode[]): IndexNode
271
- new (dimensions: MathNode[], dotNotation: boolean): IndexNode
303
+ new <TDims extends MathNode[] = MathNode[]>(dimensions: TDims): IndexNode
304
+ new <TDims extends MathNode[] = MathNode[]>(
305
+ dimensions: TDims,
306
+ dotNotation: boolean
307
+ ): IndexNode<TDims>
272
308
  }
273
309
 
274
- interface ObjectNode extends MathNode {
310
+ interface ObjectNode<
311
+ TProps extends Record<string, MathNode> = Record<string, MathNode>
312
+ > extends MathNode {
275
313
  type: 'ObjectNode'
276
314
  isObjectNode: true
277
- properties: Record<string, MathNode>
315
+ properties: TProps
278
316
  }
279
317
  interface ObjectNodeCtor {
280
- new (properties: Record<string, MathNode>): ObjectNode
318
+ new <TProps extends Record<string, MathNode> = Record<string, MathNode>>(
319
+ properties: TProps
320
+ ): ObjectNode<TProps>
281
321
  }
282
322
 
283
323
  type OperatorNodeMap = {
@@ -355,25 +395,41 @@ declare namespace math {
355
395
  ): ParenthesisNode<TContent>
356
396
  }
357
397
 
358
- interface RangeNode extends MathNode {
398
+ interface RangeNode<
399
+ TStart extends MathNode = MathNode,
400
+ TEnd extends MathNode = MathNode,
401
+ TStep extends MathNode = MathNode
402
+ > extends MathNode {
359
403
  type: 'RangeNode'
360
404
  isRangeNode: true
361
- start: MathNode
362
- end: MathNode
363
- step: MathNode | null
405
+ start: TStart
406
+ end: TEnd
407
+ step: TStep | null
364
408
  }
365
409
  interface RangeNodeCtor {
366
- new (start: MathNode, end: MathNode, step?: MathNode): RangeNode
410
+ new <
411
+ TStart extends MathNode = MathNode,
412
+ TEnd extends MathNode = MathNode,
413
+ TStep extends MathNode = MathNode
414
+ >(
415
+ start: TStart,
416
+ end: TEnd,
417
+ step?: TStep
418
+ ): RangeNode<TStart, TEnd, TStep>
367
419
  }
368
420
 
369
- interface RelationalNode extends MathNode {
421
+ interface RelationalNode<TParams extends MathNode[] = MathNode[]>
422
+ extends MathNode {
370
423
  type: 'RelationalNode'
371
424
  isRelationalNode: true
372
425
  conditionals: string[]
373
- params: MathNode[]
426
+ params: TParams
374
427
  }
375
428
  interface RelationalNodeCtor {
376
- new (conditionals: string[], params: MathNode[]): RelationalNode
429
+ new <TParams extends MathNode[] = MathNode[]>(
430
+ conditionals: string[],
431
+ params: TParams
432
+ ): RelationalNode<TParams>
377
433
  }
378
434
 
379
435
  interface SymbolNode extends MathNode {
@@ -383,6 +439,8 @@ declare namespace math {
383
439
  }
384
440
  interface SymbolNodeCtor {
385
441
  new (name: string): SymbolNode
442
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
443
+ onUndefinedSymbol: (name: string) => any
386
444
  }
387
445
 
388
446
  /**
@@ -3840,6 +3898,7 @@ declare namespace math {
3840
3898
  prefixes?: string
3841
3899
  offset?: number
3842
3900
  aliases?: string[]
3901
+ baseName?: string
3843
3902
  }
3844
3903
 
3845
3904
  // eslint-disable-next-line @typescript-eslint/no-empty-interface