I have TypeScript that is running on Node.js
TypeScript code will fetch by http several js files (lets call them 'fileA.js', 'fileB.js' and so on)
Each file will have function called 'Foo(inputparam)'. Name of the function and number of params will be the same for all fetched JS files.
How to call this functions from TypeScript?
Notes:
- I cannot embed these JS files to node.js in compilation time.
- I can change the content of JS files (I am creating them, but they should be created in a separate from TS place).
- I can change JavaScript files to TypeScript files if it will be easier to use.
- TypeScript cannot know the names of the JS files before the fetch. Node.js will be a static application, while list of JS files will be changed during runtime
evalis probably your best bet, but it is very dangerous and you'd lose all typing. The other option is to usechild_process.spawnto execute the js script, and retrieve the output from stdout. You wont have reference passing, only string passing though.