Skip to content

TypeScript should allow undefined in args.default #180

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

Closed
jcalfee opened this issue Jan 26, 2025 · 3 comments
Closed

TypeScript should allow undefined in args.default #180

jcalfee opened this issue Jan 26, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@jcalfee
Copy link

jcalfee commented Jan 26, 2025

Environment

citty ^0.1.6

Reproduction

const c = defineCommand({
  args: {
    accountId: {
      type: 'string',
      description: '[env: ACCOUNT_ID]',
      default: process.env.ACCOUNT_ID,
      required: true
    },
// ...

Describe the bug

I have environment variables and I would like to pass them though the args.default so the CLI has a chance to change the values. When I do that, process.env.ANY_VAR could be string | undefined. This causes a typescript error when I try to use that in citty.

Image

Image

Additional context

No response

Logs

@jcalfee jcalfee added the bug Something isn't working label Jan 26, 2025
@jcalfee
Copy link
Author

jcalfee commented Jan 26, 2025

Possibly related #132

@kricsleo
Copy link
Member

kricsleo commented Apr 8, 2025

Can't reproduce - https://stackblitz.com/edit/github-ltxv8441?file=src%2Findex.ts

Could you check this example? 🤔

@jcalfee jcalfee closed this as completed Apr 11, 2025
@jcalfee
Copy link
Author

jcalfee commented Apr 11, 2025

I realized tsconfig may have something to do with this. I checked everything in my tsconfig in stackblitz; it probably comes down to "strictNullChecks": true, "exactOptionalPropertyTypes": true. I can't recreate this and have since refactored that code. It looks consistent though even with strictNullChecks and exactOptionalPropertyTypes so I would say close this as a non-issue. Thank you!!

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
Development

No branches or pull requests

2 participants