Schniz / cmd-ts

💻 A type-driven command line argument parser
https://cmd-ts.now.sh
MIT License
241 stars 25 forks source link

Allow readonly T[] in oneOf #185

Closed beaucollins closed 1 year ago

beaucollins commented 1 year ago

readonly T[] is a subset of T[]

Ideally we could do this:

import * as cmd from 'cmd-ts';

const options = ['a', 'b', 'c'] as const;

const option = cmd.oneOf(options);

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAKjgQwM5wMYgCZwGZQQhwDkW2AtDKiQNwCwAUExhAHarwRgzDvoBeOAG0SyEgBpSAI0mkMJALop0rDjAbNGaznG692cIeQB07AKYB5PAAp9fDgEpaQA

One workaround is using .slice() to turn it into a non-readonly array

changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: a749ae841470b0040b80bda592ff2cf0b3946478

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------ | ----- | | cmd-ts | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
cmd-ts ❌ Failed (Inspect) Jan 11, 2023 at 7:45PM (UTC)
Schniz commented 1 year ago

Thank you!

beaucollins commented 1 year ago

My pleasure! Thanks for cmd-ts!