Skip to content

Commit 7db7a32

Browse files
committed
refactor(youtube-player): fix strict property initialization errors
Updates the code to be compatible with strict property initialization.
1 parent c59c97a commit 7db7a32

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/youtube-player/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"rootDir": "..",
66
"baseUrl": ".",
77
"paths": {},
8-
"types": ["jasmine"]
8+
"types": ["jasmine"],
9+
"strictPropertyInitialization": true
910
},
1011
"include": ["*.ts", "../dev-mode-types.d.ts"]
1112
}

src/youtube-player/youtube-player-placeholder.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ export type PlaceholderImageQuality = 'high' | 'standard' | 'low';
3939
})
4040
export class YouTubePlayerPlaceholder {
4141
/** ID of the video for which to show the placeholder. */
42-
@Input() videoId: string;
42+
@Input() videoId!: string;
4343

4444
/** Width of the video for which to show the placeholder. */
45-
@Input() width: number;
45+
@Input() width!: number;
4646

4747
/** Height of the video for which to show the placeholder. */
48-
@Input() height: number;
48+
@Input() height!: number;
4949

5050
/** Whether the video is currently being loaded. */
51-
@Input() isLoading: boolean;
51+
@Input() isLoading: boolean = false;
5252

5353
/** Accessible label for the play button. */
54-
@Input() buttonLabel: string;
54+
@Input() buttonLabel!: string;
5555

5656
/** Quality of the placeholder image. */
57-
@Input() quality: PlaceholderImageQuality;
57+
@Input() quality!: PlaceholderImageQuality;
5858

5959
/** Gets the background image showing the placeholder. */
6060
protected _getBackgroundImage(): string | undefined {

src/youtube-player/youtube-player.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ class TestApp {
803803
onPlaybackRateChange = jasmine.createSpy('onPlaybackRateChange');
804804
onError = jasmine.createSpy('onError');
805805
onApiChange = jasmine.createSpy('onApiChange');
806-
@ViewChild('player') youtubePlayer: YouTubePlayer;
806+
@ViewChild('player') youtubePlayer!: YouTubePlayer;
807807
}
808808

809809
@Component({
@@ -821,6 +821,6 @@ class StaticStartEndSecondsApp {
821821
template: `<youtube-player [videoId]="videoId"/>`,
822822
})
823823
class NoEventsApp {
824-
@ViewChild(YouTubePlayer) player: YouTubePlayer;
824+
@ViewChild(YouTubePlayer) player!: YouTubePlayer;
825825
videoId = VIDEO_ID;
826826
}

src/youtube-player/youtube-player.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ export class YouTubePlayer implements AfterViewInit, OnChanges, OnDestroy {
251251

252252
/** The element that will be replaced by the iframe. */
253253
@ViewChild('youtubeContainer', {static: true})
254-
youtubeContainer: ElementRef<HTMLElement>;
254+
youtubeContainer!: ElementRef<HTMLElement>;
255255

256256
constructor(...args: unknown[]);
257257

0 commit comments

Comments
 (0)