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 update by passing interface to protect the type #888

Merged
merged 2 commits into from
Jun 3, 2021

Conversation

summer-ji-eng
Copy link
Collaborator

@summer-ji-eng summer-ji-eng commented Jun 2, 2021

With update on both package:
yargs -> ^16.2.0 -> 17.0.0
sinon -> ^10.0.0 -> ^11.0.0
see #865

The typescript can't compile on type checks with error msg:

error TS2339: Property 'outputDir' does not exist on type '{ [x: string]: unknown; _: (string | number)[]; $0: string; } | Promise<{ [x: string]: unknown; _: (string | number)[]; $0: string; }>'.
  Property 'outputDir' does not exist on type 'Promise<{ [x: string]: unknown; _: (string | number)[]; $0: string; }>'.

because compiler expect argv['outputDir'] rather than argv.outputDir. The solution is pass in a interface to protect the type and avoid the typo by passing string in []`.

Once it merge, the #880 should pass the test.

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jun 2, 2021
@summer-ji-eng summer-ji-eng marked this pull request as ready for review June 2, 2021 05:57
@summer-ji-eng summer-ji-eng requested a review from a team as a code owner June 2, 2021 05:57
protoc?: string | undefined;
protoDirs?: string[];
commonProtoPath?: string;
descriptor: string | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ? too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this up.

export interface IArguments {
[x: string]: unknown;
outputDir?: string;
grpcServiceConfig?: string | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think when you use ? it already means "can be undefined" so should be enough to say just grpcServiceConfig?: string without | undefined. Same for others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SG. remove undefined.

@summer-ji-eng summer-ji-eng added the automerge Merge the pull request once unit tests and other checks pass. label Jun 3, 2021
@gcf-merge-on-green gcf-merge-on-green bot merged commit e87beaa into master Jun 3, 2021
@gcf-merge-on-green gcf-merge-on-green bot deleted the yargs_update branch June 3, 2021 20:08
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants