From 58de04a18a912ac3e30c016ec7016e8eedb8db89 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Tue, 8 Oct 2024 18:16:57 +0300 Subject: [PATCH] Fix build --- src/Kiota.Builder/Refiners/TypeScriptRefiner.cs | 2 +- src/Kiota.Builder/Writers/TypeScript/CodeFunctionWriter.cs | 5 ++++- src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs index 23d44d5b00..ce50121a46 100644 --- a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs +++ b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs @@ -1462,7 +1462,7 @@ private static void AddDeserializerUsingToDiscriminatorFactoryForComposedTypePar function.AddUsing(new CodeUsing { - Name = modelDeserializerFunction.Parent.Name, + Name = modelDeserializerFunction.Name, Declaration = new CodeType { Name = modelDeserializerFunction.Name, diff --git a/src/Kiota.Builder/Writers/TypeScript/CodeFunctionWriter.cs b/src/Kiota.Builder/Writers/TypeScript/CodeFunctionWriter.cs index f0101a73a8..27e5d4dc08 100644 --- a/src/Kiota.Builder/Writers/TypeScript/CodeFunctionWriter.cs +++ b/src/Kiota.Builder/Writers/TypeScript/CodeFunctionWriter.cs @@ -336,7 +336,10 @@ private string FindFunctionInNameSpace(string functionName, CodeElement codeElem var codeFunction = Array.Find(codeFunctions, func => func.GetImmediateParentOfType().Name == myNamespace.Name) ?? throw new InvalidOperationException($"Function {functionName} not found in namespace {myNamespace.Name}"); - return conventions.GetTypeString(new CodeType { TypeDefinition = codeFunction }, codeElement, false); + + var targetElement = codeElement.GetImmediateParentOfType(); + + return GetTypescriptTypeString(new CodeType { TypeDefinition = codeFunction }, targetElement, includeCollectionInformation: false); } private void WriteSerializerFunction(CodeFunction codeElement, LanguageWriter writer) diff --git a/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs index ce8ae9769b..c72aae643b 100644 --- a/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs @@ -16,7 +16,8 @@ public override void WriteCodeElement(CodeMethod codeElement, LanguageWriter wri ArgumentNullException.ThrowIfNull(writer); if (codeElement.Parent is CodeFunction) return; - var returnType = GetTypescriptTypeString(codeElement.ReturnType, codeElement, inlineComposedTypeString: true); + var codeFile = codeElement.GetImmediateParentOfType(); + var returnType = GetTypescriptTypeString(codeElement.ReturnType, codeFile, inlineComposedTypeString: true); var isVoid = "void".EqualsIgnoreCase(returnType); WriteMethodDocumentation(codeElement, writer, isVoid); WriteMethodPrototype(codeElement, writer, returnType, isVoid); @@ -30,6 +31,7 @@ private void WriteMethodDocumentation(CodeMethod code, LanguageWriter writer, bo } internal static void WriteMethodDocumentationInternal(CodeMethod code, LanguageWriter writer, bool isVoid, TypeScriptConventionService typeScriptConventionService) { + var codeFile = code.GetImmediateParentOfType(); var returnRemark = (isVoid, code.IsAsync) switch { (true, _) => string.Empty, @@ -41,7 +43,7 @@ internal static void WriteMethodDocumentationInternal(CodeMethod code, LanguageW code.Parameters .Where(static x => x.Documentation.DescriptionAvailable) .OrderBy(static x => x.Name) - .Select(x => $"@param {x.Name} {x.Documentation.GetDescription(type => GetTypescriptTypeString(type, code, inlineComposedTypeString: true), ReferenceTypePrefix, ReferenceTypeSuffix, RemoveInvalidDescriptionCharacters)}") + .Select(x => $"@param {x.Name} {x.Documentation.GetDescription(type => GetTypescriptTypeString(type, codeFile, inlineComposedTypeString: true), ReferenceTypePrefix, ReferenceTypeSuffix, RemoveInvalidDescriptionCharacters)}") .Union([returnRemark]) .Union(GetThrownExceptionsRemarks(code))); }