microsoft / microsoft/TypeScript

Language server: Recursively auto-complete default object instance.

Aperta
#42,084 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

Suggestion

🔍 Search Terms

  • auto complete typescript object recursively
  • typescript language server options
  • typescript set default nested object

✅ Viability Checklist

My suggestion meets these guidelines:

  • This feature would agree with the rest of TypeScript's Design Goals.

  • 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.)

⭐ Suggestion

Is it possible to add an auto complete feature to the language server that allows starting with this code:

const o: Animal = {
// Place cursor here
}

And then offering to set all keys recursively to a default value:

const o: Animal = {
    name: "",
    age: 0,
    children: [],
    mostFamousCousin: {
        name: "",
        age: 0,
        children: []
    }
}

I'm using Webstorm, which has this feature for other typed languages.

This comes in useful when you are entering data directly into large nested data types.

Thanks.

📃 Motivating Example

  • "Save yourself hours of work filling in each field of an object by auto completing the whole tree".

💻 Use Cases

  • When creating a large nested object it would be much faster to create the whole tree of objects.
  • For branching at enum points (one of many possible types) or recursive definitions, the auto complete code should end the recursion as early as possible, in which case the user can create the root object and type of their desired type for that branch and repeat the auto complete process.

Related

  • https://youtrack.jetbrains.com/issue/WEB-39222
    • IntelliJ's "Implement members" feature already completes all keys, but it has some issues with nested object literals, and when all keys are optional.
    • This feature proposes integrating the same "implement members" feature of IntelliJ into the TS lang server so it works in all editors flawlessly.

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

Inizia esaminando il comportamento del completamento del language server TypeScript e la funzionalità IntelliJ correlata “Implement members” descritta nell’issue. L’implementazione completata deve fornire il completamento ricorsivo con valori predefiniti per i letterali di oggetti annidati, interrompendo però la ricorsione per le definizioni ricorsive e gestendo i rami enum come descritto.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.