microsoft / microsoft/TypeScript

Feature Request: Collapsible chained methods.

Aperta
#39,825 13 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

Search Terms

Collapsible
Chained

I was told to file a feature request upstream

This was originally an issue on the vscode github.

Suggestion

Chained methods should be collapsible, just like objects and arrays that span multiple lines.

Use Cases

Why This Is a Helpful Feature

When a lot of chained methods are written in a file, it can be really annoying because currently they aren't chainable. For example, with a library that I'm making which is heavily based on chained methods, they can take up a lot of space. In Visual Studio 2019, I can collapse chained methods, but in VSCode, I can't.

My Many Chained Methods
new Scene()
    .setBackgroundColor("skyBlue")
    .add(0, 5, new Rectangle(0, 250, 600, 350)
        .fill("yellow")
    )
    .add(0, 5, new Group(-600, 0)
        .fill("red")
        .add(new Rectangle(100, 100, 300, 200))
        .add(new Rectangle(400, 200, 100, 100))
        .add(wheel(400, 300))
        .add(wheel(200, 300))
        .animate(0, 5, new Animation({
            x: -600
        }, {
            x: 600
        }))
    ))

Examples

Builtin Classes like Map and Set.

Expanded.

var m = new Map()
    .set("apple", "red")
    .set("banana", "yellow")
    .set("grapes", "purple")

Collapsed should be something like this.

> var m = new Map()...
  )
Promises

Expanded

fsPromises.unlink("somePath")
    .then(() => {
        //Do something
    })
    .catch(err => {
        //Handle error
    })

Collapsed should be something like this.

> fsPromises.unlink("somePath")...
  )

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, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

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 fornisce esempi di espressioni concatenate JavaScript e TypeScript, ma non indica file di implementazione, test o punti di ingresso. Inizia determinando quale componente di folding gestisce il supporto dell’editor e se questo rientra in TypeScript o VS Code. Done deve includere un comportamento di collapsing definito per i casi di metodi concatenati mostrati e la relativa coverage.

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

Valutazione

Stack tecnologico
javascript, typescript
Ambito
developer-experience, tooling
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.