Support TypeScript executable without extension when flag is set
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 283
説明
What is the problem this feature will solve?
When I write an executable utility like build-game, I have to expose the implementation detail of the language it's written in, like build-game.ts.
#!/usr/bin/env node
// This file is named `build-game` not `build-game.ts`. Only plain JavaScript is allowed.
const foo: number = 1 // Error: TypeScript encountered.
console.log(foo)
/home/user/bin/build-game:3
const foo: number = 1
^^^
SyntaxError: Missing initializer in const declaration
at wrapSafe (node:internal/modules/cjs/loader:1624:18)
at Module._compile (node:internal/modules/cjs/loader:1666:20)
at Object..js (node:internal/modules/cjs/loader:1824:10)
at Module.load (node:internal/modules/cjs/loader:1427:32)
at Module._load (node:internal/modules/cjs/loader:1250:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:152:5)
at node:internal/main/run_main_module:33:47
Node.js v24.4.1
What is the feature you are proposing to solve the problem?
When --experimental-strip-types is set (or add a new flag), force TypeScript evaluation. This will allow a script to encapsulate all interpreter detail.
#!/usr/bin/env -S node --experimental-strip-types
// This file is named `build-game` not `build-game.ts`. TypeScript is allowed
// because the `--experimental-strip-types` flag was passed.
const foo: number = 1
console.log(foo)
What alternatives have you considered?
If the executable is in an NPM package, I can just alias it in the package.json. If the executable is in my ~/bin, I can just shell alias it. However, these are both limited and really prevent me from sharing scripts with nice names that work everywhere.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
この issue では実装ファイル、エントリーポイント、テストが指定されていないため、まず Node のコマンドラインフラグ処理と TypeScript の実行動作を特定します。--experimental-strip-types を指定した拡張子のない実行可能ファイルに対する期待される動作を確認し、既存の拡張子ベースの動作が変更されないことも確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- nodejs, typescript
- 領域
- cli
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100