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

chore(vk-app-payload): support payload providing using generic #492

Merged
merged 3 commits into from
Jul 31, 2022
Merged

chore(vk-app-payload): support payload providing using generic #492

merged 3 commits into from
Jul 31, 2022

Conversation

egorprnn
Copy link
Contributor

@egorprnn egorprnn commented Jun 2, 2022

updates.on<{
    test: 1
}>('app_payload', (context) => {
    console.log(context.eventPayload);
});

@@ -568,7 +568,7 @@ export class Updates {
handler: AllowArray<Middleware<DonutWithdrawContext & T>>
): this;

public on<P, T = {}>(
public on<P extends Record<string, any>, T = {}>(
Copy link
Owner

@negezor negezor Jun 8, 2022

Choose a reason for hiding this comment

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

Я думаю стоит поменять местами дженерики, чтобы не сломать текущие типы.

Copy link
Contributor Author

@egorprnn egorprnn Jun 8, 2022

Choose a reason for hiding this comment

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

Если мы меняем их местами, то тогда мы делаем payload опциональным, я бы все таки оставил его на месте и сделал обязательным, потому что это основные данные с которыми будет работать разработчик, по своему опыту я не часто использовал generic для расширения контекста, и многим придется просто пробрасывать {}.

packages/vk-io/src/structures/contexts/vk-app-payload.ts Outdated Show resolved Hide resolved
@egorprnn egorprnn requested a review from negezor July 18, 2022 04:43
@negezor negezor merged commit 5714e80 into negezor:master Jul 31, 2022
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.

2 participants