question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Collapsible chained methods.

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
DanielRosenwassercommented, Jul 30, 2020

We release iteration plans to give an idea of when to expect new features. New releases come out around every 3 months. Our current iteration plan for 4.0 has a stable release planned for August 18th. We also have pre-releases like the beta or RC that you can try in the meantime!

0reactions
ChocolateLoverRajcommented, Aug 13, 2020

To the original issue: I think it seems reasonable. I am interested to know if others would like to see this.

@jessetrinity So how will we know if others will like to see this? So far only three people (@jessetrinity, @DanielRosenwasser, @jessetrinity) have talked about this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

489444 – [Formatter] Chained method calls when ... - Bugs
The problem: There is currently no combination of settings that allow Eclipse to format this code in the following way: int someValue =...
Read more >
Method chaining - why is it a good practice, or not?
Like everything in life, and programming, Chaining is neither good, nor bad if you can avoid the bad then chaining can be a...
Read more >
West Biking Folding Bike Lock, Bike Chain Lock, Heavy Duty ...
Amazon.com: West Biking Folding Bike Lock, Bike Chain Lock, Heavy Duty Alloy Steel, Bicycle Foldable Lock with Mounting Bracket, Anti-Theft Strong Security, ...
Read more >
Dehydration of main-chain amides in the final folding ... - PNAS
Kinetic IR spectroscopy was used to reveal β-sheet formation and water expulsion in the folding of single-chain monellin (SMN) composed of a five-stranded ......
Read more >
Kotlin DSL | TeamCity On-Premises Documentation - JetBrains
This Kotlin tutorial helps quickly learn most Kotlin features. ... a project by the sequential method that lists chained builds one by one....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found