microsoft / microsoft/TypeScript
Add some way to specify a different output shebang
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Suggestion
🔍 Search Terms
- shebang, hashbang, javascript, compiled shebang, #!/usr/bin/env node
✅ Viability 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, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
TypeScript should offer some way to specify a shebang to be added to the top of the compiled JS file that is different to the one specified (or not) in the TS source.
For example, this TypeScript file:
#!/usr/bin/env tsx
//->#!/usr/bin/env node
...
would become:
#!/usr/bin/env node
...
📃 Motivating Example
Currently, if you want to create a file that should be an executable when compiled, you must place #!/usr/bin/env node in the TypeScript file if you want that at the top of the JavaScript file.
This is not ideal as the TypeScript file is then therefore classified as a Node executable / JavaScript file instead of TypeScript source code. It renders the TS shebang completely misleading as it should never be run with that executable.
- Related discussion can be found at at https://github.com/github/linguist/issues/5251
💻 Use Cases
The main use case is creating a Node CLI application in TypeScript. CLIs must be executables, so the outputted JS file must have #!/usr/bin/env node, which must also be found in the TS file, misclassifying it.
Extensions are just a suggestion; shebangs (usually) mean "execute me only with this", which should guarantee a language match. TS is forcing misuse of the shebang which should be changed.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Das Issue nennt keine Dateien, Tests oder Einstiegspunkte. Beginne damit nachzuverfolgen, wie TypeScript Shebangs bei der Erzeugung von JavaScript verarbeitet, und vergleiche die angeforderten TypeScript- und Ausgabe-Beispiele. Als erledigt würde gelten, wenn ein vereinbarter Mechanismus zur Auswahl eines anderen Ausgabe-Shebangs existiert, ohne das bestehende Verhalten zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- node.js, typescript
- Bereich
- cli, compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Ruhig
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100