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,