Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7a624f

Browse files
committed
Fix TypeScript strict null handling for header values.
1 parent 5621b34 commit a7a624f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

example/ts/exampleApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ class ExampleApiHttpClient implements IExampleApi {
434434
if (!value) {
435435
return createResponseError(status, result.json) as IServiceResult<IGetWidgetResponse>;
436436
}
437-
let headerValue: string;
437+
let headerValue: string | null | undefined;
438438
headerValue = result.response.headers.get('eTag');
439439
if (headerValue != null) {
440440
value.eTag = headerValue;

src/Facility.CodeGen.JavaScript/JavaScriptGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ protected override CodeGenOutput GenerateOutputCore(ServiceInfo service)
233233

234234
if (httpMethodInfo.ResponseHeaderFields.Count != 0)
235235
{
236-
code.WriteLine("let headerValue" + IfTypeScript(": string") + ";");
236+
code.WriteLine("let headerValue" + IfTypeScript(": string | null | undefined") + ";");
237237
foreach (var httpHeaderField in httpMethodInfo.ResponseHeaderFields)
238238
{
239239
code.WriteLine($"headerValue = result.response.headers.get('{httpHeaderField.Name}');");

0 commit comments

Comments
 (0)