From 4b5560391fd2b32bab3145b18d492f46a0efcecd Mon Sep 17 00:00:00 2001 From: Josh Hansen Date: Tue, 25 Jan 2022 23:54:45 -0800 Subject: [PATCH 1/3] Add missing FunctionNode.name to Typescript types --- types/index.d.ts | 1 + 1 file changed, 1 insertion(+) 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[]; } From 8ba396d75304618b4b759a4e50d9a6bc03e2ff55 Mon Sep 17 00:00:00 2001 From: Josh Hansen Date: Wed, 26 Jan 2022 00:12:08 -0800 Subject: [PATCH 2/3] Document FunctionNode.name --- docs/expressions/expression_trees.md | 1 + 1 file changed, 1 insertion(+) 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: From 836b7957513ef5a7b249efd250303e219d039dfc Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Tue, 22 Feb 2022 07:44:20 -0800 Subject: [PATCH 3/3] chore: Add test to ensure the defined property of FunctionNode is exported --- test/generated-code-tests/entry/mainAny.test.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 })