Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ES2016 Object Spread Initializer #1974

Closed
onybo opened this issue Jan 13, 2016 · 37 comments
Closed

Add support for ES2016 Object Spread Initializer #1974

onybo opened this issue Jan 13, 2016 · 37 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@onybo
Copy link

onybo commented Jan 13, 2016

Object Spread Initializers is a proposed feature of ES2016 and is very useful when writing Redux reducers. The syntax is supported in babel, but when using the feature in Visual Studio Code it will mark the spread operator as a syntax error.

See: https://github.com/sebmarkbage/ecmascript-rest-spread/blob/master/Spread.md
for more information of the feature.

It would be very nice if Visual Studio Code did not mark the use of this feature as an error with a red squiggly.

The current behavior in Visual Studio Code is also described in Issue #1640

@jpierson
Copy link

+1 I've been pretty much ignoring my errors and warnings in VSCode in hopes that this would be addressed soon but it's been a few months now. I've also noticed some discussion in the ESLint project about this and their suggestion was to make use of babel-eslint. I wonder if that is possible to use in VSCode...

@jrieken
Copy link
Member

jrieken commented Jan 18, 2016

This issue was moved to microsoft/TypeScript#6525

@jrieken jrieken closed this as completed Jan 18, 2016
@onybo
Copy link
Author

onybo commented Jan 18, 2016

No point in moving this feature request to the TypeScript project. They already have the feature on their roadmap. It is planned for the 2.0 release of TypeScript.

https://github.com/Microsoft/TypeScript/wiki/Roadmap

I don't understand why Syntax checking of EcmaScript in Visual Studio Code is dependent on TypeScript though? Do you use TypeScript to check the syntax of plain .js files?

@jrieken
Copy link
Member

jrieken commented Jan 18, 2016

Yes

@kumarharsh
Copy link
Contributor

@jrieken shouldn't eslint and babel-eslint be doing that?

@marc314
Copy link

marc314 commented Apr 13, 2016

+1 I can't use VSCode at all b/c of this.. My code uses a ton of obj spread, so I am forced to use a different editor 👎

@jrieken
Copy link
Member

jrieken commented Apr 13, 2016

Sorry to hear that. Since recent we do have an option to turn off validation for JavaScript - "javascript.validate.enable": false. That setting and a linter extension that supports object spread (like eslint) should bring you in a more comfortable spot.

@marc314
Copy link

marc314 commented Apr 13, 2016

@jrieken
// Place your settings in this file to overwrite the default settings
{ "javascript.validate.enable": false }
Doesn't seem to effect the red ~ for me... Am I doing it wrong?

image

@jrieken
Copy link
Member

jrieken commented Apr 13, 2016

two questions:

  • what version of vs code are you running?
  • this is a JavaScript file, not TypeScript?

@marc314
Copy link

marc314 commented Apr 13, 2016

This is a .js file (not .jsx or .ts)...

image

@jrieken
Copy link
Member

jrieken commented Apr 14, 2016

@dbaeumer Do you have ideas why that is?

@kumarharsh
Copy link
Contributor

@marc314 Try using the 0.10.15-insider build, and see if it changes... That same code seems to be working fine for me.

@dbaeumer
Copy link
Member

