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

feat(router): add userdata generic to addHandler #1547

Merged
merged 2 commits into from
Sep 19, 2022
Merged

Conversation

@@ -8,6 +10,8 @@ export interface RouterHandler<Context extends CrawlingContext = CrawlingContext
(ctx: Context): Awaitable<void>;
}

type GetUserDataFromRequest<T> = T extends Request<infer Y> ? Y : never;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I move this into ./request and export it?

@szmarczak
Copy link
Contributor Author

For some reason still doesn't work... will fix

@szmarczak
Copy link
Contributor Author

Ah, doesn't work because Omit is not strict and Context extends Record<PropertyKey, unknown> after all, so it generalizes everything to unknown...

Copy link
Contributor

@mstephen19 mstephen19 left a comment

Choose a reason for hiding this comment

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

Ahaa, type-fest's Except is more strict, and therefore works. Thanks Szymek!

@szmarczak szmarczak merged commit 19cdf13 into master Sep 19, 2022
@szmarczak szmarczak deleted the addhandler-generic branch September 19, 2022 09:33
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.

UserData Generic for router
2 participants