Skip to content

Typescript expected number of arguments when using defaultTo() #164

Description

@gbcreation

Hello,

Given this code sample:

import { Model } from "objectmodel"

const classSchema = {
    id: String,
    lastName: [String],
    firstName: [String]
}

const defaultValues = { lastName: "a" }

class Character extends Model(classSchema).defaultTo(defaultValues) {}

const o = new Character({ id: "1" }) // <- typescript: Expected 0 arguments, but got 1.
console.log(o)

TypeScript underlines { id: "1" } with the error "Expected 0 arguments, but got 1" when creating a new instance of the Character class.

Is there something wrong in this code?

Note that I get the same TypeScript error with the ObjectModel example given at chapter Default values assignment in the doc.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions