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

fix: propagate Dictionary including undefined in value type #2393

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shadowspawn
Copy link
Member

The value type we use with Dictionary type declarations often includes undefined. I am guessing this is more to ensure the value type is checked for a possibly unknown key than for setting a value of undefined, but paranoia is ok for either reason.

TypeScript 5.4.0 picks up a case where the undefined was not being used consistently,

lib/yargs-factory.ts:667:7 - error TS2345: Argument of type 'string | string[] | Dictionary<string | undefined>' is not assignable to parameter of type 'string | string[] | { [x: string]: string; }'.
  Type 'Dictionary<string | undefined>' is not assignable to type 'string | string[] | { [x: string]: string; }'.
    Type 'Dictionary<string | undefined>' is missing the following properties from type 'string[]': length, pop, push, concat, and 29 more.

@YuriiMarushchak
Copy link

Hello, does this pull request actual ?

Have the same issue.

lib/yargs-factory.ts:667:7 - error TS2345: Argument of type 'string | string[] | Dictionary<string | undefined>' is not assignable to parameter of type 'string | string[] | { [x: string]: string; }'.
npm ERR!   Type 'Dictionary<string | undefined>' is not assignable to type 'string | string[] | { [x: string]: string; }'.
npm ERR!     Type 'Dictionary<string | undefined>' is missing the following properties from type 'string[]': length, pop, push, concat, and 29 more.
npm ERR! 
npm ERR! 667       keys,

@YuriiMarushchak
Copy link

Hello, does this pull request actual ?

Have the same issue.

lib/yargs-factory.ts:667:7 - error TS2345: Argument of type 'string | string[] | Dictionary<string | undefined>' is not assignable to parameter of type 'string | string[] | { [x: string]: string; }'.
npm ERR!   Type 'Dictionary<string | undefined>' is not assignable to type 'string | string[] | { [x: string]: string; }'.
npm ERR!     Type 'Dictionary<string | undefined>' is missing the following properties from type 'string[]': length, pop, push, concat, and 29 more.
npm ERR! 
npm ERR! 667       keys,

FIXED BY DOWNGRADE TO v17.7.1

@shadowspawn
Copy link
Member Author

This pull request fixes a compile error when building the yargs package itself. It does not affect normal use of the yargs package as a dependency. Example breakage:

$ git clone git@github.com:yargs/yargs.git
$ cd yargs
$ npm install
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead

> yargs@17.7.2 prepare
> npm run compile


> yargs@17.7.2 compile
> rimraf build && tsc

lib/yargs-factory.ts:667:7 - error TS2345: Argument of type 'string | string[] | Dictionary<string | undefined>' is not assignable to parameter of type 'string | string[] | { [x: string]: string; }'.
  Type 'Dictionary<string | undefined>' is not assignable to type 'string | string[] | { [x: string]: string; }'.
    Type 'Dictionary<string | undefined>' is missing the following properties from type 'string[]': length, pop, push, concat, and 29 more.

667       keys,
          ~~~~


Found 1 error in lib/yargs-factory.ts:667

@YuriiMarushchak
Copy link

This pull request fixes a compile error when building the yargs package itself. It does not affect normal use of the yargs package as a dependency. Example breakage:

$ git clone git@github.com:yargs/yargs.git
$ cd yargs
$ npm install
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead

> yargs@17.7.2 prepare
> npm run compile


> yargs@17.7.2 compile
> rimraf build && tsc

lib/yargs-factory.ts:667:7 - error TS2345: Argument of type 'string | string[] | Dictionary<string | undefined>' is not assignable to parameter of type 'string | string[] | { [x: string]: string; }'.
  Type 'Dictionary<string | undefined>' is not assignable to type 'string | string[] | { [x: string]: string; }'.
    Type 'Dictionary<string | undefined>' is missing the following properties from type 'string[]': length, pop, push, concat, and 29 more.

667       keys,
          ~~~~


Found 1 error in lib/yargs-factory.ts:667

I understand clearly. Thank you for your response. I am waiting for future releases.

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

Successfully merging this pull request may close these issues.

None yet

2 participants