Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Typescript process null values #5106

Merged
merged 6 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;");
baywet marked this conversation as resolved.
Show resolved Hide resolved
break;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading