diff --git a/docs/expressions/expression_trees.md b/docs/expressions/expression_trees.md index f2ce69230c..e09c6e9a77 100644 --- a/docs/expressions/expression_trees.md +++ b/docs/expressions/expression_trees.md @@ -477,6 +477,7 @@ Properties: - `fn: Node | string` (read-only) The object or function name which to invoke. - `args: Node[]` +- `name: string` The name of the function Examples: diff --git a/test/generated-code-tests/entry/mainAny.test.js b/test/generated-code-tests/entry/mainAny.test.js index 4c7bcc9216..3f832a92bb 100644 --- a/test/generated-code-tests/entry/mainAny.test.js +++ b/test/generated-code-tests/entry/mainAny.test.js @@ -2,7 +2,7 @@ import assert from 'assert' import * as mainAny from '../../../src/entry/mainAny.js' import * as factoriesAny from '../../../src/factoriesAny.js' import { createSnapshotFromFactories, validateBundle, validateTypeOf } from '../../../src/utils/snapshot.js' -const { create, all, add, matrix, isObject, isMatrix, pi, speedOfLight, sqrt, evaluate, chain, reviver, Complex, addDependencies } = mainAny +const { create, all, add, matrix, isObject, isMatrix, pi, speedOfLight, sqrt, evaluate, chain, reviver, Complex, FunctionNode, SymbolNode, ConstantNode, addDependencies } = mainAny const { expectedInstanceStructure, @@ -146,6 +146,14 @@ describe('mainAny', function () { assert.deepStrictEqual(obj, c) }) + it('should have the full FunctionNode interface', () => { + const funcname = 'myfunc' + const myfunc = + new FunctionNode( + new SymbolNode(funcname), [new ConstantNode(2), new ConstantNode(3)]) + assert.strictEqual(myfunc.name, funcname) + }) + // TODO: test export of errors // TODO: test export of classes }) diff --git a/types/index.d.ts b/types/index.d.ts index 1be904cffe..a19e45aed1 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -233,6 +233,7 @@ declare namespace math { interface FunctionNode extends MathNodeCommon { type: 'FunctionNode'; isFunctionNode: true; + name: string; fn: SymbolNode; args: MathNode[]; }