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

Type error in field_mask.ts when outputServices=grpc-js and useOptionals=all #956

Closed
timosaikkonen opened this issue Oct 24, 2023 · 3 comments · Fixed by #957
Closed

Type error in field_mask.ts when outputServices=grpc-js and useOptionals=all #956

timosaikkonen opened this issue Oct 24, 2023 · 3 comments · Fixed by #957
Labels

Comments

@timosaikkonen
Copy link
Contributor

timosaikkonen commented Oct 24, 2023

src/generated-grpc-js/google/protobuf/field_mask.ts(258,12): error TS18048: 'message.paths' is possibly 'undefined'.
src/generated-grpc-js/google/protobuf/field_mask.ts(277,5): error TS2322: Type 'string[] | undefined' is not assignable to type 'string[]'.
    Type 'undefined' is not assignable to type 'string[]'.

The interface for FieldMask gets generated as:

export interface FieldMask {
  /** The set of field mask paths. */
  paths?: string[] | undefined
}

And toJSON is missing optional chaining:

  toJSON(message: FieldMask): string {
    return message.paths.join(",")
  }

...and unwrap is returning a string[] | undefined where string[] is expected in the function signature:

  unwrap(message: FieldMask): string[] {
    return message.paths
  }

Looks like this requires a similar treatment as #949. I can give it a go unless I'm missing something?

@stephenh
Copy link
Owner

Ah yeah, you're diagnosis looks correct; a PR would be great, thanks @timosaikkonen !

@timosaikkonen
Copy link
Contributor Author

Coming right up.

@stephenh
Copy link
Owner

🎉 This issue has been resolved in version 1.162.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants