Valid TypeScript has "SyntaxError: '=' expected."
See original GitHub issueThe following code causes a SyntaxError, despite being syntactically/stylistically correct:
const bar = (...varargs:any[]) => {
console.log(varargs);
};
const foo = (x:string):void => (
bar(
x,
() => {},
() => {}
)
);
Here is the result:
SyntaxError: '=' expected. (6:6)
4 |
5 | const foo = (x:string):void => (
> 6 | bar(
| ^
7 | x,
8 | () => {},
9 | () => {}
Here is a link to the issue reproduced in the prettier playground. Note that if the parser is changed to babylon then there is no error shown.
Thanks for any assistance!
EDIT: I’m using prettier@1.6.1 and typescript@2.2.2.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Executing typescript file gives SyntaxError: Unexpected identifier
So i was able to solve above problem. Actually i was trying to load TypeSciprt file that is .ts file rather than .js...
Read more >Exception Handling - TypeScript Deep Dive - Gitbook
SyntaxError. Creates an instance representing a syntax error that occurs while parsing code that isn't valid JavaScript. 1***3; // SyntaxError: Unexpected ...
Read more >Less than (<) - JavaScript - MDN Web Docs
The less than (<) operator returns true if the left operand is less than the right operand, and false otherwise. ... expected output:...
Read more >Chapter 1. Getting to Know TypeScript
function greet(who: string) { ^ SyntaxError: Unexpected token : The : string is a type ... This program is valid JavaScript (and hence...
Read more >Troubleshoot 'Uncaught SyntaxError: Unexpected token u in ...
The 'Uncaught SyntaxError: Unexpected token u in JSON at position 0' error is caused when the client has been asked to execute JSON.parse() ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Funky, seems to be an issue with the TypeScript 2.5 RC. This parses fine in stable TypeScript 2.4, but not in 2.5.1.
I’ll report it to the TS team
This is not fixed in
lastest
(2.5.2) but is fixed ininsiders
(2.5.3-insiders.20170909
)