From e3c97186c48550f42be7c402310876017afd05e7 Mon Sep 17 00:00:00 2001 From: "Craig Macomber (Microsoft)" <42876482+CraigMacomber@users.noreply.github.com> Date: Fri, 18 Apr 2025 15:14:31 -0700 Subject: [PATCH 1/4] Correct AuthorizationError field declarations for ES 2022 --- packages/loader/driver-utils/src/network.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/loader/driver-utils/src/network.ts b/packages/loader/driver-utils/src/network.ts index 84f6c72ec58d..b9ebfcacecc7 100644 --- a/packages/loader/driver-utils/src/network.ts +++ b/packages/loader/driver-utils/src/network.ts @@ -112,8 +112,16 @@ export class AuthorizationError implements IAuthorizationError, IFluidErrorBase { readonly errorType = DriverErrorTypes.authorizationError; - readonly claims?: string; - readonly tenantId?: string; + + // These properties are not assigned in this class, but instead assigned in the super constructor. + // When targeting ES 2022 or later, TypeScript generates ES6 class fields for these properties. + // This override the own properties dynamically created by the super constructor. + // To prevent this undesired overriding, + // // these are declared using `declare` to indicate this definition is only for the TypeScript typing, + // and the actual fields come from elsewhere. + declare readonly claims?: string; + declare readonly tenantId?: string; + readonly canRetry = false; constructor( From c70489b3f3f5c2a32e516a43f641ea0bdbc2ffc2 Mon Sep 17 00:00:00 2001 From: "Craig Macomber (Microsoft)" <42876482+CraigMacomber@users.noreply.github.com> Date: Fri, 18 Apr 2025 15:18:59 -0700 Subject: [PATCH 2/4] Update packages/loader/driver-utils/src/network.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/loader/driver-utils/src/network.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/loader/driver-utils/src/network.ts b/packages/loader/driver-utils/src/network.ts index b9ebfcacecc7..a6b9bdce6ce0 100644 --- a/packages/loader/driver-utils/src/network.ts +++ b/packages/loader/driver-utils/src/network.ts @@ -117,7 +117,7 @@ export class AuthorizationError // When targeting ES 2022 or later, TypeScript generates ES6 class fields for these properties. // This override the own properties dynamically created by the super constructor. // To prevent this undesired overriding, - // // these are declared using `declare` to indicate this definition is only for the TypeScript typing, + // these are declared using `declare` to indicate this definition is only for the TypeScript typing, // and the actual fields come from elsewhere. declare readonly claims?: string; declare readonly tenantId?: string; From 6aec47c3ca9040b41436d8d1cfcb4b946a44beaa Mon Sep 17 00:00:00 2001 From: "Craig Macomber (Microsoft)" <42876482+CraigMacomber@users.noreply.github.com> Date: Fri, 18 Apr 2025 15:19:15 -0700 Subject: [PATCH 3/4] Update packages/loader/driver-utils/src/network.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/loader/driver-utils/src/network.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/loader/driver-utils/src/network.ts b/packages/loader/driver-utils/src/network.ts index a6b9bdce6ce0..d213ac776730 100644 --- a/packages/loader/driver-utils/src/network.ts +++ b/packages/loader/driver-utils/src/network.ts @@ -115,7 +115,7 @@ export class AuthorizationError // These properties are not assigned in this class, but instead assigned in the super constructor. // When targeting ES 2022 or later, TypeScript generates ES6 class fields for these properties. - // This override the own properties dynamically created by the super constructor. + // This overrides the own properties dynamically created by the super constructor. // To prevent this undesired overriding, // these are declared using `declare` to indicate this definition is only for the TypeScript typing, // and the actual fields come from elsewhere. From dc56d7d407f5eef213b9ca65fe9970543be7511d Mon Sep 17 00:00:00 2001 From: "Craig Macomber (Microsoft)" <42876482+CraigMacomber@users.noreply.github.com> Date: Fri, 18 Apr 2025 16:21:08 -0700 Subject: [PATCH 4/4] Update packages/loader/driver-utils/src/network.ts --- packages/loader/driver-utils/src/network.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/loader/driver-utils/src/network.ts b/packages/loader/driver-utils/src/network.ts index d213ac776730..dc272155a8b0 100644 --- a/packages/loader/driver-utils/src/network.ts +++ b/packages/loader/driver-utils/src/network.ts @@ -114,8 +114,9 @@ export class AuthorizationError readonly errorType = DriverErrorTypes.authorizationError; // These properties are not assigned in this class, but instead assigned in the super constructor. - // When targeting ES 2022 or later, TypeScript generates ES6 class fields for these properties. - // This overrides the own properties dynamically created by the super constructor. + // When targeting ES 2022 or later, TypeScript would generate ES6 class fields for these properties if they did not use "declare". + // That would override the own properties dynamically created in the super constructor + // resulting in these properties always holding `undefined` instead of their desired values. // To prevent this undesired overriding, // these are declared using `declare` to indicate this definition is only for the TypeScript typing, // and the actual fields come from elsewhere.