chore(builders): simplify types (#7784)

* chore(builders): simplify types

* chore: removed uneeded partial
This commit is contained in:
Suneet Tipirneni
2022-04-17 04:51:11 -04:00
committed by GitHub
parent c2866504a3
commit 75b6770933
9 changed files with 29 additions and 62 deletions

View File

@@ -3,37 +3,26 @@ import type {
APIActionRowComponent,
APIActionRowComponentTypes,
APIBaseComponent,
APIMessageActionRowComponent,
APIMessageComponent,
APIModalActionRowComponent,
APIModalComponent,
ComponentType,
} from 'discord-api-types/v10';
export type AnyAPIActionRowComponent = APIActionRowComponentTypes | APIActionRowComponent<APIActionRowComponentTypes>;
/**
* Represents a discord component
*/
export abstract class ComponentBuilder<
DataType extends Partial<APIBaseComponent<ComponentType>> & {
type: ComponentType;
} = APIBaseComponent<ComponentType>,
> implements
JSONEncodable<
| APIModalComponent
| APIMessageComponent
| APIActionRowComponent<APIModalActionRowComponent | APIMessageActionRowComponent>
>
DataType extends Partial<APIBaseComponent<ComponentType>> = APIBaseComponent<ComponentType>,
> implements JSONEncodable<AnyAPIActionRowComponent>
{
/**
* The API data associated with this component
*/
public readonly data: DataType;
public readonly data: Partial<DataType>;
public abstract toJSON():
| APIActionRowComponentTypes
| APIActionRowComponent<APIModalActionRowComponent | APIMessageActionRowComponent>;
public abstract toJSON(): AnyAPIActionRowComponent;
public constructor(data: DataType) {
public constructor(data: Partial<DataType>) {
this.data = data;
}
}