Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make VS Code recognize the ES7 bind operator

VS Code does not recognize the ES7 bind syntax out of the box. Instead, it shows up as a syntax error:

Example of highlighted error in code

[ts] Declaration or statement expected.
  • I've searched around to see if there's an extension that can help recognize it to no avail.
  • I've also tried to configure VS Code to use my own .eslintrc, which also doesn't seem to work. So far I haven't even been able to confirm VS Code recognizes my .eslintrc file and is using it for its own config.

Does anyone have an idea of how to configure VS Code to recognize the syntax? I realize it's a Stage 0 feature, however I feel it's fairly common at this point. I also realize what I'm seeing is a TypeScript error, however disabling TypeScript linting does not remove the error. I think it just shows up as a TypeScript error, inherited from JavaScript.

After a lot of searching, there's so many articles on how it can be used, but almost nothing when it comes to VS Code.

like image 749
Kyle Ramirez Avatar asked Oct 10 '18 22:10

Kyle Ramirez


1 Answers

If you use Typescript, this is a Typescript error (although you would get the same error with JS). And Typescript is not planning to support the operator, mainly because the TC39 proposal is dead. There are not yet plans to support it in JS or TS, only Babel does (experimentally). It is not ES7, and it is not even planned to be in the specs somewhen, so it is a SyntaxError for a good reason.

After a lot of searching, there's so many articles on how it can be used

If those articles didn't mention that the operator is still in an early proposal phase, I wouldn't use them as reliable ressources anymore.

like image 89
Jonas Wilms Avatar answered Nov 20 '22 16:11

Jonas Wilms