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

Array parameters should be readonly #211

Open
jeengbe opened this issue Jun 17, 2023 · 0 comments
Open

Array parameters should be readonly #211

jeengbe opened this issue Jun 17, 2023 · 0 comments
Labels
good first issue Good for newcomers

Comments

@jeengbe
Copy link

jeengbe commented Jun 17, 2023

The code that's generated does not use readonly in places where it should:

export declare class BatchGetAccountsRequest extends pb_1.Message {
    #private;
    constructor(data?: any[] | {
        ids?: string[];
    });
    get ids(): string[];
    set ids(value: string[]);
    static fromObject(data: {
        ids?: string[];
    }): BatchGetAccountsRequest;
    toObject(): {
        ids?: string[];
    };
    serialize(): Uint8Array;
    serialize(w: pb_1.BinaryWriter): void;
    static deserialize(bytes: Uint8Array | pb_1.BinaryReader): BatchGetAccountsRequest;
    serializeBinary(): Uint8Array;
    static deserializeBinary(bytes: Uint8Array): BatchGetAccountsRequest;
}

All parameters should declare their arrays as readonly to work with the following example code:

  getByIds(ids: readonly string[]): Promise<Account[]> {
    return this.client
      .BatchGetAccounts(new BatchGetAccountsRequest({ ids }))
      .then((res) => res.accounts.map(accountGrpcToJs));
  }

The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type 'string[]'.

@jeengbe jeengbe changed the title Array parameters should be readonly Array parameters should be readonly Jun 17, 2023
@thesayyn thesayyn added the good first issue Good for newcomers label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants