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

Refactor: Use nullish coalescing operator to simplify undefined checking #122

Merged
merged 3 commits into from Jan 19, 2020

Conversation

Mosoc
Copy link
Contributor

@Mosoc Mosoc commented Jan 14, 2020

Typescript supports nullish coalescing operator in version 3.7

I thought it's a good idea to replace comparison between value and undefined with this feature.

From

{
   disabled: disabled != undefined ? disabled : isSubmitting,
}

to

{
    disabled: disabled ?? isSubmitting,
};

Those typescript codes would compile to javascript as:

{
    disabled: (disabled !== null && disabled !== void 0 ? disabled : isSubmitting),
};

I also upgraded prettier to support this syntax feature.

Ref:
prettier/prettier#6595

@coveralls
Copy link

Coverage Status

Coverage increased (+1.5%) to 80.714% when pulling dc7c673 on Mosoc:master into 29848be on stackworx:master.

@Mosoc Mosoc requested a review from cliedeman January 16, 2020 04:16
@cliedeman cliedeman merged commit 59acc1f into stackworx:master Jan 19, 2020
@cliedeman
Copy link
Collaborator

@Mosoc thanks! this is great

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

3 participants