Skip to content

Commit b4531f1

Browse files
JeanMechedylhunn
authored andcommitted
fix(core): typing of TestBed Common token. (#49997)
Both `ComponentFixtureAutoDetect` and `ComponentFixtureNoNgZone` are mistyped. Tokens are only instantiated with booleans. PR Close #49997
1 parent 022ed5a commit b4531f1

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

goldens/public-api/core/testing/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ export class ComponentFixture<T> {
4949
}
5050

5151
// @public (undocumented)
52-
export const ComponentFixtureAutoDetect: InjectionToken<boolean[]>;
52+
export const ComponentFixtureAutoDetect: InjectionToken<boolean>;
5353

5454
// @public (undocumented)
55-
export const ComponentFixtureNoNgZone: InjectionToken<boolean[]>;
55+
export const ComponentFixtureNoNgZone: InjectionToken<boolean>;
5656

5757
// @public
5858
export function discardPeriodicTasks(): void;

packages/core/testing/src/test_bed.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,8 @@ export class TestBedImpl implements TestBed {
598598
throw new Error(`It looks like '${stringify(type)}' has not been compiled.`);
599599
}
600600

601-
// TODO: Don't cast as `InjectionToken<boolean>`, proper type is boolean[]
602-
const noNgZone = this.inject(ComponentFixtureNoNgZone as InjectionToken<boolean>, false);
603-
// TODO: Don't cast as `InjectionToken<boolean>`, proper type is boolean[]
604-
const autoDetect: boolean =
605-
this.inject(ComponentFixtureAutoDetect as InjectionToken<boolean>, false);
601+
const noNgZone = this.inject(ComponentFixtureNoNgZone, false);
602+
const autoDetect: boolean = this.inject(ComponentFixtureAutoDetect, false);
606603
const ngZone: NgZone|null = noNgZone ? null : this.inject(NgZone, null);
607604
const componentFactory = new ComponentFactory(componentDef);
608605
const initComponent = () => {

packages/core/testing/src/test_bed_common.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@ export class TestComponentRenderer {
3131
/**
3232
* @publicApi
3333
*/
34-
export const ComponentFixtureAutoDetect =
35-
new InjectionToken<boolean[]>('ComponentFixtureAutoDetect');
34+
export const ComponentFixtureAutoDetect = new InjectionToken<boolean>('ComponentFixtureAutoDetect');
3635

3736
/**
3837
* @publicApi
3938
*/
40-
export const ComponentFixtureNoNgZone = new InjectionToken<boolean[]>('ComponentFixtureNoNgZone');
39+
export const ComponentFixtureNoNgZone = new InjectionToken<boolean>('ComponentFixtureNoNgZone');
4140

4241
/**
4342
* @publicApi

0 commit comments

Comments
 (0)