microsoft / microsoft/TypeScript

Ship stripInternal as officially supported compiler option

オープン
#42,811 コメント 1 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Suggestion

🔍 Search Terms

I have looked through all issues while searching for stripInternal. While many mention this option and numerous comments mention that it is not officially supported, I couldn't find a definitive issue to discuss what would be required to officially ship shipInternal.

✅ 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

The stripInternal compiler option is currently marked as "internal": https://www.typescriptlang.org/tsconfig#stripInternal This issue would track what is required to ship stripInternal as an officially supported compiler option.

📃 Motivating Example

The compiler option looks interesting and would address several cross-folder problems we are observing in Chrome DevTools. Most commonly, we want to separate code out in separate files to keep functionality modular, but this will cause all symbols to be available in the .d.ts files. We sometimes don't explicitly export a particular file in our "entrypoints" to prevent other folders from using these symbols, but this is not always possible. Marking some exports as internal implementation details of a particular module would resolve that issue.

However, at Chrome DevTools we don't want to rely on internal, not officially supported compiler options. Therefore, if this option becomes officially supported, we can adopt it in our codebase to cleanup numerous exported symbols that are effectively internal implementation details.

💻 Use Cases

Factoring out code into separate files when they should remain internal implementation details would allow for a tighter control on what code is allowed to be used by different modules.

For example, in our formatter implementation that runs in a worker, we define the Ecmascript version we support in the same file as our tokenizer. However, this constant should effectively only be used by formatter_worker and not by any other module. Therefore, if we would be able to mark it as @internal, we can safely use this constant, without accidentally introducing unwanted usages at other places in the codebase.

Note that the same logic as above would be valid for AcornTokenizer itself. It is an implementation detail of the formatter_worker and outside modules should not be using it. We use this pattern a lot, where we implement various panels in subpanels. These subpanels are not intended to be used on their own, but are factored out into separate files for readability and maintainability purposes.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、現在のコンパイラオプション stripInternal とその tsconfig ドキュメントを確認し、ここで説明されている Chrome DevTools のユースケースと比較してください。公式サポートに必要な要件と、変更が必要になるコンパイラまたはドキュメントの領域を特定してください。完了とするには合意されたスコープと設計が必要ですが、この issue にはまだそれらがありません。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。