microsoft / microsoft/TypeScript

Intellisense for Symbol properties

Aperta
#54,870 3 commenti 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Domain: LS: Completion Lists Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

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)

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

La issue non indica file, test o punti di ingresso. Inizia riproducendo il caso di completamento example. dell’esempio motivante e confrontalo con i suggerimenti desiderati Symbol.dispose e Symbol.asyncDispose. Il lavoro è completato quando le proprietà di simbolo pertinenti vengono visualizzate in IntelliSense e il comportamento di completamento esistente rimane invariato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
developer-experience
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.