-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Issue with transpiling + destructuring #15
Comments
tonygentilcore
pushed a commit
to WildcatIP/other.js
that referenced
this issue
Jan 2, 2017
There are some issues w/ it in prod. Notably: azu/jsdoc-to-assert#15
azu
added a commit
to azu/babel-plugin-jsdoc-to-assert
that referenced
this issue
Jan 3, 2017
@tonygentilcore Thanks for report. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Foo =
/**
* @param {?string} x - param.
*/
function Foo(_ref) {
var x = _ref.x;
_classCallCheck(this, Foo);
this.x = x;
}; Maybe enabling {
"passPerPreset": true,
"presets": [["es2015", { "modules": false }], "stage-2"],
"plugins": [
"jsdoc-to-assert",
],
} Result: function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Foo =
/**
* @param {string} x
*/
function Foo(_ref) {
var x = _ref.x;
_classCallCheck(this, Foo);
console.assert(typeof x === "string");
this.x = x;
}; |
Unfortunately, |
Another snippet to use {
"passPerPreset": true,
"presets": [
[
"es2015",
{
"modules": false
}
],
"stage-2",
[
{
"plugins": [
"jsdoc-to-assert"
]
}
]
]
} Maybe, We should start from creating minimum reproduce repository... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a class w/ destructured params in its constructor like this:
My
.babelrc
looks like this:And the code is incorrectly generated like this:
NOTE The assert reads x before it's defined.
I'd expect it to be:
NOTE that the destructuring happens before the assertion. The current order would also work if the assertion were based on
_ref.x
instead ofx
.The text was updated successfully, but these errors were encountered: