Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate type definition does not represent the docs #594

Closed
TheSinding opened this issue Jun 4, 2020 · 0 comments · Fixed by #596
Closed

Populate type definition does not represent the docs #594

TheSinding opened this issue Jun 4, 2020 · 0 comments · Fixed by #596

Comments

@TheSinding
Copy link
Contributor

TheSinding commented Jun 4, 2020

Hi.

Description

The type definition for the populate hook does not correspond to the provided documents.
In the docs here, it says

schema Argument Type Default Description
include Array< Object > or Object   Continue recursively join records to these records.

Which would mean you would be able to do

const schema = {
  include: [
    {
      service: 'users',
      nameAs: 'authorItem',
      parentField: 'author',
      childField: 'id',
    },
    {
      service: 'users',
      nameAs: 'readers',
      parentField: 'readers',
      childField: 'id'
    }
  ],
};

module.exports.after = {
  all: populate({ schema })
};

Instead this results in a typescript error similar to this one:
Type '{ service: string; nameAs: string; parentField: string; childField: string; }[]' has no properties in common with type 'Partial<PopulateSchema>'

The problem

I believe this line is the problem.

include: Partial<PopulateSchema>;

The proposed fix

It should look like

    include: Partial<PopulateSchema> | Array<Partial<PopulateSchema>>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant