From 88fe27ba60b8552d4a466a011f151d120699db07 Mon Sep 17 00:00:00 2001 From: "Per Christian B. Viken" Date: Fri, 3 Oct 2025 19:14:24 +0200 Subject: [PATCH] refactor(lib): Use globalThis to avoid potential conflicts Fixes #147 --- CHANGELOG.md | 1 + TypeContractor/TypeScript/ApiClientWriter.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 782f063..e21e937 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Move to xUnit v3 (#162) - Generate Zod v4 schemas (#168) +- Use `globalThis.Response` instead of `Response` to avoid conflicts (#147) ## [0.17.4.1] - 2025-09-19 diff --git a/TypeContractor/TypeScript/ApiClientWriter.cs b/TypeContractor/TypeScript/ApiClientWriter.cs index b0064e5..6ecfb6a 100644 --- a/TypeContractor/TypeScript/ApiClientWriter.cs +++ b/TypeContractor/TypeScript/ApiClientWriter.cs @@ -50,7 +50,7 @@ public string Write(ApiClient apiClient, IEnumerable allTypes, TypeS var parameterMap = parameters.Select(x => $"{x.ParameterName}{((x.Type?.IsNullable ?? false) && !x.IsOptional ? "?" : "")}: {x.Type?.FullTypeName ?? "any"}{(x.IsOptional ? " | undefined" : "")}").ToList(); var returnType = (endpoint.ReturnType is null ? null - : converter.GetDestinationType(endpoint.ReturnType, endpoint.ReturnType.CustomAttributes, false, TypeChecks.IsNullable(endpoint.ReturnType))?.FullTypeName) ?? "Response"; + : converter.GetDestinationType(endpoint.ReturnType, endpoint.ReturnType.CustomAttributes, false, TypeChecks.IsNullable(endpoint.ReturnType))?.FullTypeName) ?? "globalThis.Response"; var routeParams = endpoint.Parameters .Where(x => x.FromRoute)