ts-node icon indicating copy to clipboard operation
ts-node copied to clipboard

Bug with Function.prototype.toString method

Open agroupp opened this issue 6 years ago • 1 comments

Code:

class A {}
console.log(Function.prototype.toString.call(A))

should be: 'class A {}'

have now: 'function A() {\r\n }'

ts-node version 8.9.1

agroupp avatar May 01 '20 13:05 agroupp

You omitted your tsconfig.json so I'll assume you're compiling with default TypeScript compiler options, which downlevel to ES3. (docs: https://www.typescriptlang.org/docs/handbook/compiler-options.html) You can verify this by compiling your code with tsc and inspecting the output .js. ts-node is doing the same thing, just in-memory.

You might be asking for something like #973. If so, you can share your use-case and requirements over there.

Closing for now because I'm pretty sure this answers it. If I have misunderstood, please let me know and we'll happily reopen the ticket.

cspotcode avatar May 01 '20 13:05 cspotcode