static-eval icon indicating copy to clipboard operation
static-eval copied to clipboard

It does not evaluate functions

Open hacknlove opened this issue 2 years ago • 1 comments

const { parse } = require('esprima');
const staticEval = require('static-eval');
const ast = parse('(() => 1)()');
const val = staticEval(ast.body[0].expression, {}, { allowAccessToMethodsOnFunctions: true });
// val is undefined

The expression I was actually trying to evaluate looks more like '[1,2,3].map(x => x)'

Is there some workaround?

hacknlove avatar May 06 '23 14:05 hacknlove

It seems to be related with this: https://github.com/browserify/static-eval/pull/37

hacknlove avatar May 06 '23 14:05 hacknlove