Skip to content

Commit

Permalink
fix(builders): make type optional in constructor (#7391)
Browse files Browse the repository at this point in the history
  • Loading branch information
DTrombett committed Feb 2, 2022
1 parent 34120bb commit 4abb28c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/builders/src/components/ActionRow.ts
Expand Up @@ -16,7 +16,7 @@ export class ActionRow<T extends ActionRowComponent = ActionRowComponent> implem
public readonly components: T[] = [];
public readonly type = ComponentType.ActionRow;

public constructor(data?: APIActionRowComponent) {
public constructor(data?: APIActionRowComponent & { type?: ComponentType.ActionRow }) {
this.components = (data?.components.map(createComponent) ?? []) as T[];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/Button.ts
Expand Up @@ -19,7 +19,7 @@ export class ButtonComponent implements Component {
public readonly custom_id!: string;
public readonly url!: string;

public constructor(data?: APIButtonComponent) {
public constructor(data?: APIButtonComponent & { type?: ComponentType.Button }) {
/* eslint-disable @typescript-eslint/non-nullable-type-assertion-style */
this.style = data?.style as ButtonStyle;
this.label = data?.label;
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/selectMenu/SelectMenu.ts
Expand Up @@ -21,7 +21,7 @@ export class SelectMenuComponent implements Component {
public readonly custom_id!: string;
public readonly disabled?: boolean;

public constructor(data?: APISelectMenuComponent) {
public constructor(data?: APISelectMenuComponent & { type?: ComponentType.SelectMenu }) {
this.options = data?.options.map((option) => new SelectMenuOption(option)) ?? [];
this.placeholder = data?.placeholder;
this.min_values = data?.min_values;
Expand Down

0 comments on commit 4abb28c

Please sign in to comment.