-
I am trying to convert an object literal into a class extended with polytype using class-transformer, but I'm running into the following issue:
The below code reproduces this error.
|
Beta Was this translation helpful? Give feedback.
Answered by
fasttime
Apr 17, 2022
Replies: 1 comment 1 reply
-
I believe that class-transformer is assuming that every constructor has a prototype. I don't know why they are doing that, but I can think of other cases where that code would fail. You may want to report this issue to class-transformer. import { plainToInstance } from "class-transformer";
function Base() { }
Object.setPrototypeOf(Base, null);
class Derived extends Base { }
// throws error
const obj = plainToInstance(Derived, { }); Note that in this example, |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
aru-py
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe that class-transformer is assuming that every constructor has a prototype. I don't know why they are doing that, but I can think of other cases where that code would fail. You may want to report this issue to class-transformer.
Note that in this example,
Derived
is a valid, instantiable and subclassable class.