oclif / command

oclif base command

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parse method doesn't work without passing class

arifmahmudrana opened this issue · comments

Base abstract child

import { Command, flags } from '@oclif/command'

abstract class AP extends Command {
  static flags = {
    help: flags.help({ char: 'h' }),
    file: flags.string({
      description: 'File path',
      required: true,
    }),
  }

  async run() {
    const { flags } = this.parse() // It should work without class name so that it can be dynamic
    console.log(flags.file)
  }
}

export default AP

Child class

import AP from '../../abstract/ap'

export default class API extends AP {
  static description = `Extended`

  static examples = [`$ my-cli api`]

  static flags = AP.flags
}

export default API

But it shows error Property 'file' does not exist on type 'unknown'.ts(2339)