Skip to content

Generics

Pre-release
Pre-release
Compare
Choose a tag to compare
@spuckhafte spuckhafte released this 11 Sep 09:13
· 4 commits to master since this release

commit

Changes

  • Now you also have to define the type of your cmd structure as Generic to the command class. This well help in inferring the type of each field properly when using this.extract().
// commands/test.ts

export default class extends Command<[string, number|null]> {
    constructor() {
        super({
            structure: ["string", "number|null"]
        });
    }

    async execute() {
        // one: string, two: number|null
        const [one, two] = this.extract();
    }
}