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:
@@ -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.
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user