Skip to content
This repository was archived by the owner on Jan 18, 2021. It is now read-only.

Commit

Permalink
[ez.d.ts] update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
codehz committed Aug 18, 2020
1 parent 2991bf6 commit 99be450
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions ez.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,32 @@ declare interface CommandOrigin {
worldpos: ScriptPosition;
}

type CommandParameterTypeName = |
"bool" |
"int" |
"float" |
"string" |
"json";
type CommandParameterTypeName =
| "bool"
| "int"
| "float"
| "string"
| "json"
| "enum"
| "players"
| "entities";

type CommandParameterTypeMap<Name extends CommandParameterTypeName> =
Name extends "bool" ? boolean :
Name extends "int" ? number :
Name extends "float" ? number :
Name extends "string" ? string :
Name extends "json" ? Record<string, any> :
Name extends "enum" ? number :
Name extends "entities" ? Entity[] :
Name extends "players" ? PlayerEntry[] :
never;

declare interface CommandParameterDefinition {
name: string;
type: CommandParameterTypeName;
optional: boolean;
enum?: string;
}

type CommandParameterMap<Defs extends CommandParameterDefinition[]> = {
Expand Down Expand Up @@ -187,6 +194,13 @@ declare module "ez:command" {
defs: Defs,
handler: (this: CommandOrigin, ...args: CommandParameterMap<Defs>) => CommandHandlerResult
): void;

/**
* Add command enum
* @param name enum name
* @param value enum values
*/
export function addEnum(name: string, value: string[]): void
}

declare interface ItemStack {
Expand Down

0 comments on commit 99be450

Please sign in to comment.