From 9713b9cea6ddbf60ce823425a2146a386a072694 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 10 Feb 2022 13:34:39 -0500 Subject: [PATCH] - adds error prototype inheritance for typescript Signed-off-by: Vincent Biret --- src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs index 831bc48091..ae8b16d73b 100644 --- a/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs @@ -107,6 +107,8 @@ private static void WriteSerializationRegistration(List serializationMod private void WriteConstructorBody(CodeClass parentClass, CodeMethod currentMethod, LanguageWriter writer, bool inherits) { if(inherits || parentClass.IsErrorDefinition) writer.WriteLine("super();"); + if(parentClass.IsErrorDefinition && parentClass.StartBlock is CodeClass.Declaration declaration) + writer.WriteLine($"Object.setPrototypeOf(this, {declaration.Inherits.Name.ToFirstCharacterUpperCase()}.prototype);"); var propertiesWithDefaultValues = new List { CodePropertyKind.AdditionalData, CodePropertyKind.BackingStore,