Skip to content

Instantly share code, notes, and snippets.

@dseg
Created December 22, 2016 10:47
Show Gist options
  • Save dseg/f6489e04b3479a9eef7623a6c3b0dc2d to your computer and use it in GitHub Desktop.
Save dseg/f6489e04b3479a9eef7623a6c3b0dc2d to your computer and use it in GitHub Desktop.
Compile and run a typescript file
function tscc {
local target
if [[ -n $2 ]]; then
target="$2"
else
target=es6
fi
tsc -t "$target" "$1" -outFile /dev/stdout | node
}
@dseg
Copy link
Author

dseg commented Dec 22, 2016

$ cat destructive-assignment.ts
const b = ({c: {d: value}}) => console.log(value);

var abcd = {a: 1, b: 2, c: {d: 4}};
b(abcd); // 4
$ source tscc.sh

$ tscc destructive-assignment.ts
=> 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment