Skip to content

Commit

Permalink
fix: remove cast
Browse files Browse the repository at this point in the history
  • Loading branch information
suneettipirneni committed Feb 13, 2022
1 parent eaf779b commit 4be95ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/builders/src/components/ActionRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type ActionRowComponent = ButtonComponent | SelectMenuComponent;
* Represents an action row component
*/
export class ActionRow<T extends ActionRowComponent = ActionRowComponent> extends Component<
Omit<Partial<APIActionRowComponent>, 'components'>
Omit<Partial<APIActionRowComponent> & { type: ComponentType.ActionRow }, 'components'>
> {
public readonly components: T[];

Expand Down Expand Up @@ -41,10 +41,9 @@ export class ActionRow<T extends ActionRowComponent = ActionRowComponent> extend
}

public toJSON(): APIActionRowComponent {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
return {
...this.data,
components: this.components.map((component) => component.toJSON()),
} as APIActionRowComponent;
};
}
}
4 changes: 3 additions & 1 deletion packages/builders/src/components/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import type { APIBaseMessageComponent, APIMessageComponent, ComponentType } from
* Represents a discord component
*/
export abstract class Component<
DataType extends Partial<APIBaseMessageComponent<ComponentType>> = APIBaseMessageComponent<ComponentType>,
DataType extends Partial<APIBaseMessageComponent<ComponentType>> & {
type: ComponentType;
} = APIBaseMessageComponent<ComponentType>,
> implements JSONEncodable<APIMessageComponent>
{
/**
Expand Down

0 comments on commit 4be95ae

Please sign in to comment.