Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document FunctionNode.name and add it to Typescript typings #2395

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/expressions/expression_trees.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
10 changes: 9 additions & 1 deletion test/generated-code-tests/entry/mainAny.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
})
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ declare namespace math {
interface FunctionNode extends MathNodeCommon {
type: 'FunctionNode';
isFunctionNode: true;
name: string;
fn: SymbolNode;
args: MathNode[];
}
Expand Down