privatenumber / tsx

⚡️ TypeScript Execute | The easiest way to run TypeScript in Node.js
https://tsx.is
MIT License
9.53k stars 146 forks source link

Using `typeof` in REPL results in `undefined` output #327

Open coreyward opened 1 year ago

coreyward commented 1 year ago

Problem

I noticed that when using the REPL (yarn tsx), most expressions with typeof result in the output line being undefined. If it's in a ternary it seems to be okay, though.

Screenshot 2023-09-27 at 12 22 31 PM

Expected behavior

I expected this to match the behavior of the Node REPL, outputting the resultant value of the expression.

Minimal reproduction URL

https://github.com/esbuild-kit/tsx/assets/81224/eacf8fc5-8b7b-4085-b2b9-79a3b6c02d23

Version

v3.13.0

Node.js version

v18.16.1

Package manager

yarn

Operating system

macOS

Contributions

privatenumber commented 5 months ago

This is blocked by https://github.com/evanw/esbuild/issues/3502, but we may be able to hack around this by wrapping it in a IIFE: https://esbuild.github.io/try/#dAAwLjE5LjcAACgoKSA9PiB0eXBlb2YgMSkoKQ