From 5611759bf06cda78bf1412977563143654044d43 Mon Sep 17 00:00:00 2001 From: czindel-sap <162141099+czindel-sap@users.noreply.github.com> Date: Mon, 10 Mar 2025 11:28:07 +0100 Subject: [PATCH] Improper use of Intersection Type See https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#intersection-types. Using `&` might be convenient while defining types, but leads to ugly situations when using theses types. With Union Types(`|`) TypeScript would correctly infer the actual type by using a simple if or and type guard. But like in the given example everything is merged together and there is no way to differentiate between a entity or context etc. Which is forcing the consumer to do a type cast. --- apis/csn.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/csn.d.ts b/apis/csn.d.ts index 48fc1205..51847254 100644 --- a/apis/csn.d.ts +++ b/apis/csn.d.ts @@ -43,7 +43,7 @@ export type FQN = string /** * Definitions are the central elements of a CDS model. */ -export type Definition = context & service & type & struct & entity & Association +export type Definition = context | service | type | struct | entity | Association // NOTE: If we use & instead of | CSN.definitions values would be reduced to /**