[英]What does @babel/plugin-transform-block-scoping do that isn't part of babel's core behavior?
The docs leave a lot to be desired, as is sometimes the case with Babel plugins. 文档有很多不足之处,有时 Babel 插件就是这种情况。
This plugin also validates all
const
variables.此插件还验证所有
const
变量。 Reassignment of constants is a runtime error and it will insert the necessary error code for those.常量的重新分配是一个运行时错误,它会插入必要的错误代码。
I don't know what this means?我不知道这是什么意思? Isn't that always going to cause a runtime error?
这不是总是会导致运行时错误吗?
And the example it provides only uses let
and var
which furthers my confusion.它提供的示例仅使用了
let
和var
,这使我更加困惑。
In es5, const
does not exist.在 es5 中,不存在
const
。 If you are compiling your code down to es5, all your const
declarations will become var
declarations.如果您将代码编译为 es5,则所有
const
声明都将变为var
声明。 The plugin will insert runtime code for the const
values to throw an error if they are assigned a new value, likely by converting references to accessor function calls.该插件将为
const
值插入运行时代码,以便在为它们分配新值时抛出错误,可能是通过将引用转换为访问器 function 调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.