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.

TypeScript - incorrect semicolon added to method with ECMAScript 6 arrow syntax

See original GitHub issue

Example of method declaration in a class.

receiveBroadcast = (message: string): void => { this.broadcastMessage = message; };

Prettier added the semicolon at the end of the method. I’ve confirmed this by flipping the semi setting to false and observing the result.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
CiGitcommented, Jun 4, 2018

You have to put those semi in a case like:

class {
	b:()=>1;
	[computedMethodName](){}
}

I think it’s not the case with a block statement tho.

1reaction
CiGitcommented, Jun 4, 2018

Why is that incorrect? This is an assignment expression.

Read more comments on GitHub >

github_iconTop Results From Across the Web

One line arrow functions without braces - can't have a ...
I get a "Cannot find module" error. But if I remove the semicolon in the arrow function: return <input onChange={event => console. log(event....
Read more >
SyntaxError: missing ; before statement - JavaScript | MDN
The JavaScript exception "missing ; before statement" occurs when there is a semicolon ( ; ) missing somewhere and can't be added by...
Read more >
ECMAScript 6: arrow functions and method definitions - 2ality
ECMAScript.next will make things easy by introducing two constructs: arrow functions and method definitions. This blog posts explains what ...
Read more >
13. Arrow functions - Exploring JS
13.9 FAQ: arrow functions​​ ECMAScript 6 has syntax for functions with a lexical this , so-called arrow functions. However, it does not have...
Read more >
semicolon rule false positives with class members with arrow ...
Expected behavior. the semicolon after the initializer expression is not unnecessary if you are requiring semi-colons.
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