Allow type annotations in .js files in preparation for Type Annotations proposal
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript, typescript
- 領域
- compilers
調査の方向性
まず、#10939 の以前の議論と、リンクされている TC39 Type Annotations proposal を読んでください。次に、.js ファイル内の TypeScript 専用構文に対する TypeScript コンパイラーの既存の制限を調べ、引き続き許可されない構文を含めて、このオプションの適用範囲を判断してください。ドキュメント化されたコンパイラーオプションによって、実行時に出力される動作を変更せずに、意図した型付き JavaScript のパースがサポートされれば完了です。
索引モデルが issue の本文から書いたものです。
説明
🔍 Search Terms
allow js file extension
✅ Viability Checklist
- 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 isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
Add an option to allow removing the error "[some feature] can only be used in TypeScript files"
Previous discussion: #10939
The compiler option would allow consuming .js files as if they were .ts files, but with some differences (see below). All type-checking, type-stripping, and code emitting features would remain as-is.
📃 Motivating Example
The Type Annotations proposal is the definite future of JavaScript.
This feature would:
- Enable incremental adoption of the Type Annotations proposal by users
- Enable incremental support of Type Annotations in the TypeScript compiler
- Possibly help push that proposal forward a little more quickly by increased usage
- Spread word that this proposal exists by gaining compiler support in tsc and its release notes
It's true that the exact syntax isn't definite yet, and it will probably be at least somewhat different than current TypeScript syntax.
However, that's exactly why adding initial support for plain TypeScript would not interfere with its eventually sealed syntax.
In other words, the initial support would simply parse it as "typed-javascript" but the TypedJavaScript parser would currently be exactly the same as the TypeScript parser for the time being, and allow gradual differentiation.
It would also be a good opportunity to allow TypedJavaScript mode to disallow namespaces, enums, constructor fields, etc.
💻 Use Cases
- What do you want to use this for?
Writing future-ready JavaScript.
- What shortcomings exist with current approaches?
It doesn't take into account the pending type annotation proposal.
- What workarounds are you using in the meantime?
I can almost get this working with some VS Code hacks, but then tsc complains as soon as I run it.
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/TypeScript のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
microsoft/TypeScript#64322 · コメント 2 件 · リアクション 1 件 · 担当者 2 名 ·
-
Possible Improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/TypeScript#64278 · コメント 1 件 · リアクション 1 件 ·
-
Docs
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
microsoft/TypeScript#64118 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
microsoft/TypeScript#64094 ·
-
Docs
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/TypeScript#63959 · コメント 5 件 ·
microsoft/TypeScript の issue をすべて見る
似ている issue
-
optimization optimization:agents-md-curator
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
githubnext/gh-aw-cao#13143 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
blinklabs-io/bursa#904 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · コメント 2 件 ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100