Skip to content

Commit ec276bf

Browse files
committed
update PR
1 parent 3df6994 commit ec276bf

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

projects/testing-library/src/lib/models.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ import {
55
EventEmitter,
66
EnvironmentProviders,
77
Provider,
8-
ValueProvider,
9-
ClassProvider,
10-
ExistingProvider,
11-
FactoryProvider,
128
Signal,
13-
InputSignalWithTransform
9+
InputSignalWithTransform,
1410
} from '@angular/core';
1511
import { ComponentFixture, DeferBlockBehavior, DeferBlockState, TestBed } from '@angular/core/testing';
1612
import { Routes } from '@angular/router';
@@ -166,7 +162,7 @@ export interface RenderComponentOptions<ComponentType, Q extends Queries = typeo
166162
* declarations: [ CustomerDetailComponent, ButtonComponent ]
167163
* })
168164
*/
169-
declarations?: Array<Type<any> | any[]>;
165+
declarations?: (Type<unknown> | unknown[])[];
170166
/**
171167
* @description
172168
* A collection of providers needed to render the component via Dependency Injection, for example, injectable services or tokens.
@@ -187,7 +183,7 @@ export interface RenderComponentOptions<ComponentType, Q extends Queries = typeo
187183
* ]
188184
* })
189185
*/
190-
providers?: Array<Provider | EnvironmentProviders>;
186+
providers?: (Provider | EnvironmentProviders)[];
191187
/**
192188
* @description
193189
* A collection of imports needed to render the component, for example, shared modules.
@@ -205,7 +201,7 @@ export interface RenderComponentOptions<ComponentType, Q extends Queries = typeo
205201
* ]
206202
* })
207203
*/
208-
imports?: Array<Type<any> | ModuleWithProviders<any>>;
204+
imports?: (Type<unknown> | ModuleWithProviders<unknown>)[];
209205
/**
210206
* @description
211207
* A collection of schemas needed to render the component.
@@ -327,7 +323,7 @@ export interface RenderComponentOptions<ComponentType, Q extends Queries = typeo
327323
* ]
328324
* })
329325
*/
330-
componentProviders?: Array<ValueProvider | ClassProvider | ExistingProvider | FactoryProvider>;
326+
componentProviders?: Provider[];
331327
/**
332328
* @description
333329
* Collection of child component specified providers to override with
@@ -361,7 +357,7 @@ export interface RenderComponentOptions<ComponentType, Q extends Queries = typeo
361357
* ]
362358
* })
363359
*/
364-
componentImports?: (Type<any> | any[])[];
360+
componentImports?: (Type<unknown> | unknown[])[];
365361
/**
366362
* @description
367363
* Queries to bind. Overrides the default set from DOM Testing Library unless merged.
@@ -475,7 +471,7 @@ export interface RenderComponentOptions<ComponentType, Q extends Queries = typeo
475471

476472
export interface ComponentOverride<T> {
477473
component: Type<T>;
478-
providers: any[];
474+
providers: (Provider | EnvironmentProviders)[];
479475
}
480476

481477
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
@@ -509,7 +505,7 @@ export interface Config extends Pick<RenderComponentOptions<any>, 'excludeCompon
509505
/**
510506
* Imports that are added to the imports
511507
*/
512-
defaultImports: any[];
508+
defaultImports?: (Type<unknown> | ModuleWithProviders<unknown>)[];
513509
/**
514510
* Set to `true` to use zoneless change detection.
515511
* This automatically adds `provideZonelessChangeDetection` to the default imports.

projects/testing-library/src/lib/testing-library.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
OnChanges,
77
OutputRef,
88
OutputRefSubscription,
9+
Provider,
910
SimpleChange,
1011
SimpleChanges,
1112
Type,
@@ -436,7 +437,7 @@ function overrideComponentImports<SutType>(sut: Type<SutType> | string, imports:
436437
function overrideChildComponentProviders(componentOverrides: ComponentOverride<any>[]) {
437438
if (componentOverrides) {
438439
for (const { component, providers } of componentOverrides) {
439-
TestBed.overrideComponent(component, { set: { providers } });
440+
TestBed.overrideComponent(component, { set: { providers: providers as Provider[] } });
440441
}
441442
}
442443
}
@@ -499,7 +500,7 @@ function addAutoDeclarations<SutType>(
499500
wrapper,
500501
}: Pick<RenderTemplateOptions<any>, 'declarations' | 'excludeComponentDeclaration' | 'wrapper'>,
501502
) {
502-
const nonStandaloneDeclarations = declarations?.filter((d) => !isStandalone(d));
503+
const nonStandaloneDeclarations = declarations.filter((d) => !isStandalone(d as Type<any>));
503504
if (typeof sut === 'string') {
504505
if (wrapper && isStandalone(wrapper)) {
505506
return nonStandaloneDeclarations;

0 commit comments

Comments
 (0)