tsx REPL does not respect NODE_REPL_MODE
environment variable or --use_strict
CLI flag at transpile time
#477
Labels
NODE_REPL_MODE
environment variable or --use_strict
CLI flag at transpile time
#477
Acknowledgements
Minimal reproduction URL
N/A
Version
v4.7.1
Node.js version
v20.10.0
Package manager
N/A
Operating system
Windows
Problem & Expected behavior
Put simply,
tsx
has the same issue I myself reported todeno
a while back here: denoland/deno#13775But I'll re-explain it here anyway just in case.
Node.js supports the
NODE_REPL_MODE
flag documented here or the--use_strict
CLI flag (seemingly undocumented at the time?) to configure the REPL to run in strict mode instead of the default sloppy mode, you can test this with:node
->01
-> Returns1
node --use_strict
->01
-> Strict mode error (expected)Reproducing the same steps above but with
tsx
in place ofnode
results in step 4 still returning1
instead of the expected error. Notice however the following alternative reproduction:tsx
->eval('01')
-> Returns1
tsx --use_strict
->eval('01')
-> Strict mode error (expected, it works now!)The conclusion here is that the runtime itself is respecting the options and running in strict mode, after all it is just regular Node.js in the end, but
tsx
is not running transpilation in strict mode in accordance to these REPL flags, so it transpiles these strict-mode-invalid literals into "resolved" literals that are valid in strict mode, causing unintended odd looking behavior.Contributions
The text was updated successfully, but these errors were encountered: