loaders icon indicating copy to clipboard operation
loaders copied to clipboard

Function constructor does not honor experimental-{strip,transform}-types

Open sdegutis opened this issue 1 year ago • 1 comments

$ node --experimental-transform-types -e 'new Function(`console.log("hi" as 3)`)()'
undefined:3
console.log("hi" as 3)
            ^^^^

SyntaxError: missing ) after argument list

sdegutis avatar Aug 30 '24 15:08 sdegutis

The ECMAScript spec prevents runtimes from intercepting the code passed to new Function. Modules can be anything, but eval and new Function can only evaluate JS.

nicolo-ribaudo avatar Aug 30 '24 16:08 nicolo-ribaudo