microsoft / microsoft/TypeScript

Intellisense for Symbol properties

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

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

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

説明

Suggestion

🔍 Search Terms

With and without "is:issue is:open"
"symbol intellisense"
"symbol autocomplete"

✅ 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

Intellisense provides a list of symbol properties which, when accepted, insert indexed accessor syntax for that symbol. This list would be comprised of known symbols within the current scope or those that can be with an import statement.

📃 Motivating Example

This example demonstrates a type that implements the global Disposable interface introduced by TC39 ECMAScript Explicit Resource Management. (#54505)

class ExampleClass implements Disposable {
  [Symbol.dispose](): void {
    // ...
  }
}

const example = new ExampleClass();

example[Symbol.dispose]();

The suggestions shown for example. do not includeSymbol.dispose.

💻 Use Cases

TL;DR: Symbol.dispose and Symbol.asyncDispose are the first well-known symbols that are useful to call directly, and I want to easily know that they're there.

Typically, ES6 Symbols are intended as an implementation detail, but the new global Disposable interface, however, is analogous to this very prolific interface:

interface Disposable {
  dispose(): void;
}

In order to support using syntax, I need to implement the global Disposable interface. I have a few options:

  • Switch to the global Disposable interface, but lose the visibility to developers of the lifecycle management requirements of implementations.
  • Make my Disposable interface extend the global Disposable interface, or possibly merge it with the global one and then, by convention, do the following:
dispose(): void {
  // ...
}

[Symbol.dispose](): void {
  this.dispose();
}

An option is to create a utility class decorator that does that for me, but unfortunately that creates the issue of how to make that class recognized as an implementation of the global Disposable. (#4881)

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

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

はじめの一歩

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

調査の方向性

この Issue にはファイル、テスト、エントリポイントが記載されていません。まず、動機となった例の example. 補完ケースを再現し、目的の Symbol.disposeSymbol.asyncDispose の候補と比較してください。関連するシンボルプロパティが IntelliSense に表示され、既存の補完動作が維持されれば完了です。

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

評価

技術スタック
typescript
領域
developer-experience
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

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

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