incorrect arguments by default with `this`
See original GitHub issue๐ญ๐ฎ๐ฌ๐ช๐ฏ๐ฏ๐ฎ๐ฒ๐ท๐ช๐ฝ๐ฎ is incorrectly transpiling my CoffeeScript input:
source
class Component extends React.PureComponent
state: {intent: null, yearMonth: null}
loadData: ({ intent = @state.intent, yearMonth = @state.yearMonth } = {}) =>
@loadable.request =>
Api.get '/admin/document_checks/stat_data', { yearMonth, intent }
.then ({ stats, teams, operators }) => @setState { stats, teams, operators }
incorrect result (indentation issue is there too):
class Component extends React.PureComponent {
// ...
loadData({ intent = intent1, yearMonth = yearMonth1 } = {}) { // ๐ UNDEF
this.state = state; // ๐
this.intent = intent1; // ๐
this.state = state1; // ๐
this.yearMonth = yearMonth1; // ๐
return this.loadable.request(() => {
return Api.get('/admin/document_checks/stat_data', { yearMonth, intent })
.then(({ stats, teams, operators }) => this.setState({ stats, teams, operators }));
});
}
expected:
class Component extends React.PureComponent {
// ...
loadData({ intent = this.state.intent, yearMonth = this.state.yearMonth } = {}) {
return this.loadable.request(() => {
return Api.get('/admin/document_checks/stat_data', { yearMonth, intent })
.then(({ stats, teams, operators }) => this.setState({ stats, teams, operators }));
});
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
c++ - Am I using default arguments incorrectly? - Stack Overflow
Default arguments go in the declaration. And to format the code, paste it in, don't put any backticks, highlight it all, and click...
Read more >Incorrect handling of default arguments for type Type ... - GitHub
Consider a function which takes type and returns instance of that type. This is handled correctly by mypy: from typing import Type,ย ...
Read more >Default function arguments are the devil โ Arthur O'Dwyer
Conclusion: Default function arguments do not directly cause boolean parameter tarpits, but they make their pernicious effects worse. Booleanย ...
Read more >Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
Read more >incorrect number of arguments for default constructor for ...
Hi All, I am getting this error for one of the Type defined as below create or replace TYPE CONTRACTOR_TYPE AS OBJECT (...
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 FreeTop 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
Top GitHub Comments
Have you looked at this? https://github.com/decaffeinate/decaffeinate/blob/master/docs/contribution-guide.md
This definitely appears to be a bug. Hereโs a minimal reproduction:
I think the problem is that itโs inspecting the whole subtree of nodes for default values to assign, when it shouldnโt be doing so with the right hand side of the assignment. I donโt know thatโs the case, but thatโs what it feels like. Iโd be happy to review a PR to fix this.