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

Type inference for options and arguments works in rc.5 but fails in rc.7 #764

Open
lionel-rowe opened this issue Nov 8, 2024 · 9 comments

Comments

@lionel-rowe
Copy link
Contributor

// import { Command } from 'jsr:@cliffy/command@1.0.0-rc.7'
import { Command } from 'jsr:@cliffy/command@1.0.0-rc.5'

export const cli = new Command()
    .option('-v, --verbose', 'Enable verbose output.')
    .arguments('[...keywords:string]')
    .action((options, ...args) => {})

In rc.5, options is correctly inferred as { verbose?: true | undefined } and args as string[]; however, in rc.7, both options and args implicitly have any type unless manually annotated.

@c4spar
Copy link
Owner

c4spar commented Nov 28, 2024

works fine for me with both versions. do you still have the issue?

Bildschirmfoto 2024-11-28 um 23 47 06

@lionel-rowe
Copy link
Contributor Author

Weird, seems the problem is very flaky. Adding console.log(options, args) seemed to fix the issue for me, and commenting out the console log didn't cause it to recur. Even weirder, clearing the Deno cache had no effect either way.

Maybe an issue with JSR/VS Code/TS/Deno/Deno lint/something else?

@spalberg
Copy link

spalberg commented Dec 1, 2024

Still not working for me.
image

@lionel-rowe adding the console.log makes no difference for me.

Using:

jsr:@cliffy/command@^1.0.0-rc.7

deno 2.1.2 (stable, release, x86_64-pc-windows-msvc)
v8 13.0.245.12-rusty
typescript 5.6.2

Works fine using rc.5:
image

@brad-jones
Copy link

FWIW I just ran into this. Not sure what's unique about my system, apart from running WSL & VsCode.

deno 2.1.3 (stable, release, x86_64-unknown-linux-gnu)
v8 13.0.245.12-rusty
typescript 5.6.2

Interestingly when I tried the same directly on Windows, no issues.

deno 2.1.3 (stable, release, x86_64-pc-windows-msvc)
v8 13.0.245.12-rusty
typescript 5.6.2

Left is Windows, right is WSL.
image

@brad-jones
Copy link

And similarly now it's come good in WSL & all I did was:

  • Close vscode
  • Create a new folder complete seperate from the last project I was working on
  • Opened vscode in this new folder
  • Enabled Deno for the workspace
  • Added the same test typescript to a new file
  • Restored dependencies

ie: nothing too special.

I can only assume it's somehow related to deno's cache.

@sigmaSd
Copy link

sigmaSd commented Dec 10, 2024

I have the same error, it works with rc 4 and stops with rc 5 (fedora 41 )

Screencast.From.2024-12-10.22-43-18.mp4

@tomsseisums
Copy link

Cannot get it to work in rc.7 whatsoever, rc.5 works out-of-the-box.

@c4spar
Copy link
Owner

c4spar commented Dec 13, 2024

I remember having this problem from time to time in the past. But currently I can't reproduce it. I tested it again with all rc versions, on two different laptops, with deno and node+typescript.

I also think it's either an lsp or a caching issue.

Does anyone have this issue with node as well?

@sigmaSd
Copy link

sigmaSd commented Dec 13, 2024

It fixed itself when I explicitly run deno check fileInQuestion.ts (it seem to have downloaded some missing files that the lsp maybe didn't download automatically)

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

No branches or pull requests

6 participants