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
Took me a bit to drill into but in VS Code we have cases where we use a decorator on a class which also has static factory function. Those factory function use the original class constructor, not the decorated one. Checkout the sample, this gist is that calling Foo.create doesn't go through the decorated-code
The factory function should invoke the decorated class-contructor. In the SWC output the class and its variable use the same name and I guess JS prefers the class then. In TS the class-variable uses a different name and its static uses refer it by that name.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Describe the bug
Took me a bit to drill into but in VS Code we have cases where we use a decorator on a class which also has static factory function. Those factory function use the original class constructor, not the decorated one. Checkout the sample, this gist is that calling
Foo.create
doesn't go through the decorated-codeInput code
Config
Playground link
https://play.swc.rs/?version=1.2.197&code=H4sIAAAAAAAAA32Qy26DMBBF18xXTFcBiYRVN2ETKVW2VP0B5LpDSxRsazwoRRH%2FXlvBpN3UG7%2FOPZYvdKPR0luD5J%2BPF%2BX90Q5OSS6KP0n2eFruiz0qM%2BENsqqqDuK39O1Iy5aYLUO2atq8wBsyycgG36i7BGinrfHCo07aEsM0DmTElyhfvX8QlosaZ8ia93NMflDXG3pl64hlytsSN0YNtClxAYKtuZoEvJDX3LtgWV%2B688VTUa9STxICYmVy1HRReof%2FQXYu7RL8OImx5cNtDTPA4W%2BXoOMaT9aG%2BiDzoqTXqJmUUGwLshQ3dI1YHo3Bg2H8KiayM8w%2FGozC%2B7MBAAA%3D&config=H4sIAAAAAAAAA0WOTQ6DQAhG70JcNmpceoPewc1kxL84wwQw1RjvXqzR7sjj%2Bx7skIkfMDioYVBNdVFMQjG%2FoCgx5sR9IR%2FPHl6Aq5%2BXFi3dNPkkmaFJPNQ7JMeCfE6yRXWrRXRLKJ7HpBZTMdS5WfAFLXpiZ3KBWnnBw9aOe1QroVRlVVphJhJ8KmGMY7edek8hMYr8Vy728508zBWoXU6w%2Fz4wpwutCSO9oyJTeo7e0qv5BTnH4YgMAQAA
Expected behavior
The factory function should invoke the decorated class-contructor. In the SWC output the class and its variable use the same name and I guess JS prefers the class then. In TS the class-variable uses a different name and its static uses refer it by that name.
See how
Foo.create
callsnew Foo_1();
instead ofFoo
: https://www.typescriptlang.org/play?module=2#code/FAMwrgdgxgLglgewgAgKYGcCsBhANgQ3XWwQFsAHfGAChnwCcBzVGALmQDFJZEIBKdvggBPZAG9gASAD0sgAIx0AWlQAPcqlgr69BPSnho8JMgD61PuOT0WYeigBKqELk0wAdFCToY9MLFoGZhgAGmQgsFJUCEUwmAALOHRPb19-GD0+AG5kAF8pAHkAIwArN3cAE2c4CFQABV0NehhhalMwgHIIfCiOsOKy2HdggoB3CAaEJpaAEQwoejhyDPpAphZO7t6+AEJswtLy9BZJjJaNApA2uKCWfckBo5PdM+ELq9N3cheEc9Qb9Yeb6-X5vVD3GwwOwoUxZYD5YByDA4AhEEgUKjAKCo9CcBAIcTAKQ+KhwKDIBaoKioCyEySSSHQ5C1UZ4hAWOGSBHIHkU1J+WB6WlifK5IAActual behavior
The static factory function should use the decoratored constructor calls
Version
1.2.197
Additional context
This is for microsoft/vscode#150025
The text was updated successfully, but these errors were encountered: