Class name not being inherited in anonymous classes results in decorated classes losing their original name with Node 12.16.0 and above #37157
Labels
Rescheduled
This issue was previously scheduled to an earlier milestone
Working as Intended
The behavior described is the intended behavior; this is not a bug
Milestone
TypeScript Version:
3.6.2
,3.8.2
Search Terms: decorator, anonymous class
Expected behavior:
Using a decorator which modifies the constructor of a class returns a class with the same name as the original class.
Using more than one decorator which modify the constructor of a class returns a class whose prototype's name is the original class's name.
Actual behavior:
Using a decorator which modifies the constructor of a class replaces the name of the class with the empty string.
Using more than one decorator which modify the constructor of a class also replaces the name of the prototype of the class with the empty string.
Additional details:
Node
12.16.0
introduces a change which makes the.name
property of an anonymous class the empty string: #31830.From a comment in that issue:
However, in the future that change may still come back to V8 and continue affecting the decorator behavior.
Code
Replicator:
Expected result with
12.16.0
:Expected result with
12.15.0
:The following is the tsconfig that was used:
The following comment provided a possible workaround: nodejs/node#32035 (comment)
Decorator function which loses original name:
Example decorator function which preserves the original name:
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: