Logan Smyth 90566103a6 v7.0.0-beta.49 | 6 년 전 | |
---|---|---|
.. | ||
src | 6 년 전 | |
test | 6 년 전 | |
.npmignore | 7 년 전 | |
README.md | 6 년 전 | |
package.json | 6 년 전 |
If the argument bound to the catch block is not referenced in the catch block, that argument and the catch binding is removed.
try {
throw 0;
} catch (err) {
console.log("it failed, but this code executes");
}
Is transformed to:
try {
throw 0;
} catch {
console.log("it failed, but this code executes");
}
npm install --save-dev @babel/plugin-codemod-optional-catch-binding
.babelrc
(Recommended).babelrc
{
"plugins": ["@babel/plugin-codemod-optional-catch-binding"]
}
babel --plugins @babel/plugin-codemod-optional-catch-binding script.js
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-codemod-optional-catch-binding"]
});
This codemod updates your source code in line with the following proposal: