Skip to content

Commit 6cd91c6

Browse files
JeanMechedylhunn
authored andcommitted
refactor(devtools): enables typescript strict option (angular#53340)
Enabling `strict` is part of an effort to improve the quality of the devtools code base. One of the direct side effect is to enable `noImplicitAny`, `strictPropertyInitialization` and `strictBindCallApply`. This commit also replaces `fullTemplateTypeCheck` with `stringTemplates`. PR Close angular#53340
1 parent 1e3bcfe commit 6cd91c6

90 files changed

Lines changed: 830 additions & 569 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

devtools/projects/demo-standalone/src/app/demo-app/demo-app.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import {ZippyComponent} from './zippy.component';
2626
schemas: [CUSTOM_ELEMENTS_SCHEMA]
2727
})
2828
export class DemoAppComponent {
29-
@ViewChild(ZippyComponent) zippy: ZippyComponent;
30-
@ViewChild('elementReference') elementRef: ElementRef;
29+
@ViewChild(ZippyComponent) zippy!: ZippyComponent;
30+
@ViewChild('elementReference') elementRef!: ElementRef;
3131

3232
@Input('input_one') inputOne = 'input one';
3333
@Input() inputTwo = 'input two';

devtools/projects/demo-standalone/src/app/demo-app/heavy.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import {Component, Input} from '@angular/core';
1010

11-
const fib = (n: number) => {
11+
const fib = (n: number): number => {
1212
if (n === 1 || n === 2) {
1313
return 1;
1414
}

devtools/projects/demo-standalone/src/app/demo-app/todo/home/todo.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export interface Todo {
4545
`
4646
})
4747
export class TodoComponent {
48-
@Input() todo: Todo;
48+
@Input() todo!: Todo;
4949
@Output() update = new EventEmitter();
5050
@Output() delete = new EventEmitter();
5151

devtools/projects/demo-standalone/src/app/demo-app/todo/home/todos.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class TodosFilter implements PipeTransform {
3838
}
3939
}
4040

41-
const fib = (n: number) => {
41+
const fib = (n: number): number => {
4242
if (n === 1 || n === 2) {
4343
return 1;
4444
}
@@ -101,7 +101,7 @@ export class TodosComponent implements OnInit, OnDestroy {
101101
@Output() delete = new EventEmitter();
102102
@Output() add = new EventEmitter();
103103

104-
private hashListener: EventListenerOrEventListenerObject;
104+
private hashListener!: EventListenerOrEventListenerObject;
105105

106106
constructor(private cdRef: ChangeDetectorRef) {}
107107

devtools/projects/demo-standalone/src/app/demo-app/todo/todo-app.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ import {DialogComponent} from './dialog.component';
5252
`
5353
})
5454
export class TodoAppComponent {
55-
name: string;
56-
animal: string;
55+
name!: string;
56+
animal!: string;
5757

5858
constructor(public dialog: MatDialog) {}
5959

devtools/projects/demo-standalone/src/app/demo-app/zippy.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ import {Component, Input} from '@angular/core';
4242
`
4343
})
4444
export class ZippyComponent {
45-
@Input() title: string;
45+
@Input() title!: string;
4646
visible = false;
4747
}

devtools/projects/demo-standalone/src/app/devtools-app/devtools-app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ import {IFrameMessageBus} from '../../../../../src/iframe-message-bus';
4747
})
4848
export class DevToolsComponent {
4949
messageBus: IFrameMessageBus|null = null;
50-
@ViewChild('ref') iframe: ElementRef;
50+
@ViewChild('ref') iframe!: ElementRef;
5151
}

devtools/projects/ng-devtools-backend/src/lib/component-inspector/component-inspector.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface ComponentInspectorOptions {
2323
}
2424

2525
export class ComponentInspector {
26-
private _selectedComponent: {component: Type<unknown>; host: HTMLElement | null};
26+
private _selectedComponent!: {component: Type<unknown>; host: HTMLElement | null};
2727
private readonly _onComponentEnter;
2828
private readonly _onComponentSelect;
2929
private readonly _onComponentLeave;
@@ -57,7 +57,7 @@ export class ComponentInspector {
5757

5858
if (this._selectedComponent.component && this._selectedComponent.host) {
5959
this._onComponentSelect(
60-
initializeOrGetDirectiveForestHooks().getDirectiveId(this._selectedComponent.component));
60+
initializeOrGetDirectiveForestHooks().getDirectiveId(this._selectedComponent.component)!);
6161
}
6262
}
6363

@@ -73,7 +73,7 @@ export class ComponentInspector {
7373
if (this._selectedComponent.component && this._selectedComponent.host) {
7474
highlight(this._selectedComponent.host);
7575
this._onComponentEnter(
76-
initializeOrGetDirectiveForestHooks().getDirectiveId(this._selectedComponent.component));
76+
initializeOrGetDirectiveForestHooks().getDirectiveId(this._selectedComponent.component)!);
7777
}
7878
}
7979

0 commit comments

Comments
 (0)