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): return type for get router parameter utils #400

Merged
merged 1 commit into from
Jun 9, 2023

Conversation

cerinoligutom
Copy link
Contributor

Improve the return type of getRouterParam and getRouterParams. The latter's return type in particular is misleading especially when destructured:

image

And the implementation is simply returning the event.context.params with a fallback.

h3/src/utils/request.ts

Lines 10 to 13 in 3e5f427

export function getRouterParams(event: H3Event): H3Event["context"] {
// Fallback object needs to be returned in case router is not used (#149)
return event.context.params || {};
}

Unless event.context.params, for some reason, can possibly have sessions and params in it?

@Atinux
Copy link
Member

Atinux commented Jun 8, 2023

Unless event.context.params, for some reason, can possibly have sessions and params in it?

Should not.

The PR looks good to me thank you! Waiting for @pi0 review

@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Merging #400 (aa4569a) into main (3e5f427) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #400      +/-   ##
==========================================
+ Coverage   76.19%   76.21%   +0.01%     
==========================================
  Files          26       26              
  Lines        2436     2438       +2     
  Branches      339      339              
==========================================
+ Hits         1856     1858       +2     
  Misses        580      580              
Impacted Files Coverage Δ
src/utils/request.ts 100.00% <100.00%> (ø)

@pi0 pi0 changed the title fix: return type for get router parameter utils fix(types): return type for get router parameter utils Jun 9, 2023
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks 👍🏼

@pi0 pi0 merged commit 7c9219a into unjs:main Jun 9, 2023
3 checks passed
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.

None yet

3 participants