Skip to content

Commit 6f31c73

Browse files
committed
fix(azure-identity,msal-node): make enableAuthMock generic over TModules/TRef
Replaces the IModulesConfigurator<any, any> parameter with a generic <TModules extends Array<AnyModule> = Array<AnyModule>, TRef = unknown> signature, so the optional configure callback keeps the caller's actual TRef type instead of erasing it to unknown. Addresses review feedback on PR #5244 (copilot-pull-request-reviewer).
1 parent 820b9d8 commit 6f31c73

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

packages/modules/azure-identity/src/mock/module.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { IModulesConfigurator, Module } from '@equinor/fusion-framework-module';
1+
import type { AnyModule, IModulesConfigurator, Module } from '@equinor/fusion-framework-module';
22

33
import type { IAuthProvider } from '../AuthProvider.interface.js';
44

@@ -46,6 +46,8 @@ export type AuthMockConfigFn<TRef = unknown> = (auth: MockAuthProvider, ref?: TR
4646
* @param configure - Optional callback to seed the identity, token, or expiry.
4747
* @returns The {@link MockAuthProvider} instance, for calling `login`/`logout`
4848
* or its setters directly, in addition to whatever `configure` already did.
49+
* @template TModules - The array of module descriptors managed by `configurator`.
50+
* @template TRef - Reference type forwarded to `configure`, inferred from `configurator`.
4951
*
5052
* @example
5153
* ```typescript
@@ -56,10 +58,12 @@ export type AuthMockConfigFn<TRef = unknown> = (auth: MockAuthProvider, ref?: TR
5658
* await auth.login({ request: { scopes: ['User.Read'] } });
5759
* ```
5860
*/
59-
export const enableAuthMock = (
60-
// biome-ignore lint/suspicious/noExplicitAny: must be any to support all module types
61-
configurator: IModulesConfigurator<any, any>,
62-
configure?: AuthMockConfigFn,
61+
export const enableAuthMock = <
62+
TModules extends Array<AnyModule> = Array<AnyModule>,
63+
TRef = unknown,
64+
>(
65+
configurator: IModulesConfigurator<TModules, TRef>,
66+
configure?: AuthMockConfigFn<TRef>,
6367
): MockAuthProvider => {
6468
const auth = new MockAuthProvider();
6569
configurator.addConfig({ module: createAuthMockModule(auth), configure });

packages/modules/msal-node/src/mock/module.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { IModulesConfigurator, Module } from '@equinor/fusion-framework-module';
1+
import type { AnyModule, IModulesConfigurator, Module } from '@equinor/fusion-framework-module';
22

33
import type { IAuthProvider } from '../AuthProvider.interface.js';
44

@@ -46,6 +46,8 @@ export type AuthMockConfigFn<TRef = unknown> = (auth: MockAuthProvider, ref?: TR
4646
* @param configure - Optional callback to seed the identity, token, or expiry.
4747
* @returns The {@link MockAuthProvider} instance, for calling `login`/`logout`
4848
* or its setters directly, in addition to whatever `configure` already did.
49+
* @template TModules - The array of module descriptors managed by `configurator`.
50+
* @template TRef - Reference type forwarded to `configure`, inferred from `configurator`.
4951
*
5052
* @example
5153
* ```typescript
@@ -56,10 +58,12 @@ export type AuthMockConfigFn<TRef = unknown> = (auth: MockAuthProvider, ref?: TR
5658
* await auth.login({ request: { scopes: ['User.Read'] } });
5759
* ```
5860
*/
59-
export const enableAuthMock = (
60-
// biome-ignore lint/suspicious/noExplicitAny: must be any to support all module types
61-
configurator: IModulesConfigurator<any, any>,
62-
configure?: AuthMockConfigFn,
61+
export const enableAuthMock = <
62+
TModules extends Array<AnyModule> = Array<AnyModule>,
63+
TRef = unknown,
64+
>(
65+
configurator: IModulesConfigurator<TModules, TRef>,
66+
configure?: AuthMockConfigFn<TRef>,
6367
): MockAuthProvider => {
6468
const auth = new MockAuthProvider();
6569
configurator.addConfig({ module: createAuthMockModule(auth), configure });

0 commit comments

Comments
 (0)