Microsoft/TypeScript

`tsc` loses the class name in sourcemap

Open

#55,912 建立於 2023年9月29日

在 GitHub 查看
 (0 留言) (4 反應) (0 負責人)TypeScript (6,726 fork)batch import
Domain: Source MapsHelp WantedPossible Improvement

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

🔎 Search Terms

  • stack trace
  • lose class name

🕗 Version & Regression Information

Now I use TypeScript v5.2.2. This is not a critical bug, so I did not pay attention when it appeared.

💻 Code

// tmp.ts
class MyClass {
  static staticMethod() {
    throw new Error('Error in static method');
  }
}

MyClass.staticMethod();

Enable sourceMap in tsconfig, compile this code with tsc and then run compiled file with --enable-source-maps option:

tsc tmp.ts
node --enable-source-maps dist/tmp.js

🙁 Actual behavior

Error: Error in static method
    at Function.staticMethod

As you can see, the class name is missing from the stack trace. This bug appears only when the error occurs in static methods.

🙂 Expected behavior

Error: Error in static method
    at MyClass.staticMethod

貢獻者指南