@jrieken the setting in not available in 0.10.11 (intellisense doesn't propose it either in that build)

@jrieken
Copy link
Member

jrieken commented Apr 14, 2016

Ok. mystery solved - @marc314 You got two options: Try out the 0.10.15-insider or wait for the next stable build is coming out very, very soon.

@marc314
Copy link

marc314 commented Apr 14, 2016

@jrieken @kumarharsh @dbaeumer Thanks guys! I installed the insider build and it solved my issue. Looking forward to the next stable build as well. Much obliged!

@albertogasparin
Copy link

Just updated to v1.0 but spread operator is still marked as an error 😞
I've also added jsconfig.json with target es6 to my project, but no luck

@jrieken
Copy link
Member

jrieken commented Apr 15, 2016

@albertogasparin Object spread is not es6 but up for es7 discussion. There is a setting to disable validation such that VS Code doesn't complain about the future there.

@pavestru
Copy link

Regarding this, as a newcomer to VS Code I found the official docs very helpful.

@tracker1
Copy link

To add what @jrieken has, you can use the eslint plugin to have eslint run, it will catch most of the same errors, but may miss some. I'm just ignoring these for now, still annoying.

@DennisBecker
Copy link

The issue still exists - I'm using VS Code 1.7 and ESLint plugin for React.js

@dongjinahn
Copy link

dongjinahn commented Nov 10, 2016

i'm using vscode version 1.7.1
with eslint version 3.9.1 both on global and local
and just adding "javascript.validate.enable": false in settings.json(the one pops up with cmd+,) resolved the problem.
now i don't see any eslint warnings about spread operator. no restart/reload required!

@DennisBecker
Copy link

What you do is disabling JavaScript errror detecton in VS Code which is a bad idea. ESLint may not find all issues or errors in your code.

@dongjinahn
Copy link

ok i know it would be better vscode supports spread operator natively.
i just made some kind of footnote for those
who confused vscode doesn't support the operator not at all.
And i also quite trust eslint thought. thank you for your quick replying @DennisBecker !

@ghost
Copy link

ghost commented Nov 16, 2016

@marc314 Use Object.assign for now if you want to get rid of that red squiggles.

@Law78
Copy link

Law78 commented Nov 17, 2016

I've the same issue and I'use the latest version of VSCODE, the spread operator isn't recognized.

@kumarharsh
Copy link
Contributor

The thing is that this depends on Salsa, which is itself written on top of Typescript. If I am interpreting discussions in older issues](#3804) correctly, until Typescript doesn't gets these features, Salsa won't, and by extension JS in vscode won't. We can only wait until TS gets better ES8 support, which seems to coming soonTM.

@DerGernTod
Copy link

really unfortunate, since this actually works but gets detected as an error:
var arr = [ ...state.slice(0, i), {...state[i], likes: state[i].likes + 1}, ...state.slice(i + 1) ]
it works up until the {...state[i] stuff. (as of wes bos video about redux (around 8:50): https://www.youtube.com/watch?v=BWN-9bF51BU

@Anupheaus
Copy link

Why is this issue closed? It is important that this gets fixed! I feel this is a bug and should be fixed in vs code.

@jrieken jrieken added *duplicate Issue identified as a duplicate of another issue(s) upstream Issue identified as 'upstream' component related (exists outside of VS Code) labels Dec 1, 2016
@jrieken
Copy link
Member

jrieken commented Dec 1, 2016

This issue is a duplicate of microsoft/TypeScript#2103 which will come with TypeScript version 2.1.3. Please do not comment here but on the actual issue.

@halliej
Copy link

halliej commented Dec 1, 2016

Guess it's back to Atom...

@kumarharsh
Copy link
Contributor

It's coming in 1.8!!!

@Mellbourn
Copy link

@kumarharsh that sounds great. Do you have a reference?

@kumarharsh
Copy link
Contributor

@Mellbourn: #3804 (comment)

@XidongHuang
Copy link

XidongHuang commented Feb 10, 2017

Hey, does this problem be solved? I updated my VS code to 1.9, but still get the error warning in redux programming like

...
case "CHANGE_NAME": 
               { state = {...state, name: action.payload}; 
                 break;}
...

Is is any hints about it?

update:
Fixed it, just as mentioned above, need to update Typescript to the latest version.

@Noyabronok
Copy link

I'm on VS Code version 1.10 and I thought I had this problem too, but then I realized that the code line above didn't have a closing semicolon. Adding the semicolon fixed the problem.

@tracker1
Copy link

tracker1 commented Mar 14, 2017

All my source is under my profile directory... in my profile, I've setup a package.json in my profile root, configured ~/.eslintrc to my desired baseline configuration... from there, disable the JS warnings, and install the ESLint extension.

Now I just see eslint errors... doesn't help when editing outside my profile, but works well enough for my own use case.

Also, I do setup a per-project eslint.. the baseline in the profile root is a fallback when editing other things that aren't a project, or don't have it setup yet.

@whxaxes
Copy link

whxaxes commented Jul 13, 2017

disabled javascript validation and jshint, use eslint only...

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests