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

Improve query types #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Improve query types #68

wants to merge 2 commits into from

Conversation

OliverJAsh
Copy link

No description provided.

@@ -18,7 +18,7 @@ import { Contravariant1 } from 'fp-ts/lib/Contravariant'
* @category routes
* @since 0.4.0
*/
export type QueryValues = string | Array<string> | undefined
export type QueryValues = string | Array<string>
Copy link
Collaborator

Choose a reason for hiding this comment

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

@OliverJAsh this is a breaking change because the type is exported and we don't how and if it is used by the library's consumers.

Event if the version is still > 1.0.0, the package have been published from quite a lot by now and in my opinion this kind of changes has to be carefully evaluated.

Why do you propose it?

Copy link
Author

Choose a reason for hiding this comment

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

Why do you propose it?

I think it was just to improve correctness. Consider this example:

declare const x: Query;
Object.entries(x).map(([, queryValues]) => {
  // This will never be `undefined`, yet the type includes `undefined`.
  queryValues
});

Copy link
Collaborator

Choose a reason for hiding this comment

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

uhmmmm... I think that the QueryValues definition is a kind of "legacy" of Node's querystring package.

With the current implementation based on standard URLSearchParams it shouldn't happen to have an undefined query value.

Maybe we can add this change to a wider fp-ts-routing refactoring before publishing the v1.0.0

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.

2 participants