You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notice that the generated wrapper function has the name foo, but the inner function passed to _generator (which executes the original code) does not have a name.
Would it be possible for TS to emit the function name also for this inner function? (Maybe this would need some helper variable so that the inner function can correctly reference the wrapper function, in this example _c:)
We use an embedded TypeScript Compiler in an application where the user can create and edit scripts, which are executed using Jurassic (ES5). When an error occurs, we use the stack trace and filter out frames whose line numbers cannot be mapped by the source map, or which originate from the Promise polyfill. This stacktrace is displayed to the user.
However, because the TS does not emit a name for the inner generator function, the stack looks like this for async functions:
at anonymous (MyScript.js:7)
at anonymous (MyScript.js:2)
at MyScript.js:13
whereas if TS could emit the name, it would look like this:
at bar (MyScript.js:7)
at foo (MyScript.js:2)
at MyScript.js:13
Would this be possible?
Thanks!
The text was updated successfully, but these errors were encountered:
We may opt to emit the inner functions as foo_1 (or foo_awaiter_1) as we do for other emit where we need to give something a name. That could still help as far as identifying functions in call stacks.
I'm redirecting the conversation from #34977 here.
@RyanCavanaugh, @DanielRosenwasser: Since #34977 is marked "Bug" and "Rescheduled" and has 4.2 for its milestone, do we want to consider fixing this for 4.2? Since this could increase file-size on async-function heavy source that downlevels to ES2015 or lower, would we want to put this behind a flag?
RyanCavanaugh
added
Won't Fix
The severity and priority of this issue do not warrant the time or complexity needed to fix it
and removed
Bug
A bug in TypeScript
labels
Feb 23, 2024
This doesn't seem like an important scenario for modern JS development - folks can either target ES6 which is supported basically everywhere, or use an alternate transpiler with stricter adherence semantics if this is important for their scenario.
Hi, sorry if this is a duplicate.
TypeScript Version: 2.2.0-dev.20170116
Code
When writing an async function and compiling down to ES5:
TypeScript emits code like this:
Notice that the generated wrapper function has the name
foo
, but the inner function passed to_generator
(which executes the original code) does not have a name.Would it be possible for TS to emit the function name also for this inner function? (Maybe this would need some helper variable so that the inner function can correctly reference the wrapper function, in this example
_c
:)We use an embedded TypeScript Compiler in an application where the user can create and edit scripts, which are executed using Jurassic (ES5). When an error occurs, we use the stack trace and filter out frames whose line numbers cannot be mapped by the source map, or which originate from the Promise polyfill. This stacktrace is displayed to the user.
However, because the TS does not emit a name for the inner generator function, the stack looks like this for async functions:
whereas if TS could emit the name, it would look like this:
Would this be possible?
Thanks!
The text was updated successfully, but these errors were encountered: