microsoft / microsoft/TypeScript

Set as executable files that are intended to be binaries

Abierto
#37,583 13 comentarios 15 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Awaiting More Feedback Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Descripción

Search Terms

  • mode
  • binary
  • executable
  • package.json bin

Suggestion

Currently, the TypeScript compiler always generates files with the 644 mode. But some files are meant to be executable: they may start with #!/usr/bin/env node; they may be marked as bin in package.json; they may have an executable mode set on the .ts source; and so forth.

It’d be great if the TypeScript compiler would take any of the hints I mentioned above, figure that the file should be executable, and create the .js as so.

At least the TypeScript compiler doesn’t change the mode of existing .js files when overwriting them, so I can chmod once, and as long as never delete the file, it’ll have the right mode.

Use Cases

This is mostly for development and running the binary from the command-line directly. Once you install the package, npm puts the binary in the node_modules/.bin folder, npx picks it up, and all is good.

Examples

You’re working on a project that should provide a binary: src/my-binary.ts. You do one of the things I mentioned to indicate that the file should be executable. You run tsc, and the generated file at lib/my-binary.js is marked as +x. Then you can call the binary with lib/my-binary.js from the command-line and it works.

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con el flujo de tsc que emite src/my-binary.ts como lib/my-binary.js y, después, investiga cómo se eligen actualmente los modos de archivo de salida. Se considera completado cuando se haya definido e implementado una regla compatible para reconocer los binarios previstos y se haya verificado que el JavaScript generado es ejecutable sin cambiar el comportamiento existente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
compilers
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.