#ts-node console.log does not print strings in quotes

17 messages · Page 1 of 1 (latest)

empty shadow
#

I'm searching through ts-node docs and issues, but so far did not find if it is possible at all to have ts-node print to stdout keeping strings inside single or double quotes.

gray ruin
#

and just to confirm, you get the quotes when logging from node directly?

empty shadow
#

Yeah, was checking that, but no. I guess I was confusing with when I am in the REPL.

#

Therefore, my question makes no sense.

gray ruin
#

i believe the quotes are only when they're inside structures

#

unrelated to whether or not you're in the repl

empty shadow
gray ruin
#

ah, i see what you mean

#

expressions vs logs, i suppose

#

it's probably using util.inspect here for the expressions, and console.log also uses it, but i guess not for strings since that wouldn't really help for normal logs

hasty pine
#

for example, if you had console.log("Hello world!");, should the output be Hello world! or "Hello world!"

#

to answer your question, console.log(util.inspect(whatever)) works

empty shadow
#

Nice, will wrap inspect in a simple wrapper for my debugging purposes.

Learned something today. Thank you both!

gray ruin
#

if it's just for debugging, you could also wrap a variable in an object to both trigger the inspect and get a label.

empty shadow
#

Yeah, I do use the object trick a lot. It does help and makes sense for discussion as well.

gray ruin
#

!resolved