It appears as though TypeScript is transpiling target files that are not executable.
I have to run chmod u+x <file>
after transpilation to get the files to become executable.
This is the case, even if they have a hashbang:
#!/usr/bin/env node
How can I tell TypeScript / tsc to create files which are executable?
TSUN, a TypeScript Upgraded Node, supports a REPL and interpreter for TypeScript.
You can run typescript directly on the node with the ts-node package. This package is recommended for development only. To make the final deploy in production, always use the javascript version of your project.
Changing file's permissions isn't typescript responsibility.
Solution 1. Use a separate step in the build process in your package.json. For example:
{
"name": "temp",
"version": "1.0.0",
"scripts": {
"build": "tsc && chmod +x build/index.js"
},
"dependencies": {
"typescript": "^2.3.4"
}
}
Solution 2.
Write TypeScript Language Service Plugin. I think, in your case this is overengineering.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With