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

fix(types): update BelongsToManyGetAssociationsMixinOptions definition #11818

Merged
merged 5 commits into from
Jan 21, 2020
Merged

fix(types): update BelongsToManyGetAssociationsMixinOptions definition #11818

merged 5 commits into from
Jan 21, 2020

Conversation

lojgmyrht
Copy link

@lojgmyrht lojgmyrht commented Jan 12, 2020

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

This will add the joinTableAttributes property to the BelongsToManyGetAssociationsMixinOptions interface.

belongs-to-many.d.ts defines an interface named JoinTableAttributes:

export interface JoinTableAttributes {
  [attribute: string]: unknown;
}

However, this does not seem to be the appropriate type for this property. In belongs-to-many.js, joinTableAttributes is assigned to the attributes property of a set of include options, so I used the same type as the attributes property from IncludeOptions (FindAttributeOptions).

options.include.push({
    association: this.oneFromTarget,
    attributes: options.joinTableAttributes,
    required: true,
    where: throughWhere
});

@papb
Copy link
Member

papb commented Jan 18, 2020

Hello! I see you are a first-time contributor, thank you for taking the time to help Sequelize! I hope to see more PRs from you in the future!

Copy link
Member

@papb papb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add at least one test to make sure your implementation works as intended and to prevent regressions in the future.

Testing the TypeScript typings consists simply on checking if some code can be compiled. In other words, a typings test is just some TS code that should compile. What it does when executed is irrelevant, the test is simply to compile it without errors, as can be seen in our CI configuration (using npm run test-typings) here and here. Since it's just a compilation, getting no output from it means that it passed. Getting a compilation error is a failure. Note that if you directly throw an error from your typings test code, the test will still pass because throwing an error is something that compiles just fine.

For good examples on how to write typescript typings, check the following PRs: #11368 #11378 #11520

Let me know if you need further help!

@codecov
Copy link

codecov bot commented Jan 18, 2020

Codecov Report

Merging #11818 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #11818   +/-   ##
=======================================
  Coverage   96.26%   96.26%           
=======================================
  Files          94       94           
  Lines        9191     9191           
=======================================
  Hits         8848     8848           
  Misses        343      343

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 00211a5...ffbf3da. Read the comment docs.

@papb papb added status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense. labels Jan 18, 2020
@lojgmyrht lojgmyrht removed the request for review from SimonSchick January 20, 2020 20:11
Oliver Emery added 2 commits January 20, 2020 14:27
…ion' of github.com:thrymgjol/sequelize into update-BelongsToManyGetAssociationsMixinOptions-definition
@lojgmyrht lojgmyrht requested a review from papb January 20, 2020 22:03
@papb
Copy link
Member

papb commented Jan 20, 2020

Thank you!!

@papb papb removed the status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action label Jan 20, 2020
@papb papb self-assigned this Jan 20, 2020
@papb papb merged commit 1f42c79 into sequelize:master Jan 21, 2020
@papb papb removed their assignment Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants