test-utils: add const type parameter modifier to TestApiProvider and TestApiRegistry.from

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2026-02-27 20:22:28 +01:00
parent 32cb991728
commit 56d01c7a7d
3 changed files with 9 additions and 4 deletions
@@ -0,0 +1,5 @@
---
'@backstage/test-utils': patch
---
Added `const` type parameter modifier to `TestApiProvider` and `TestApiRegistry.from` for improved type inference of API pairs.
+2 -2
View File
@@ -340,7 +340,7 @@ export function setupRequestMockHandlers(worker: {
export type SyncLogCollector = () => void;
// @public
export const TestApiProvider: <T extends any[]>(
export const TestApiProvider: <const T extends any[]>(
props: TestApiProviderProps<T>,
) => JSX_2.Element;
@@ -352,7 +352,7 @@ export type TestApiProviderProps<TApiPairs extends any[]> = {
// @public
export class TestApiRegistry implements ApiHolder {
static from<TApiPairs extends any[]>(
static from<const TApiPairs extends any[]>(
...apis: readonly [...TestApiProviderPropsApiPairs<TApiPairs>]
): TestApiRegistry;
get<T>(api: ApiRef<T>): T | undefined;
@@ -63,7 +63,7 @@ export class TestApiRegistry implements ApiHolder {
* @public
* @param apis - A list of pairs mapping an ApiRef to its respective implementation.
*/
static from<TApiPairs extends any[]>(
static from<const TApiPairs extends any[]>(
...apis: readonly [...TestApiProviderPropsApiPairs<TApiPairs>]
) {
return new TestApiRegistry(
@@ -124,7 +124,7 @@ export class TestApiRegistry implements ApiHolder {
*
* @public
*/
export const TestApiProvider = <T extends any[]>(
export const TestApiProvider = <const T extends any[]>(
props: TestApiProviderProps<T>,
) => {
return (