I have some logic saved in a string and I need to convert it to a runable function. I have Interface already setup to make it strongly typed in Typescript, but it seem to not work.
interface IInterface {
Run(data: string): Promise<string>;
}
let code: string = `
return new class{
let Run = function(data) {
console.log(data);
return "SUCCESS";
};
}
`;
let obj: IInterface = Function(code) as IInterface;
obj.Run("Test ").then((result: string ) => {
console.log(result);
});
Should write: Test SUCCESS