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

feat: support useReadonlyTypes option #691

Merged
merged 20 commits into from
Oct 22, 2022
Merged

Conversation

jonaskello
Copy link
Collaborator

Fixes #163

This PR will add the option useReadonlyTypes. When set to true this option will generate code like this:

export interface Entity {
  readonly intVal: number;
  readonly stringVal: string;
  readonly intArray: readonly number[];
  readonly stringArray: readonly string[];
  readonly subEntity: SubEntity | undefined;
  readonly subEntityArray: readonly SubEntity[];
  readonly optionalIntVal?: number | undefined;
  readonly fieldMask: readonly string[] | undefined;
  readonly listValue: ReadonlyArray<any> | undefined;
  readonly structValue: { readonly [key: string]: any } | undefined;
}

@jonaskello
Copy link
Collaborator Author

@stephenh I went with the as any approach as discussed in #163, do you think that is OK?

Copy link
Owner

@stephenh stephenh left a comment

Choose a reason for hiding this comment

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

@jonaskello this looks great! Thanks for the PR, and also for testing the various google.protobuf.* well known types.

@stephenh stephenh merged commit 4b87334 into stephenh:main Oct 22, 2022
stephenh pushed a commit that referenced this pull request Oct 22, 2022
# [1.130.0](v1.129.0...v1.130.0) (2022-10-22)

### Features

* support `useReadonlyTypes` option ([#691](#691)) ([4b87334](4b87334))
@stephenh
Copy link
Owner

🎉 This PR is included in version 1.130.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jonaskello
Copy link
Collaborator Author

@stephenh Thank you for the quick review and merge. Also, thanks for creating this awesome package in the first place. It really makes a huge difference for working with protobuf in typescript :-).

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 this pull request may close these issues.

Option for readonly types
2 participants