Skip to content

Instantly share code, notes, and snippets.

@halferty
Created August 7, 2018 15:49
Show Gist options
  • Save halferty/9d0ea72c2a10c3c8eb34d1a3ba3851ed to your computer and use it in GitHub Desktop.
Save halferty/9d0ea72c2a10c3c8eb34d1a3ba3851ed to your computer and use it in GitHub Desktop.
Compile and Run TypeScript from JS
#!/bin/bash
npm install ts-node
npm install typescript
node test.js
require('ts-node').register({});
process.openStdin().addListener("data", function(d) {
const asdf = require("./" + d.toString().trim());
asdf.hello();
});
export const hello = () => console.log("hello!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment