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

use template literal types to call 'opts' with type safely #1585

Closed
anatawa12 opened this issue Aug 16, 2021 · 4 comments
Closed

use template literal types to call 'opts' with type safely #1585

anatawa12 opened this issue Aug 16, 2021 · 4 comments

Comments

@anatawa12
Copy link

Since typescript 4.1, template literal types was coming.
This feature enables us to call the 'opts' function with type safety without specifying types, I think. Could you implement this?

@shadowspawn
Copy link
Collaborator

There is an experiment with this in #1356.

Related: #1245

@shadowspawn
Copy link
Collaborator

I think this may be too complex to do with the existing API. Deducing type for .opts() is hard enough, but there are also the arguments passed into the action handler. They are affected by .argument() as well!

An alternative interface for configuration might allow type deduction and a different style of setup (e.g. #665), in situations where preference or the benefits make it attractive.


I saw an interesting related statement in the Clipanion documentation:

We won't provide domain-specific languages (DSL). Once upon a time Clipanion actually worked like this, using a "natural" language to declare commands, but over time it became clear that we were merely fighting JavaScript, losing many useful tooling integrations.

https://mael.dev/clipanion/docs/

@shadowspawn
Copy link
Collaborator

This issue has not had any activity in a month. It isn't likely to get acted on due to this report.

Feel free to open a new issue if it comes up again, with new information and renewed interest.

Thank you for your contributions.

@shadowspawn
Copy link
Collaborator

For some experimental strong inferred typing see: https://github.com/commander-js/extra-typings

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