> How is VSCode related to JavaScript? You have ignored the context from Jordan’s email (emphasis added):
>> again, `Object.keys({ y })[0]` will give you the string `y`, and will >> survive refactoring tools. you can even do `function nameof(obj) { return >> Object.keys(obj)[0]; }` and then `nameof({ y })`. VSCode is a popular editor that supports JavaScript *and* is a refactoring tool. Rename refactoring was the subject I was responding to. There are a number of reasons VSCode has implemented rename refactoring in this fashion. Not the least of which is that an editor cannot fully understand user intent. Let us say, for example, you are working with Gulp: ``` const cwd /*1*/ = "."; gulp.src("*.js", { cwd /*2*/ }); ``` If you were to rename `cwd` at (1) and it *also* renamed the `cwd` property at (2), you would have introduced an error in the call because a `cwd` option to gulp has a special meaning. Since the editor doesn’t know the intent of the user may be to rename *both* symbols, it remains conservative and choses only to rename the binding and its references, producing: ``` const currentDir = "."; gulp.src("*.js", { cwd: currentDir }); ``` There is also the issue of collisions: ``` const foo /*1*/ = 1; f({ foo /*2*/, bar: 2 }); ``` If I were to use a refactoring tool to rename `foo` at (1) to `bar`, it would *not* be safe to rename the property at (2) as well as it would introduce a semantic error that would prevent the entire script from executing. In the context of Jordan’s email, that means that `Object.keys({ y })[0]` would *not* necessarily survive refactoring tools. From: es-discuss <es-discuss-boun...@mozilla.org> On Behalf Of guest271314 Sent: Monday, June 17, 2019 7:40 AM Cc: es-discuss@mozilla.org Subject: Re: Re: What do you think about a C# 6 like nameof() expression for > In VSCode, if you rename ‘foo’ to ‘bar’ at /1/, you get this: How is VSCode related to JavaScript? Is the proposal really based on creating ```nameof``` in JavaScript to workaround output at a text editor? Why not file a bug with the individuals who write the code for VSCode or just write a text editor code from scratch which does what you want as to "refactoring". Or write the code by hand and test the code to avoid having to rely on _any_ text editor to catch your mistakes?
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss