Skip to content

Model.$set definition conflicts with implementation #244

Closed
@katanacrimson

Description

@katanacrimson

As above. Typescript is currently throwing a fit, because...

This

$set<R extends Model<R>>(propertyKey: string, instances: R|R[], options?: IAssociationActionOptions): Promise<this>;

and this

$set(propertyKey: string, instances: any, options: any): Promise<this> {

are incompatible.

Right now, Typescript is insisting that the third parameter for $set must conform to the interface IAssociationActionOptions, which both conflicts with the implementation and prevents passing save: false, which is useful when creating multiple associations while disallowing null values.

Example:

    const xref = new UsergroupPermissions({
      value: PermissionValue.NO
    })
    await xref.$set('usergroup', usergroup, { save: false })
    await xref.$set('permission', permission, { save: false })
    await xref.save()

    // ...

Resulting Typescript error:

    (52, 47) Argument of type '{ save: boolean; }' is not assignable to parameter of type 'IAssociationActionOptions | undefined'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions