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 withRequestMiddlewares signatures #134

Merged
merged 2 commits into from Jan 4, 2018

Conversation

Projects
None yet
2 participants
@gcanti
Contributor

gcanti commented Jan 4, 2018

@cloudify I was reading your post and noticed a possible issue: I think that the type parameter RH should be moved to the right

// current signature
declare function withRequestMiddlewares<RH, R1, R2, T1, T2>(
  m1: IRequestMiddleware<R1, T1>,
  m2: IRequestMiddleware<R2, T2>
): (handler: (v1: T1, v2: T2) => Promise<IResponse<RH>>) => RequestHandler<RH | R1 | R2>

declare const m1: IRequestMiddleware<'R1', 'T1'>
declare const m2: IRequestMiddleware<'R2', 'T2'>
declare const handler: (v1: 'T1', v2: 'T2') => Promise<IResponse<'RH'>>

// const x: (req: Request) => Promise<IResponse<{} | "R1" | "R2">>
const x = withRequestMiddlewares(m1, m2)(handler)

Note the inferred type {} for RH

// proposed signature
declare function withRequestMiddlewares2<R1, R2, T1, T2>(
  m1: IRequestMiddleware<R1, T1>,
  m2: IRequestMiddleware<R2, T2>
): <RH>(handler: (v1: T1, v2: T2) => Promise<IResponse<RH>>) => RequestHandler<RH | R1 | R2>

// const y: (req: Request) => Promise<IResponse<"R1" | "R2" | "RH">>
const y = withRequestMiddlewares2(m1, m2)(handler)
@codecov

This comment has been minimized.

Show comment
Hide comment
@codecov

codecov bot Jan 4, 2018

Codecov Report

Merging #134 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #134      +/-   ##
==========================================
+ Coverage   90.07%   90.08%   +<.01%     
==========================================
  Files          54       54              
  Lines        1381     1382       +1     
  Branches      152      152              
==========================================
+ Hits         1244     1245       +1     
  Misses        137      137
Impacted Files Coverage Δ
lib/utils/request_middleware.ts 63.26% <100%> (+0.76%) ⬆️

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 bfd6ba6...9d8ce90. Read the comment docs.

codecov bot commented Jan 4, 2018

Codecov Report

Merging #134 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #134      +/-   ##
==========================================
+ Coverage   90.07%   90.08%   +<.01%     
==========================================
  Files          54       54              
  Lines        1381     1382       +1     
  Branches      152      152              
==========================================
+ Hits         1244     1245       +1     
  Misses        137      137
Impacted Files Coverage Δ
lib/utils/request_middleware.ts 63.26% <100%> (+0.76%) ⬆️

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 bfd6ba6...9d8ce90. Read the comment docs.

@gunzip gunzip requested a review from cloudify Jan 4, 2018

@cloudify

This comment has been minimized.

Show comment
Hide comment
@cloudify

cloudify Jan 4, 2018

Member

Thanks @gcanti ! I'll update the post too!

Member

cloudify commented Jan 4, 2018

Thanks @gcanti ! I'll update the post too!

@cloudify cloudify merged commit 12ef45b into teamdigitale:master Jan 4, 2018

2 of 3 checks passed

codeclimate 2 issues to fix
Details
Codacy/PR Quality Review Good work! A positive pull request.
Details
ci/circleci Your tests passed on CircleCI!
Details

@gcanti gcanti deleted the gcanti:withRequestMiddlewares-signatures branch Jan 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment