Due to some reason, I am require to use the eval() and access the function i.e. foo
. However, I not able to make it in typescript.
eval("function foo() { console.log(\"foo bar\") }");
// @ts-ignore
foo();
The above code will hit error instead of print "foo bar" in console log.
VM42:4 Uncaught ReferenceError: foo is not defined
You may try the code here.
However, the same code work in javascript.
Does it require additional configuration?