Sunday 30 December 2018

How to automatically apply argument to class constructor?

I want to instead of writing following:

map((value) => new User(value))

Somehow write something like this:

map(new User)


User is es6 class:

class  User {
  constructor(public name: string) {}
}

const map = <T, R>(project: (value: T) => R) => {}

I am not sure if this is possible or not.



from How to automatically apply argument to class constructor?

No comments:

Post a Comment