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
{{ message }}
Repository navigation
Prototype assignment should take the type of the initializer and not require a literal #39166
This is a feature request based on actual VS customer code.
TypeScript Version: 3.9.2
Search Terms: ES5 class javascript prototype assignment constructor function
Expected behavior: In the example below, the prototype for test.class should include properties from testPrototype.
Actual behavior: Per Nathan Shively-Sanders (@sandersn) this pattern is recognized in the binder and only uses syntactic information, therefore does not use the type information from testPrototype .
Related Issues:#39167 from same user code. Also #33454 maybe?
Code
vartest={};test.testPrototype={add: function(i){}}test.class=function(name){functiongetName(){returnname;}this.name=getName();}test.class.prototype=test.testPrototype;vart=newtest.class("test");t.namet.add// EXPECTED: Binds to `add` from the prototype, ACTUAL: doesn't//// Same pattern works when a literal is assigned to the prototype://vartest2={};test2.class=function(name){functiongetName(){returnname;}this.name=getName();}// replaced `test.testPrototype` with a literal test2.class.prototype={add: function(i){}};vart2=newtest2.class("test");t2.namet2.add// ACTUAL: `add` bound correctly
Activity