Closed KostyaTretyak closed 1 year ago
ts-node is compiling the code via typescript compiler before executing it. What happens when you compile via tsc and then run in node? Same stack trace, or different?
@cspotcode, just checked. If the compiled code reads node.js, then the class name is correct:
Error: Error in static method
at MyClass.staticMethod
Ok thanks, can you share that reproduction somewhere? Can be a new git repo, then commit the package.json, tsconfig, .ts source, and compiled .js output. It'll help reproducing locally.
Also, one more thing to try: make sure tsc emits a sourcemap, then run node with --enable-source-maps
ts-node enables sourcemaps and its own mapping of stack traces, so if we can compare ts-node's mapping against what vanilla node is doing, we can see how they both handle sourcemapping.
@cspotcode, I've provided the code above that needs to be tested to see the problem.
Hmm here's what I see:
Error
at Function.Foo.bar
I think I found the culprit. When node
is run with the --enable-source-maps
option, the class name is also lost.
Search Terms
Expected Behavior
The class name must be present.
Actual Behavior
The word "Function" is inserted instead of the class name.
Steps to reproduce the problem
Call this code with
ts-node
:And see the stack trace:
If you run the same code from
node
, the stack trace will be correct:Specifications
ts-node v10.9.1 node v18.17.1 compiler v5.1.6 Ubuntu 22.04