Closed mikhail closed 1 year ago
Hey @mikhail! Thanks for the PR!
However, I'm sorry I can't accept this pull request as is because it's actually the type definition for manager.update.match()
that is incorrect. This function works without giving participant IDs, and I want it that way.
So I don't want to show an example with something that is not required. This example should stay minimal.
Do you still want to work on fixing the type definition in this PR? Basically, you should do a change like this (and update the rest of the code accordingly):
diff --git a/src/update.ts b/src/update.ts
index 3934e35..023e4fb 100644
--- a/src/update.ts
+++ b/src/update.ts
@@ -4,6 +4,10 @@ import { BaseUpdater } from './base/updater';
import { ChildCountLevel } from './types';
import * as helpers from './helpers';
+type DeepPartial<T> = T extends object ? {
+ [P in keyof T]?: DeepPartial<T[P]>;
+} : T;
+
export class Update extends BaseUpdater {
/**
@@ -13,7 +17,7 @@ export class Update extends BaseUpdater {
*
* @param match Values to change in a match.
*/
- public async match<M extends Match = Match>(match: Partial<M>): Promise<void> {
+ public async match<M extends Match = Match>(match: DeepPartial<M>): Promise<void> {
if (match.id === undefined)
throw Error('No match id given.');
If you don't want to work on this, it's perfectly fine! I can also close the PR and work on it. 👌
It's more or less related to https://github.com/Drarig29/brackets-manager.js/issues/105.
I could take this opportunity to use zod
for runtime type checking.
I fixed it in this commit: https://github.com/Drarig29/brackets-manager.js/commit/5b60a8d29bef68abda20da0650167a96a5c7e361
TypeScript checking failed when copy/pasting the README example after installing the latest version