@commander-js/extra-typings
Advanced tools
Comparing version 10.0.3 to 11.0.0
{ | ||
"name": "@commander-js/extra-typings", | ||
"version": "10.0.3", | ||
"version": "11.0.0", | ||
"description": "Infer strong typings for commander options and action handlers", | ||
@@ -16,2 +16,3 @@ "main": "index.js", | ||
"esm.mjs", | ||
"esm.d.mts", | ||
"index.js", | ||
@@ -23,7 +24,5 @@ "index.d.ts" | ||
".": { | ||
"types": "./index.d.ts", | ||
"require": "./index.js", | ||
"import": "./esm.mjs" | ||
}, | ||
"./esm.mjs": "./esm.mjs" | ||
} | ||
}, | ||
@@ -51,3 +50,3 @@ "types": "index.d.ts", | ||
"peerDependencies": { | ||
"commander": "10.0.x" | ||
"commander": "11.0.x" | ||
}, | ||
@@ -57,3 +56,3 @@ "devDependencies": { | ||
"@types/node": "^18.7.16", | ||
"commander": "~10.0.0", | ||
"commander": "~11.0.0", | ||
"jest": "^29.3.1", | ||
@@ -60,0 +59,0 @@ "ts-jest": "^29.0.5", |
@@ -35,3 +35,3 @@ # extra-typings for commander | ||
```js | ||
```typescript | ||
import { program } from '@commander-js/extra-typings'; | ||
@@ -49,3 +49,3 @@ | ||
```js | ||
```typescript | ||
import { Command } from '@commander-js/extra-typings'; | ||
@@ -59,3 +59,3 @@ | ||
```js | ||
```typescript | ||
import { Command } from '@commander-js/extra-typings'; | ||
@@ -68,1 +68,10 @@ | ||
``` | ||
Use a "const assertion" on the choices to narrow the option type from `string`: | ||
```typescript | ||
const program = new Command() | ||
.addOption(new Option('--drink-size <size>').choices(['small', 'medium', 'large'] as const)) | ||
.parse(); | ||
const drinkSize = program.opts().drinkSize; // "small" | "medium" | "large" | undefined | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48416
7
74