Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScripts transpiles files which are non-executable

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?

like image 827
Alexander Mills Avatar asked Jun 18 '17 05:06

Alexander Mills


People also ask

Is there a TypeScript REPL?

TSUN, a TypeScript Upgraded Node, supports a REPL and interpreter for TypeScript.

CAN node JS run 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.


1 Answers

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.

like image 160
galkin Avatar answered Sep 22 '22 08:09

galkin