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 assert types to accurately reflect implementation #83

Merged
merged 2 commits into from
Oct 29, 2021

Conversation

englercj
Copy link
Contributor

Improve the assert typings to match node's assert module. This informs Typescript to narrow the type of the parameters, and allows values that are not strictly boolean. Also the previous typings indicated a string return value, but that doesn't seem to match the JS implementation.

Ideally this code should compile correctly, and correctly inform Typescript about the assertion being made:

fastify.assert(obj, 404);
fastify.assert(obj.someValue, 422);

Currently this doesn't compile correctly for various reasons, which are fixed in this PR.

note: The checklist says to run "npm run benchmark" but no such script exists.

Checklist

Copy link
Member

@RafaelGSS RafaelGSS left a comment

Choose a reason for hiding this comment

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

LGTM.

@Eomm Eomm merged commit a76102f into fastify:master Oct 29, 2021
@englercj englercj deleted the fix-assert-types branch November 6, 2021 01:46
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 this pull request may close these issues.

3 participants