Inherit top-level type (e.g. PlainMessage)
See original GitHub issueI 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:
Protobuf
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:
- Created a year ago
- Comments:7 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Absolutely, @sjbarag. We’re just wrapping up some work on the plugin framework, but this issue is up next!
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 aninterface IExample
for everymessage Example
alongside the class, which behaves exactly like a recursivePlainMessage<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!