Repository: microsoft/kiota (csharp)

Issue:
Cannot write null to a nullable value
Our API depends on null's being allowed as part of the request:

```
const updateWidgetRequest: UpdateWidgetRequest = {
  name: 'Sproket',
  size: 5,
  inspectionDetails: null,
};
```

This is different than sending undefined for inspectionDetails. Our API treats undefined on patch as no change, but null as a means to clear the value.

While the swagger file defines the type as nullable, the generated code only allows `InspectionDetails | undefined`

We've tried to hack a value by doing:

`inspectionDetails: <InspectionDetails>(<unknown>null)`

This is awful and still doesn't work. This call to writeObjectValue strips it.

Pull request:
Fixes https://github.com/microsoft/kiota-typescript/issues/1188
2 part for processing null values

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9fb6bb685f..40b461cb27 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 - Fixed an issue where models would be missing when they had no properties and a single allOf entry. [#5014](https://github.com/microsoft/kiota/issues/5014)
 - Reverts modification of responses in output openApi file when generating plugins [#4945](https://github.com/microsoft/kiota/issues/4945)
+- Expand properties types with null type for Typescript. [#4993](https://github.com/microsoft/kiota-typescript/issues/1188)
 
 ## [1.17.0] - 2024-08-09
 
diff --git a/src/Kiota.Builder/Writers/TypeScript/CodePropertyWriter.cs b/src/Kiota.Builder/Writers/TypeScript/CodePropertyWriter.cs
index bd5ee91049..fb1aaf201b 100644
--- a/src/Kiota.Builder/Writers/TypeScript/CodePropertyWriter.cs
+++ b/src/Kiota.Builder/Writers/TypeScript/CodePropertyWriter.cs
@@ -33,9 +33,13 @@ private static void WriteCodePropertyForInterface(CodeProperty codeElement, Lang
             case CodePropertyKind.RequestBuilder:
                 writer.WriteLine($"get {codeElement.Name.ToFirstCharacterLowerCase()}(): {returnType};");
                 break;
-            default:
+            case CodePropertyKind.QueryParameter:
+            case CodePropertyKind.AdditionalData:
                 writer.WriteLine($"{codeElement.Name.ToFirstCharacterLowerCase()}?: {returnType}{(isFlagEnum ? "[]" : string.Empty)};");
                 break;
+            default:
+                writer.WriteLine($"{codeElement.Name.ToFirstCharacterLowerCase()}?: {returnType}{(isFlagEnum ? "[]" : string.Empty)} | null;");
+                break;
         }
     }
 }


Test patch:
diff --git a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodePropertyWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodePropertyWriterTests.cs
index 70d56bf989..99eb614fd9 100644
--- a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodePropertyWriterTests.cs
+++ b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodePropertyWriterTests.cs
@@ -69,12 +69,12 @@ public void WritesRequestBuilder()
         Assert.DoesNotContain("?", result, StringComparison.OrdinalIgnoreCase);
     }
     [Fact]
-    public void WritesCustomProperty()
+    public void WritesCustomPropertyWithDefaultedNullType()
     {
         property.Kind = CodePropertyKind.Custom;
         writer.Write(property);
         var result = tw.ToString();
-        Assert.Contains($"{PropertyName}?: {TypeName}", result);
+        Assert.Contains($"{PropertyName}?: {TypeName} | null", result);
         Assert.DoesNotContain("| undefined", result); // redundant with ?
     }
     [Fact]