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

Please export YargsInstance from deno.ts as well #2391

Open
justinmchase opened this issue Feb 5, 2024 · 3 comments
Open

Please export YargsInstance from deno.ts as well #2391

justinmchase opened this issue Feb 5, 2024 · 3 comments

Comments

@justinmchase
Copy link

I keep needing this type when implementing commands, as this is the type of the argument supplied to the command builder.

Also, it would be really helpful if the types in deno-types.ts were also exported from deno.ts as well.

What I am doing now:

import yargs from "yargs/deno.ts";
import { Arguments } from "yargs/deno-types.ts";
import { YargsInstance } from "yargs/build/lib/yargs-factory.js";

export const hello = {
  command: "hello",
  builder(yargs: YargsInstance) {
    return yargs.option("name", name)
  },
  async handler(args: Arguments) {
    await console.log(`Hello ${args.name}!`)
  },
}

await yargs()
  .scriptName("example")
  .command(hello)
  .strictCommands()
  .demandCommand(1)
  .parse(Deno.args);

Ideally, from a Deno users perspective the I think it would be nice if they all came out of a single import:

import { yargs, YargsInstance, Arguments } from "yargs/deno.ts";
@shadowspawn
Copy link
Member

Related: #1799

In node, the TypeScript types are supplied by Definitely Typed and maintained separately. I don't know if you can make use of those from Deno.

@justinmchase
Copy link
Author

I think deno just treats them as two separate modules. It natively imports typescript files so whatever is in that file is what it interprets.

@justinmchase
Copy link
Author

Here is an example usage for reference:
https://github.com/Optum/semver-cli/blob/main/deps/yargs.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants