Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag type inference fails for command() with 'description' #2

Closed
1 task
jgoz opened this issue Jan 24, 2022 · 1 comment · Fixed by privatenumber/type-flag#7 or #4
Closed
1 task

Flag type inference fails for command() with 'description' #2

jgoz opened this issue Jan 24, 2022 · 1 comment · Fixed by privatenumber/type-flag#7 or #4
Labels
bug Something isn't working

Comments

@jgoz
Copy link

jgoz commented Jan 24, 2022

Bug description

Flags definitions passed to command() that include a description field are inferred as never. If you omit description, the type is inferred correctly.

Reproduction

import { command } from "cleye";

const build = command({
  name: 'build',
  flags: {
    watch: {
      type: Boolean,
      alias: 'w',
      default: false,
      description: 'Watch for changes and rebuild', // when commented out, type is correct
    },
  },
}, argv => {
  if (argv.flags.watch) {
    // expected "watch" to be boolean, but it is "never"
  }
});

Node.js package manager

pnpm

Environment

System:
    OS: macOS 12.1
    CPU: (8) arm64 Apple M1
    Memory: 191.53 MB / 16.00 GB
    Shell: 3.3.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 16.13.0 - ~/.volta/tools/image/node/16.13.0/bin/node
    Yarn: 1.22.10 - ~/.volta/tools/image/yarn/1.22.10/bin/yarn
    npm: 8.1.0 - ~/.volta/tools/image/node/16.13.0/bin/npm
  npmPackages:
    cleye: ^1.0.1 => 1.0.1

Can you contribute a fix?

  • I’m interested in opening a pull request for this issue.
@privatenumber
Copy link
Owner

Thanks for catching this major issue.

I have a fix ready and will be releasing it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants