You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using let to declare imported variables in compiled code allows the variables to be scoped to the enclosing block, and enables warnings about redeclarations of identically-named variables:
if(process.env.NODE_ENV==="production"){import{S3}from"aws-sdk";lets3=newS3();s3.abortMultipartUpload(params,function(err,data){ ... });}// S3 and s3 should not be visible here!
The use of var means the S3 variable will be visible anywhere in the enclosing function scope, which is dangerous if process.env.NODE_ENV !== "production".
Ideally (when possible) we would like to use let instead:
Note that const is not an option because imported symbols must be able to change their values whenever the source module gets around to exporting them.
However, using let in the Node REPL means you can't import the same symbol more than once, which can be really annoying. For that reason, when you require("reify/repl"), the compiler should generate var declarations instead (as it currently does).
The text was updated successfully, but these errors were encountered:
Using
let
to declare imported variables in compiled code allows the variables to be scoped to the enclosing block, and enables warnings about redeclarations of identically-named variables:Currently the
import
statement is compiled toThe use of
var
means theS3
variable will be visible anywhere in the enclosing function scope, which is dangerous ifprocess.env.NODE_ENV !== "production"
.Ideally (when possible) we would like to use
let
instead:Note that
const
is not an option becauseimport
ed symbols must be able to change their values whenever the source module gets around toexport
ing them.However, using
let
in the Node REPL means you can'timport
the same symbol more than once, which can be really annoying. For that reason, when yourequire("reify/repl")
, the compiler should generatevar
declarations instead (as it currently does).The text was updated successfully, but these errors were encountered: