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
Search Terms: ES5 class javascript prototype assignment constructor function
Expected behavior: In the example below, I expect the test.class properties include the one from the prototype. The behavior shouldn't depend on whether or not test.class was default-assigned or not.
Actual behavior: The prototype assignment doesn't seem to work when default assignment is used. @sandersn thinks this is a bug but isn't surprised.
vartest={};test.class=test.class||function(name){functiongetName(){returnname;}this.name=getName();}test.class.prototype={add: function(i){}};vart=newtest.class("test");t.namet.add// EXPECTED: Binds to `add` from the prototype, ACTUAL: doesn't//// Same pattern works with a straightforward assignment://vartest2={};// Removed `test.class ||` test2.class=function(name){functiongetName(){returnname;}this.name=getName();}test2.class.prototype={add: function(i){}};vart2=newtest2.class("test");t2.namet2.add// ACTUAL: `add` bound correctly
Bug seen in actual VS customer code.
TypeScript Version: 3.9.2
Search Terms: ES5 class javascript prototype assignment constructor function
Expected behavior: In the example below, I expect the
test.class
properties include the one from the prototype. The behavior shouldn't depend on whether or nottest.class
was default-assigned or not.Actual behavior: The prototype assignment doesn't seem to work when default assignment is used. @sandersn thinks this is a bug but isn't surprised.
Related Issues: #39166 from same user code
Code
Compiler Options
Playground Link: Provided
The text was updated successfully, but these errors were encountered: