Skip to content

Bug in stacktrace-gps: Method Name Matching Fails in TypeScript with Typed Return Values #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
x842013824 opened this issue Dec 14, 2023 · 0 comments
Labels

Comments

@x842013824
Copy link

In TypeScript, when using stacktrace-gps, the _findFunctionName method's regular expression fails to match method names if a return type is specified.

Expected Behavior

The method name should be correctly identified in the stack trace, regardless of the presence of a typed return value in TypeScript.

Current Behavior

method name is not correctly identified in the stack trace, , maybe I can get the name of the last method without the return type when lineNum less 20.

Steps to Reproduce (for bugs)

  1. Define a TypeScript method with a specific return type, e.g., methodName(): ReturnType
  2. Generate a stack trace using stacktrace-gps
  3. Observe that the method name is not correctly identified in the stack trace

Context

I can't get the method name anymore, maybe I can get the name of the last method without the return type. My temporary solution is to drop the return type and use Typescript's automatic inference feature. But I would prefer to add a regular expression for this case directly in the _findFunctionName syntaxes

Your Environment

  • Package version: stacktrace-gps@^3.0.4 [email protected]
  • Browser name and version: chrome 120.0.6099.71

Possible Solution

add a regular expression for this case directly in the _findFunctionName syntaxes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant