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

chore: better typings for DiscussionListState #3132

Merged
merged 2 commits into from
Nov 9, 2021

Conversation

davwheat
Copy link
Member

Changes proposed in this pull request:

Explicitly define function return types in DiscussionListState.

Defining these help to identify changes that inadvertently change the return type, and are this breaking.

Reviewers should focus on:

Are the requestParams typings correct?

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

Required changes:

  • Related documentation PR: (Remove if irrelevant)
  • Related core extension PRs: (Remove if irrelevant)

@davwheat davwheat added this to the 1.2 milestone Oct 27, 2021
@davwheat davwheat self-assigned this Oct 27, 2021
@@ -2,6 +2,12 @@ import app from '../../forum/app';
import PaginatedListState, { Page } from '../../common/states/PaginatedListState';
import Discussion from '../../common/models/Discussion';

export interface IRequestParams {
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Could we enforce that if q is present in filters, it should be the only key?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooh, that's a good question. Let me have a play.

Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't find a way.

One of the promising things was:

filter: { q: string } | { [key: string]: string } & { q?: never }

but this seemed to not work correctly, for some reason.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I couldn't find a way.

One of the promising things was:

filter: { q: string } | { [key: string]: string } & { q?: never }

but this seemed to not work correctly, for some reason.

Fair enough, let's keep things as is then

@askvortsov1 askvortsov1 merged commit ad2cef7 into master Nov 9, 2021
@askvortsov1 askvortsov1 deleted the dw/discussionliststate-typings branch November 9, 2021 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants