From 62eaa0855e18ffa200e010c235a2222d057b9ad2 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 15 Oct 2026 14:19:03 +0200 Subject: [PATCH] Fix type check of unsupported language codes in Stripe checkout session --- apps/api/src/app/subscription/subscription.service.ts | 8 +++++--- .../api/src/app/subscription/types/string-literal.type.ts | 7 ------- 2 files changed, 5 insertions(+), 10 deletions(-) delete mode 100644 apps/api/src/app/subscription/types/string-literal.type.ts diff --git a/apps/api/src/app/subscription/subscription.service.ts b/apps/api/src/app/subscription/subscription.service.ts index 143f89950b..17beba0077 100644 --- a/apps/api/src/app/subscription/subscription.service.ts +++ b/apps/api/src/app/subscription/subscription.service.ts @@ -23,8 +23,6 @@ import { addMilliseconds, isBefore } from 'date-fns'; import ms, { StringValue } from 'ms'; import Stripe from 'stripe'; -import { StringLiteral } from './types/string-literal.type'; - @Injectable() export class SubscriptionService { private readonly logger = new Logger(SubscriptionService.name); @@ -270,7 +268,11 @@ export class SubscriptionService { const unsupportedLanguageCodes: Record< Exclude< (typeof SUPPORTED_LANGUAGE_CODES)[number], - StringLiteral + // Extract removes OtherString of Stripe, which matches every string + Extract< + Stripe.Checkout.SessionCreateParams.Locale, + (typeof SUPPORTED_LANGUAGE_CODES)[number] + > >, true > = { diff --git a/apps/api/src/app/subscription/types/string-literal.type.ts b/apps/api/src/app/subscription/types/string-literal.type.ts deleted file mode 100644 index 1f25cb81a4..0000000000 --- a/apps/api/src/app/subscription/types/string-literal.type.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Removes the open string type (e.g. OtherString of Stripe), which matches -// every string, and keeps only the string literals -export type StringLiteral = T extends string - ? string extends T - ? never - : T - : never;