From 5b10d4f549ebc12645ad08cba8ab7b91eaa87d28 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Tue, 6 Jul 2021 17:18:35 -0400 Subject: [PATCH] fix(@schematics/angular): remove unsafe any usage in application spec file The `nativeElement` property on a `TestBed` fixture is of type `any`. In one of the tests within a new application's spec file, the `nativeElement` is accessed but not cast to an appropriate type which results in potentially unsafe member access. The `nativeElement` is now cast as an `HTMLElement` and allows additional usage to be type checked. --- .../application/other-files/app.component.spec.ts.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/schematics/angular/application/other-files/app.component.spec.ts.template b/packages/schematics/angular/application/other-files/app.component.spec.ts.template index fcdf822fb55b..8eda79d528db 100644 --- a/packages/schematics/angular/application/other-files/app.component.spec.ts.template +++ b/packages/schematics/angular/application/other-files/app.component.spec.ts.template @@ -29,7 +29,7 @@ describe('AppComponent', () => { it('should render title', () => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); - const compiled = fixture.nativeElement; - expect(compiled.querySelector('.content span').textContent).toContain('<%= name %> app is running!'); + const compiled = fixture.nativeElement as HTMLElement; + expect(compiled.querySelector('.content span')?.textContent).toContain('<%= name %> app is running!'); }); });