Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inherit top-level type (e.g. PlainMessage)

See original GitHub issue

I have some user-facing functions that take PlainMessage<T> as input. The problem is that PlainMessage doesn’t seem to trickle down to properties that themselves are messages. Take the below snippets as an example:


syntax = "proto3";

option optimize_for = SPEED;

message Op {
  string denomination = 1;

message Msg {
  repeated Op ops = 1;
// Type
type x = PlainMessage<Msg>

// Expected
type x = {
    ops: PlainMessage<Op>[];

// Actual
type x = {
    ops: Op[];

When using PlainMessage<T> I would expect all properties of T that are also messages to be also referenced as PlainMessage rather than expecting the (full) Message. Is this an intentional design choice and can this be worked around without a custom type outside the library or is this an oversight? Thanks in advanced!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

timostammcommented, Oct 12, 2022

Absolutely, @sjbarag. We’re just wrapping up some work on the plugin framework, but this issue is up next!

timostammcommented, Sep 26, 2022

Hey Brian, thanks for this issue!

The behavior is a design choice - the type is an exact representation for a message cloned with the spread operator: let plain: PlainMessage<Example> = {...example};

I’m aware that this is not always helpful in practice. Making PlainMessage<T> recursive is definitely an option, but I’m not quite sure yet that it is the best option. So before we consider this, we will be looking into generating an interface IExample for every message Example alongside the class, which behaves exactly like a recursive PlainMessage<T>.

The rationale for interface IExample is that a simple interface can be a bit more approachable and can provide better TypeScript error messages than a mapped type. It also means we would generate a bit more code, so we obviously want to consider this carefully.

Expect to see some updates regarding this soonish. In the meantime, I don’t see any complications from using your own recursive version of PlainMessage<T>. If you do, please do let us know about how it works out for you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · bufbuild/protobuf-es - GitHub
Proposal: Inherit constructor and static methods from base Message class. #290 opened 8 days ago by fubhy ... Inherit top-level type (e.g. PlainMessage)....
Read more >
Python tkinter - successfully inherit from toplevel
I am trying to use an object-oriented approach to create a class that inherits from tkinter's Toplevel, triggered by pressing a button in ......
Read more >
Message (JavaDoc User Messaging Service (UMS) 12.1.2 API)
Examples that show how to set the content of a Message: Plain Text Message: ... Fields inherited from interface oracle.sdp.messaging.MessagingObject.
Read more >
An Extensible Format for Email Feedback Reports RFC 5965
Format of Email Feedback Reports To satisfy the requirements, an email feedback report is defined as a [MIME] message with a top-level MIME...
Read more >
Mime Class - LumiSoft
Content-Type: name = "" is specified (old RFC 822 message) ... (Inherited from Object.) ... text entity */ Content-Type: text/plain Message body text....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found