microsoft / microsoft/TypeScript
Intellisense for Symbol properties
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
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
Disposableinterface, but lose the visibility to developers of the lifecycle management requirements of implementations. - Make my
Disposableinterface extend the globalDisposableinterface, 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)
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
El issue no menciona archivos, pruebas ni puntos de entrada. Empieza reproduciendo el caso de completado example. del ejemplo motivador y compáralo con las sugerencias deseadas Symbol.dispose y Symbol.asyncDispose. Se considera terminado cuando las propiedades de símbolo relevantes aparecen en IntelliSense y el comportamiento de completado existente se mantiene.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- developer-experience
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 25/100