TypeScripts translates files that are not executable

It seems that TypeScript is passing in target files that are not executable.

I need to run chmod u+x <file>

after transpilation for 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 executable files?

+3


source to share


1 answer


Changing file permissions is not the responsibility of typescript.

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 a TypeScript Language Service Plugin . I think in your case it is too complicated.

+3


source







All Articles