Skip to content

context.result type is too wide #3624

@AshotN

Description

@AshotN
// Main data model schema
export const companySchema = Type.Object(
  {
    id: Type.Number()
  },
  { $id: 'Company', additionalProperties: false }
)

// Schema for creating new entries
export const companyDataSchema = Type.Object(
  {
    id: Type.Number()
  },
  {
    $id: 'CompanyData',
    additionalProperties: false
  }
)
create: [
        async (context, next) => {
          const beforeResult = context.result
      
          await next()

          const afterResult = context.result
        }
      ]

The type for beforeResult and afterResult both come out

{
  id: number
} | Paginated<{
  id: number
}> | {
  id: number
}[] | undefined

{ id: number } :☑️

Paginated<{ id: number }>: Can context.result even be paginated in a create hook? Type doesn't go away even if I try to disable pagination ❌

{ id: number }[]: This seems to happen even if multi: false, but that may still be correct; since the input of a single object can maybe produce an array output. ⚠️

undefined: in an around hook, this should be the only type before await next() and then it should go away after. AFAIK Feathers doesn't allow empty creates, so there will always be a result.

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