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

build fails due to new yargs-parser dependency update #378

Open
goncalofialho opened this issue Mar 3, 2022 · 5 comments · May be fixed by #379
Open

build fails due to new yargs-parser dependency update #378

goncalofialho opened this issue Mar 3, 2022 · 5 comments · May be fixed by #379

Comments

@goncalofialho
Copy link

goncalofialho commented Mar 3, 2022

When you run yarn build it will throw the following error:

yarn run v1.22.17
$ yarn build:lib && yarn build:changelog
$ tsc
src/params.ts:16:14 - error TS2322: Type 'string | number' is not assignable to type 'string'.
  Type 'number' is not assignable to type 'string'.

16     return { generator, action, templates }
                ~~~~~~~~~

  src/types.ts:48:3
    48   generator: string
         ~~~~~~~~~
    The expected type comes from property 'generator' which is declared here on type 'ParamsResult'

src/params.ts:16:25 - error TS2322: Type 'string | number' is not assignable to type 'string'.
  Type 'number' is not assignable to type 'string'.

16     return { generator, action, templates }
                           ~~~~~~

  src/types.ts:49:3
    49   action: string
         ~~~~~~
    The expected type comes from property 'action' which is declared here on type 'ParamsResult'

src/params.ts:18:42 - error TS2339: Property 'split' does not exist on type 'string | number'.
  Property 'split' does not exist on type 'number'.

18   const [mainAction, subaction] = action.split(':')
                                            ~~~~~

src/params.ts:20:45 - error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'.
  Type 'number' is not assignable to type 'string'.

20   const actionfolder = path.join(templates, generator, mainAction)
                                               ~~~~~~~~~

src/params.ts:43:3 - error TS2322: Type '{ templates: string; actionfolder: string; generator: string | number; action: string | number; subaction: any; } & { [argName: string]: any; '--'?: (string | number)[]; } & { name: string | number; }' is not assignable to type 'ParamsResult'.
  Type '{ templates: string; actionfolder: string; generator: string | number; action: string | number; subaction: any; } & { [argName: string]: any; '--'?: (string | number)[]; } & { name: string | number; }' is not assignable to type '{ templates: string; generator: string; action: string; subaction?: string; actionfolder?: string; name?: string; dry?: boolean; }'.
    Types of property 'generator' are incompatible.
      Type 'string | number' is not assignable to type 'string'.
        Type 'number' is not assignable to type 'string'.

43   return args
     ~~~~~~~~~~~


Found 5 errors in the same file, starting at: src/params.ts:16

This is caused by the new version of yargs-parser -> "^21.0.0"

This file should be changed in order to comply with the new types.

@jondot
Copy link
Owner

jondot commented Mar 3, 2022

This is strange, on CI build works, incl. my dev env.. any idea what's changed?

goncalofialho pushed a commit to goncalofialho/hygen that referenced this issue Mar 3, 2022
@goncalofialho goncalofialho linked a pull request Mar 3, 2022 that will close this issue
@goncalofialho
Copy link
Author

goncalofialho commented Mar 3, 2022

I've created a PR with the changes 604063d, it seems yargs-parser now can return string | number. Typescript is complaining about it.
To reproduce, try to delete node_modules package-lock.json and check if the error occur.

goncalofialho pushed a commit to goncalofialho/hygen that referenced this issue Mar 4, 2022
@jondot
Copy link
Owner

jondot commented Mar 4, 2022

Are you using yarn or npm to install, because we have no pacakge-lock.json in the repo at all (if npm, can you try yarn?)

@goncalofialho
Copy link
Author

you are right! package-lock.json is the cause of the problem!
Feel free to decline the PR if you want 😄

@goncalofialho
Copy link
Author

I mean, it would be great to have this fixed to work in both npm and yarn

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 a pull request may close this issue.

2 participants