Closed mwildehahn closed 4 years ago
it's because of TS strict mode, where forcing code to have initialization code of constructor. typically in ORM though, (i meant all kind of, not just this library) this restriction is not valid. the intention of this limit is to make sure class instance being created with all the member variable being initialized, but in ORM we "deserialize" DB schema into js object. thus we don't use those constructor anyway - you can checkout TypeORM for same issue.
in short, i can allow constructor but that's not gonna solve issue of data => JS scenario.
i recommend to do public image!: string
and create static method like public static async create()
if you need such an helper method.
Ah that makes sense. Thanks!
On Tue, May 12, 2020 at 7:25 PM Kurt notifications@github.com wrote:
it's because of TS strict mode, where forcing code to have initialization code of constructor. typically in ORM though, (i meant all kind of, not just this library) this restriction is not valid. the intention of this limit is to make sure class instance being created with all the member method being initialized, but in ORM we "deserialize" DB schema into js object. thus we don't use those constructor anyway - you can checkout TypeORM for same issue.
in short, i can allow constructor but that's not gonna solve issue of data => JS scenario. i recommend to do public image!: string and create static method like public static async create() if you need such an helper method.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/balmbees/dynamo-types/issues/62#issuecomment-627705763, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFMAUN5SRFOMQRM7GLVPXTRRIAJVANCNFSM4M7JSE4A .
I'm running into the following error when trying to define a class:
The error is on any of the
@Decorator.Attribute
fields:If I define a constructor though, it says I don't conform to the interface defined here: https://github.com/balmbees/dynamo-types/blob/d6befcca35f5a82f2137003720b21a473c091dab/src/table.ts#L77.
I was looking at extending that interface to
new(...args: any[])
but was curious why I would need to do that.