1

I have a generic function like this :

export function f<T >(json: Object): T {
return new T()

}

but I got this error when com'T' only refers to a type, but is being used as a value here.

how should i handle this ?

Mohammad Ranjbar Z
  • 1,487
  • 1
  • 10
  • 20
  • 1
    https://stackoverflow.com/questions/17382143/how-to-create-a-new-object-from-type-parameter-in-generic-class-in-typescript – Ivan Mladenov Aug 08 '18 at 06:06

1 Answers1

-4

Try this

export function f<T>(arg: T): T {
    return arg;
}