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

Seeding with CustomParticipant not possible in TypeScript #10

Open
Tandashi opened this issue Jun 26, 2023 · 2 comments
Open

Seeding with CustomParticipant not possible in TypeScript #10

Tandashi opened this issue Jun 26, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@Tandashi
Copy link

Tandashi commented Jun 26, 2023

When trying to create a Stage with Seeding the same way as in custom.spec.js#L16 TypeScripts errors.

This is due to the fact that a CustomParticipant also requires to have the Participant field, namingly id and tournament_id. I am not sure if this is intentional or not. Else I would propose something like this:

/**
 * The seeding for a stage.
 *
 * Each element represents a participant, which can be:
 * - A full object, with possibly extra fields.
 * - Its name.
 * - Its ID.
 * - Or a BYE: `null`.
 */
export type Seeding<Participant extends Partial<CustomParticipant> = CustomParticipant> = (Participant | string | number | null)[];

/**
 * Used to create a stage.
 */
export interface InputStage<Participant extends Partial<CustomParticipant> = Partial<CustomParticipant>> {
    /**
     * ID of the parent tournament.
     *
     * Used to determine the `number` property of a stage related to a tournament.
     */
    tournamentId: number;
    /** Name of the stage. */
    name: string;
    /** Type of stage. */
    type: StageType;
    /** The number of the stage in its tournament. Is determined if not given. */
    number?: number;
    /** Contains participants or `null` for BYEs. */
    seeding?: Seeding<Participant>;
    /** Contains optional settings specific to each stage type. */
    settings?: StageSettings;
}
@Drarig29
Copy link
Owner

I am not sure if this is intentional or not.

As the JSDoc of Seeding says, objects in the seeding should "A full object, with possibly extra fields.". On the other hand, tests are the minimal code required to make the test pass.

So this was intentional, but I can try to relax this.

@Drarig29 Drarig29 added the enhancement New feature or request label Jun 26, 2023
@Tandashi
Copy link
Author

Oh okay I see :)

In my project I just create the participants manually now and link them by their id.
Need to do that for other things as well but could become a confidence in the future to someone else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants