diff --git a/types/google-protobuf/google-protobuf-tests.ts b/types/google-protobuf/google-protobuf-tests.ts index 8104ba4680..1f1c69cc6c 100644 --- a/types/google-protobuf/google-protobuf-tests.ts +++ b/types/google-protobuf/google-protobuf-tests.ts @@ -534,3 +534,8 @@ class MySimple extends jspb.Message { return jspb.Message.getField(this, 15) != null; } }; + +// ensures messages are cloneable without a redundant cast +const myMessage: MySimple = new MySimple(); +const myClonedMessage: MySimple = myMessage.clone(); +const myClonedMessage2: MySimple = myMessage.cloneMessage() diff --git a/types/google-protobuf/index.d.ts b/types/google-protobuf/index.d.ts index cc6de4f146..ee70b7618c 100644 --- a/types/google-protobuf/index.d.ts +++ b/types/google-protobuf/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/google/google-protobuf // Definitions by: Marcus Longmuir // Chaitanya Kamatham +// Austin Bonander // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped type ByteSource = ArrayBuffer | Uint8Array | number[] | string; @@ -110,8 +111,8 @@ export abstract class Message { static equals(m1: Message, m2: Message): boolean; static compareExtensions(extension1: {}, extension2: {}): boolean; static compareFields(field1: any, field2: any): boolean; - cloneMessage(): Message; - clone(): Message; + cloneMessage(): this; + clone(): this; static clone(msg: T): T; static cloneMessage(msg: T): T; static copyInto(fromMessage: Message, toMessage: Message): void;