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
Need to allow to use generics for "this" type, like this: this<T>
classCollection<T>extendsArray<T>{map<U>(callbackfn: (value: T,index: number,array: T[])=>U,thisArg?: any): this {// this method will return this<T>, but I want to return this<U>returnnew(this.constructorasany)(...super.map(callbackfn,thisArg));}}
example of usage:
newCollection(newModel(1,"Mercedes"),newModel(2,"BMW"),newModel(3,"Ford")).map(model=>model.engine).forEach(engine=>engine.serialNumber);// here compiler should see engine.serialNumber
The text was updated successfully, but these errors were encountered:
Need to allow to use generics for "this" type, like this:
this<T>
example of usage:
The text was updated successfully, but these errors were encountered: