Skip to content

Commit

Permalink
fix: TS does not generate getters and setters.
Browse files Browse the repository at this point in the history
This is making properties not show up in export as the are set as private by adding of the unused dom elements.

In general TS export is smaller that C# as it has
- no constructors
- no generated derived requestConfiuration classes.
- no withUrl method.
  • Loading branch information
Andrew Omondi committed Aug 19, 2024
1 parent 1a61fc9 commit 4dcf5e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
14 changes: 1 addition & 13 deletions src/Kiota.Builder/Refiners/TypeScriptRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance
true,
true
);
AddGetterAndSetterMethods(generatedCode,
[
CodePropertyKind.Custom,
CodePropertyKind.AdditionalData,
],
static (_, s) => s.ToCamelCase(UnderscoreArray),
false,
false,
string.Empty,
string.Empty);
AddConstructorsForDefaultValues(generatedCode, true);
cancellationToken.ThrowIfCancellationRequested();
var defaultConfiguration = new GenerationConfiguration();
Expand Down Expand Up @@ -1154,9 +1144,7 @@ private static void ProcessModelClassProperties(CodeClass modelClass, CodeInterf
* Add properties to interfaces
* Replace model classes by interfaces for property types
*/
var serializationFunctions = GetSerializationFunctionsForNamespace(modelClass);
var serializer = serializationFunctions.Item1;
var deserializer = serializationFunctions.Item2;
var (serializer, deserializer) = GetSerializationFunctionsForNamespace(modelClass);

foreach (var mProp in properties)
{
Expand Down
8 changes: 1 addition & 7 deletions src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,10 @@ internal static void WriteMethodPrototypeInternal(CodeMethod code, LanguageWrite
var asyncReturnTypePrefix = code.IsAsync ? "Promise<" : string.Empty;
var asyncReturnTypeSuffix = code.IsAsync ? ">" : string.Empty;
var nullableSuffix = code.ReturnType.IsNullable && !isVoid ? " | undefined" : string.Empty;
var accessorPrefix = code.Kind switch
{
CodeMethodKind.Getter => "get ",
CodeMethodKind.Setter => "set ",
_ => string.Empty
};
var shouldHaveTypeSuffix = !code.IsAccessor && !isConstructor && !string.IsNullOrEmpty(returnType);
var returnTypeSuffix = shouldHaveTypeSuffix ? $" : {asyncReturnTypePrefix}{returnType}{nullableSuffix}{asyncReturnTypeSuffix}" : string.Empty;
var openBracketSuffix = code.Parent is CodeClass || isFunction ? " {" : ";";
writer.WriteLine($"{accessModifier}{functionPrefix}{accessorPrefix}{staticPrefix}{methodName}{(isFunction ? string.Empty : asyncPrefix)}({parameters}){returnTypeSuffix}{openBracketSuffix}");
writer.WriteLine($"{accessModifier}{functionPrefix}{staticPrefix}{methodName}{(isFunction ? string.Empty : asyncPrefix)}({parameters}){returnTypeSuffix}{openBracketSuffix}");
}

internal static void WriteMethodTypecheckIgnoreInternal(CodeMethod code, LanguageWriter writer)
Expand Down

0 comments on commit 4dcf5e6

Please sign in to comment.