JavaScript: destructuring binding#3435
Conversation
2edf82b to
732de02
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3435 +/- ##
==========================================
+ Coverage 85.91% 85.94% +0.02%
==========================================
Files 239 239
Lines 58851 58963 +112
==========================================
+ Hits 50563 50673 +110
- Misses 8288 8290 +2 ☔ View full report in Codecov by Sentry. |
732de02 to
ec3b205
Compare
|
Rebased on the latest master branch. |
|
@masatake Thanks for rebasing! I have had this one on my todo list for a while. I will try to get to it soon. |
|
It seems to be working to a limit. Deconstruction in a multilines block of code fails: files.push({
relative, // <----
basename: name,
absolute: loc,
mtime: +stat.mtime
});I don't know if it is related but the following form fails as well: computed: {
...mapGetters([
'getAsylumAssistant',
'getModel',
'getType',
]),
},I thought these forms would work but apparently not: this.stagedlocalRecord = { localRecord, localRecordIndex }
// ---
return this.saveData({ partyId, id, data, rubyType: dbTypes[type], jsType: type })
// ---
createDocketEntryModel ({ commit, state }, requestData) {
// ...
}And there might be more but it takes too long for me to check all the warnings 😅 |
|
@AdrienGiboire thank you. I don't understand this. Is I cannot find the notation in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment. |
This assumes that |
|
@jafl Thank you. So the question is, in which context can we use the shorthand syntax? |
|
Here it describes the case you're wondering about, especially this part:
Knowing that it should support default values.
Basically, if a variable is between |
ec3b205 to
3b52348
Compare
|
@AdrienGiboire Thank you. I found even this input causes the warning message. It seems that we must improve skipArgumentList(). I will inspect this one more. |
Could you provide an example input that node accepts? |
Did you mean to run |
You are correct. However, even though I specified /tmp/foo.js, I got an error. |
|
You can try something like this: const embedded = { foo: 'bar' }
const something = {
...embedded,
baz: 'fox',
} |
|
Thank you. Based on your hit, I modified /tmp/foo.js: Works fine. Thank you. I cannot remember what we were talking about quickly. But I guess the issue is about |
I found two issues here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax |
|
It makes sense but at the same time would it not be legit to have the definition? For example, you can have something like: It would make sense to have the definition of the function referenced. What do you think? |
|
This is a difficult question. However, regarding the example, In my understanding, this is the same as: Am I correct? The Added after commenting My understanding may be correct. |
|
|
Surprisingly, the change for skipping spread operators works well with the current master branch. So I can submit it as a standalone pull request. |
Related to universal-ctags#3435. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Related to universal-ctags#3435. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
This tells spread syntax. |
Pretty much, yes.
It does look good 👍
I'm not sure I understand what you mean. And I know nothing about Lisp so I can't relate ^^' I tried googling but I have not seen |
|
@AdrienGiboire Sorry, after rereading the page at developer.mozilla.org, "spread syntax" is the correct word. |
With this change, the parser skip "..." and the subsequent expression. ref. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax Related to universal-ctags#3435. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
343d606 to
68ee390
Compare
|
@jafl, can I merge this? |
|
|
68ee390 to
501e14b
Compare
|
@jafl, can I merge this? |
cf7d4ab to
617d290
Compare
Close universal-ctags#1112. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
… name: name, ...} Signed-off-by: Masatake YAMATO <yamato@redhat.com>
A computed object property, surrounded by [ and ], should not be extracted as variable. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
…ing (universal-ctags#3435) Signed-off-by: Masatake YAMATO <yamato@redhat.com>
617d290 to
b719aec
Compare
Close #1112.
Limitations:
If an object literal is specified as a default value in object restructuring, the parser may fail to extract the variable (or constant):
I will try to remove this limitation.
keyin[key]is extracted unexpectedly.the parser fills the signature field for
userDisplayNamewith a wrong value.fis not tagged withfunctionkind.I will not try to fix this. I cannot find any easy way to remove this limitation.
ref. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment