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! yargs.parsed now populated before returning, when yargs.parse() called with no args #1382

Merged
merged 1 commit into from Jul 29, 2019

Conversation

bcoe
Copy link
Member

@bcoe bcoe commented Jul 29, 2019

BREAKING CHANGE: we now only officially support yargs.$0 parameter and discourage direct access to yargs.parsed

#1369 and #1366 are incompatible, because 1369 unfreezes properties before returning (at which point yargs.parsed is the original value of false).

I would like to discourage users from accessing these properties on yargs, I've added a hack to make behavior the same as before, but now warn when yargs.parsed is accessed in singleton mode.

…called with no args

BREAKING CHANGE: we now only officially support yargs.$0 parameter and discourage direct access to yargs.parsed
@bcoe bcoe merged commit e3981fd into master Jul 29, 2019
@bcoe bcoe deleted the fix-exposed-api branch July 29, 2019 04:08
@codemile
Copy link

codemile commented Sep 3, 2019

In future major releases of yargs, "parsed" will be a private field. Use the return value of ".parse()" or ".argv" instead

@bcoe the getter is triggering the warning for everyone who is using TypeScript.

For example;

import * as yargs from 'yargs';

The above will copy all of the exported properties from the module to a variable named yargs, and since the getter raises this warning it is triggered.

@codemile
Copy link

codemile commented Sep 3, 2019

I was able to turn off the message by changing

import * as yargs from 'yargs';

to this

import yargs = require('yargs');

@mleguen
Copy link
Member

mleguen commented Sep 4, 2019

@bcoe just removed the warning in #1412 not to trigger error when importing in Typescript.

@codemile could you please confirm that with the version in the master branch the issue with import * is gone?

@igloocube
Copy link

@mleguen I have just found this issue myself and can confirm when using master instead that the message is no longer displayed.

@mleguen
Copy link
Member

mleguen commented Sep 18, 2019

Thanks @igloocube

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

4 participants