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

Out-of-the-box TypeScript type errors #2125

Closed
rendall opened this issue Jan 15, 2024 · 3 comments
Closed

Out-of-the-box TypeScript type errors #2125

rendall opened this issue Jan 15, 2024 · 3 comments

Comments

@rendall
Copy link

rendall commented Jan 15, 2024

Using the latest commander.js with the latest typescript (and Node v18.12.1 FWIW), the Quick Start code from https://github.com/tj/commander.js/blob/HEAD/examples/string-util.js (but import via import { Command } from "commander";)

Gets a squiggly line under program.parse() with

Expected 1 arguments, but got 0.ts(2554)
index.d.ts(208, 11): An argument for 'argv' was not provided.
(method) local.Command.parse(argv: string[]): local.Command
Parse argv, settings options and invoking commands when defined.

@param argv

@returns — for chaining

To replicate, create a new project as described above. For reference, here is the tsconfig I'm using:

{
  "compilerOptions": {
    "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
    "module": "Node16" /* Specify what module code is generated. */,
    "rootDir": "./src" /* Specify the root folder within your source files. */,
    "moduleResolution": "Node16" /* Specify how TypeScript looks up a file from a given module specifier. */,
    "outDir": "./dist" /* Specify an output folder for all emitted files. */,
    "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
    "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
    "strict": true /* Enable all strict type-checking options. */,
    "skipLibCheck": true /* Skip type checking all .d.ts files. */
  }
}
@shadowspawn
Copy link
Collaborator

shadowspawn commented Jan 15, 2024

I was not able to reproduce this. I suspect TypeScript is finding an old version of the typings file, as local has been gone for a while (#1081). If you are using npm, you can have a look at your Commander dependency using:

npm ls commander

@shadowspawn
Copy link
Collaborator

The argument to .parse() got made optional in #1172 which was released in Commander v5.

@rendall
Copy link
Author

rendall commented Jan 15, 2024

Ok. Might have been some version control weirdness. Let's close this.

@rendall rendall closed this as completed Jan 15, 2024
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

2 participants