Open gbcreation opened 1 year ago
Nothing wrong with your code. TypeScript definitions have been recently added to the project and they are hard to code and unit test. Thanks for the bug report
I improved the type definitions with defaultTo() in v4.4.4, released just now. Can you update and confirm that it fiixed your issue ? Thanks
Thank you very much for your quick answer.
v4.4.4 fixes the typescript error for the ObjectModel example in the Default values assignment chapter.
It also fixes it for the code sample in my first post, however I now get another error:
class Character extends Model(classSchema).defaultTo(defaultValues) {}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// |_ typescript: Base constructors must all have the same return type
Sounds like a limitation of TypeScript, based on my understanding of this issue: https://github.com/microsoft/TypeScript/issues/40110
I can remove the type error but will lose the ability to return the default value as type when no arguments are passed.
Hello,
Given this code sample:
TypeScript underlines
{ id: "1" }
with the error "Expected 0 arguments, but got 1" when creating a new instance of theCharacter
class.Is there something wrong in this code?