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.

Cannot declare multiline function

See original GitHub issue

I’m not sure what I’m missing from the readme, but I cannot seem to able to define multiline functions.

Given:

let bla = (one, two) ->
    console.log one
    console.log two

It compiles to:

let bla = function(one, two) {}
    console.log(one)
    console.log(two)

There is just a single line break after -> and the indentation is the same on the 2nd and 3rd line. I’m using the VSC extensions, so the language server is already displaying me an error before compilation, saying Cannot find name 'one'

Changing it to an arrow function:

let bla = (one, two) =>
    console.log one
    console.log two

Results in:

let bla = (one, two) =>
    console.log(one)
    console.log(two)

Here’s the same with types:

let bla = (one: string, two: string) =>
    console.log one
    console.log two

It turns to:

let bla = (one: string, two: string) =>
    console.log(one)
    console.log(two)

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
zolomatokcommented, Nov 12, 2022

Thanks Daniel, really helpful! Read the readme like 5 times but I missed that 😄

+1 for optional assignment, I never understood why it’s not a thing in typescript and it’s always a big bummer conditional assignment is also very nice!

Civet has a really, really bright future 🌈

0reactions
zolomatokcommented, Nov 25, 2022

Works great, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to declare multiline string in JS File with ES6 format
I am trying to declare multiline string variable in a JS file. However it seems that Karate won't let me to declare the...
Read more >
Multiline Functions - General - RStudio Community
I am doing something wrong when I try to create a function. I enter. I want to enter "myfunc3 <- variable(a) {" and...
Read more >
Working of Python Multiline String with Examples - eduCBA
Firstly, we will see how to declare a multiline string in Python having a newline character using triple quotes along with examples. Example:...
Read more >
[PSR-12] Function declarations with multiline arguments AND ...
I cannot find an answer to this question: what should a function/method declaration look like if it has arguments that are split over...
Read more >
Allow blank lines between multi-line function arguments #3323
I read through the exact definition in PSR12 and it does not state that there cannot be blank lines between function arguments -...
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