Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

How to pass flag type to base class #80

@ktalebian

Description

@ktalebian

This is mostly a Typescript question more than anything else with OClif itself. I want to create a BaseCommand and define some additional parameters. One such is a getter for flags. I cannot figure out how to set the type of it though so it's dynamic based on whatever the implemented class is:

export abstract class BaseCommand extends Command {
  protected flags: WhatToPutHere;

  async run() {
     this.flags = this.parse(this.constructor).flags;
  }
}

class MyCommand extends BaseCommand {
  static flags = {
    version: flags.string()
  }

  async run() {
    // I want to access this.flags.version
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions