microsoft / microsoft/TypeScript

Feature Request: Collapsible chained methods.

Offen
#39,825 13 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Awaiting More Feedback Domain: LS: Outlining Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Das Issue enthält Beispiele für verkettete JavaScript- und TypeScript-Ausdrücke, nennt jedoch keine Implementierungsdateien, Tests oder Einstiegspunkte. Beginne damit zu bestimmen, welche Folding-Komponente die Editor-Unterstützung übernimmt und ob dies zu TypeScript oder VS Code gehört. Die Definition des Abschlusses sollte ein festgelegtes Einklappverhalten für die gezeigten Fälle verketteter Methoden und eine entsprechende Abdeckung dafür enthalten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript
Bereich
developer-experience, tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.