From 248f422578718000809a2e324354e3e0a1a48fc9 Mon Sep 17 00:00:00 2001 From: Stefano Cappa Date: Tue, 23 May 2023 01:12:41 +0200 Subject: [PATCH] fix: restore some syntax fixes Signed-off-by: Stefano Cappa --- .../carousel-previews.component.ts | 9 +++---- .../current-image/current-image.component.ts | 9 +++---- .../loading-spinner.component.ts | 4 +-- .../src/lib/components/dots/dots.component.ts | 7 ++---- .../components/previews/previews.component.ts | 25 ++++++------------- .../upper-buttons/upper-buttons.component.ts | 10 ++------ 6 files changed, 20 insertions(+), 44 deletions(-) diff --git a/projects/ks89/angular-modal-gallery/src/lib/components/carousel/carousel-previews/carousel-previews.component.ts b/projects/ks89/angular-modal-gallery/src/lib/components/carousel/carousel-previews/carousel-previews.component.ts index 986d19e3..d7bb133c 100644 --- a/projects/ks89/angular-modal-gallery/src/lib/components/carousel/carousel-previews/carousel-previews.component.ts +++ b/projects/ks89/angular-modal-gallery/src/lib/components/carousel/carousel-previews/carousel-previews.component.ts @@ -86,21 +86,18 @@ export class CarouselPreviewsComponent extends AccessibleComponent implements On * TODO write doc */ @Input() - // @ts-ignore - id: number; + id!: number; /** * Object of type `InternalLibImage` that represent the visible image. */ @Input() - // @ts-ignore - currentImage: InternalLibImage; + currentImage!: InternalLibImage; /** * Array of `InternalLibImage` that represent the model of this library with all images, * thumbs and so on. */ @Input() - // @ts-ignore - images: InternalLibImage[]; + images!: InternalLibImage[]; /** * Output to emit the clicked preview. The payload contains the `InternalLibImage` associated to the clicked preview. diff --git a/projects/ks89/angular-modal-gallery/src/lib/components/current-image/current-image.component.ts b/projects/ks89/angular-modal-gallery/src/lib/components/current-image/current-image.component.ts index 57907fb7..5d619372 100644 --- a/projects/ks89/angular-modal-gallery/src/lib/components/current-image/current-image.component.ts +++ b/projects/ks89/angular-modal-gallery/src/lib/components/current-image/current-image.component.ts @@ -85,21 +85,18 @@ export class CurrentImageComponent extends AccessibleComponent implements OnInit * the service to call modal gallery without open it manually. */ @Input() - // @ts-ignore - id: number; + id!: number; /** * Object of type `InternalLibImage` that represent the visible image. */ @Input() - // @ts-ignore - currentImage: InternalLibImage; + currentImage!: InternalLibImage; /** * Array of `InternalLibImage` that represent the model of this library with all images, * thumbs and so on. */ @Input() - // @ts-ignore - images: InternalLibImage[]; + images!: InternalLibImage[]; /** * Boolean that it is true if the modal gallery is visible. * If yes, also this component should be visible. diff --git a/projects/ks89/angular-modal-gallery/src/lib/components/current-image/loading-spinner/loading-spinner.component.ts b/projects/ks89/angular-modal-gallery/src/lib/components/current-image/loading-spinner/loading-spinner.component.ts index bad95a7e..31c28866 100644 --- a/projects/ks89/angular-modal-gallery/src/lib/components/current-image/loading-spinner/loading-spinner.component.ts +++ b/projects/ks89/angular-modal-gallery/src/lib/components/current-image/loading-spinner/loading-spinner.component.ts @@ -50,13 +50,13 @@ export class LoadingSpinnerComponent { * It contains a field to choose a loading spinner. */ @Input() - loadingConfig: LoadingConfig | undefined; + loadingConfig!: LoadingConfig; /** * Object of type `AccessibilityConfig` to init custom accessibility features. * For instance, it contains titles, alt texts, aria-labels and so on. */ @Input() - accessibilityConfig!: AccessibilityConfig | undefined; + accessibilityConfig!: AccessibilityConfig; /** * Enum of type `LoadingType` to choose the standard loading spinner. diff --git a/projects/ks89/angular-modal-gallery/src/lib/components/dots/dots.component.ts b/projects/ks89/angular-modal-gallery/src/lib/components/dots/dots.component.ts index 2989adf4..df74ce2c 100644 --- a/projects/ks89/angular-modal-gallery/src/lib/components/dots/dots.component.ts +++ b/projects/ks89/angular-modal-gallery/src/lib/components/dots/dots.component.ts @@ -51,7 +51,7 @@ export class DotsComponent extends AccessibleComponent implements OnInit, OnChan * the service to call modal gallery. */ @Input() - id: number | undefined + id!: number /** * Object of type `InternalLibImage` that represent the visible image. */ @@ -68,7 +68,7 @@ export class DotsComponent extends AccessibleComponent implements OnInit, OnChan * For instance, it contains a param to show/hide this component. */ @Input() - dotsConfig: DotsConfig | undefined; + dotsConfig!: DotsConfig; /** * Output to emit clicks on dots. The payload contains a number that represent @@ -97,9 +97,6 @@ export class DotsComponent extends AccessibleComponent implements OnInit, OnChan * In particular, it's called only one time!!! */ ngOnInit(): void { - if (this.id === null || this.id === undefined) { - throw new Error('Internal library error - id must be defined'); - } const libConfig: LibConfig | undefined = this.configService.getConfig(this.id); if (!libConfig) { throw new Error('Internal library error - libConfig must be defined'); diff --git a/projects/ks89/angular-modal-gallery/src/lib/components/previews/previews.component.ts b/projects/ks89/angular-modal-gallery/src/lib/components/previews/previews.component.ts index d48be4f6..7865691f 100644 --- a/projects/ks89/angular-modal-gallery/src/lib/components/previews/previews.component.ts +++ b/projects/ks89/angular-modal-gallery/src/lib/components/previews/previews.component.ts @@ -54,18 +54,18 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On * the service to call modal gallery. */ @Input() - id: number | undefined; + id!: number; /** * Object of type `InternalLibImage` that represent the visible image. */ @Input() - currentImage: InternalLibImage | undefined; + currentImage!: InternalLibImage; /** * Array of `InternalLibImage` that represent the model of this library with all images, * thumbs and so on. */ @Input() - images: InternalLibImage[] | undefined; + images!: InternalLibImage[]; /** * Optional template reference for the rendering of previews. @@ -135,9 +135,6 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On * In particular, it's called only one time!!! */ ngOnInit(): void { - if (this.id === null || this.id === undefined) { - throw new Error('Internal library error - id must be defined'); - } const libConfig: LibConfig | undefined = this.configService.getConfig(this.id); if (!libConfig) { throw new Error('Internal library error - libConfig must be defined'); @@ -145,9 +142,6 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On this.accessibilityConfig = libConfig.accessibilityConfig; this.slideConfig = libConfig.slideConfig; this.previewConfig = libConfig.previewConfig; - if (!this.currentImage || !this.images) { - throw new Error('Internal library error - currentImage and images must be defined'); - } this.initPreviews(this.currentImage, this.images); } @@ -157,7 +151,7 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On * @returns boolean true if is active, false otherwise */ isActive(preview: InternalLibImage): boolean { - if (!preview || !this.currentImage) { + if (!preview) { return false; } return preview.id === this.currentImage.id; @@ -190,9 +184,6 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On // It's suggested to stop propagation of the event, so the // Cdk background will not catch a click and close the modal (like it does on Windows Chrome/FF). event?.stopPropagation(); - if (!this.id || !this.images) { - throw new Error('Internal library error - id and images must be defined'); - } if (!this.previewConfig || !this.previewConfig.clickable) { return; } @@ -290,8 +281,8 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On * Private method to update the visible previews navigating to the right (next). */ private next(): void { - if (!this.images || !this.previewConfig) { - throw new Error('Internal library error - images must be defined'); + if (!this.previewConfig) { + throw new Error('Internal library error - previewConfig must be defined'); } if(this.end >= this.images.length) { // check if nextImage should be blocked @@ -312,8 +303,8 @@ export class PreviewsComponent extends AccessibleComponent implements OnInit, On * Private method to update the visible previews navigating to the left (previous). */ private previous(): void { - if (!this.images || !this.previewConfig) { - throw new Error('Internal library error - images must be defined'); + if (!this.previewConfig) { + throw new Error('Internal library error - previewConfig must be defined'); } if(this.start <= 0) { // check if prevImage should be blocked diff --git a/projects/ks89/angular-modal-gallery/src/lib/components/upper-buttons/upper-buttons.component.ts b/projects/ks89/angular-modal-gallery/src/lib/components/upper-buttons/upper-buttons.component.ts index 493c40ce..9918eb99 100644 --- a/projects/ks89/angular-modal-gallery/src/lib/components/upper-buttons/upper-buttons.component.ts +++ b/projects/ks89/angular-modal-gallery/src/lib/components/upper-buttons/upper-buttons.component.ts @@ -65,12 +65,12 @@ export class UpperButtonsComponent extends AccessibleComponent implements OnInit * the service to call modal gallery. */ @Input() - id: number | undefined; + id!: number; /** * Object of type `Image` that represent the visible image. */ @Input() - currentImage: Image | undefined; + currentImage!: Image; /** * Output to emit clicks on refresh button. The payload contains a `ButtonEvent`. @@ -151,9 +151,6 @@ export class UpperButtonsComponent extends AccessibleComponent implements OnInit * In particular, it's called only one time!!! */ ngOnInit(): void { - if (this.id === null || this.id === undefined) { - throw new Error('Internal library error - id must be defined'); - } const libConfig: LibConfig | undefined = this.configService.getConfig(this.id); if (!libConfig || !libConfig.buttonsConfig) { throw new Error('Internal library error - libConfig and buttonsConfig must be defined'); @@ -188,9 +185,6 @@ export class UpperButtonsComponent extends AccessibleComponent implements OnInit * @throws an error if the button type is unknown */ onEvent(button: InternalButtonConfig, event: KeyboardEvent | MouseEvent, action: Action = Action.CLICK): void { - if (this.id === null || this.id === undefined) { - throw new Error('Internal library error - id must be defined'); - } if (!event) { return; }