Skip to content

Commit

Permalink
Fix #1536 better compatibility with strictNullChecks TS option
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Jan 16, 2025
1 parent 310aaa4 commit 698bcec
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/autorotate-plugin/src/AutorotatePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class AutorotatePlugin extends AbstractConfigurablePlugin<
* Changes the keypoints
* @throws {@link PSVError} if the configuration is invalid
*/
setKeypoints(keypoints: AutorotateKeypoint[]) {
setKeypoints(keypoints: AutorotateKeypoint[] | null) {
if (!keypoints) {
this.keypoints = null;
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-plugin/src/CompassPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class CompassPlugin extends AbstractConfigurablePlugin<
/**
* Changes the hotspots on the compass
*/
setHotspots(hotspots: CompassHotspot[]) {
setHotspots(hotspots: CompassHotspot[] | null) {
this.config.hotspots = hotspots;
this.component.update();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export class Viewer extends TypedEventTarget<ViewerEvents> {
this.state.loadingPromise = null;

if (err) {
this.navbar.setCaption('');
this.navbar.setCaption(null);
this.showError(this.config.lang.loadError);
console.error(err);
this.dispatchEvent(new PanoramaErrorEvent(path, err));
Expand Down Expand Up @@ -758,7 +758,7 @@ export class Viewer extends TypedEventTarget<ViewerEvents> {
/**
* Changes the global mouse cursor
*/
setCursor(cursor: string) {
setCursor(cursor: string | null) {
this.state.cursorOverride = cursor;
if (!cursor) {
this.container.style.cursor = this.config.mousemove ? 'move' : 'default';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/Navbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class Navbar extends AbstractComponent {
/**
* Changes the navbar caption
*/
setCaption(html: string) {
setCaption(html: string | null) {
this.children.some((item) => {
if (item instanceof NavbarCaption) {
item.setCaption(html);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/NavbarCaption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class NavbarCaption extends AbstractButton {
/**
* Changes the caption
*/
setCaption(html: string) {
setCaption(html: string | null) {
this.show();
this.contentElt.innerHTML = html ?? '';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/services/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class Renderer extends AbstractService {
/**
* Resets or replaces the THREE renderer by a custom one
*/
setCustomRenderer(factory: (renderer: WebGLRenderer) => CustomRenderer) {
setCustomRenderer(factory: ((renderer: WebGLRenderer) => CustomRenderer) | null) {
if (factory) {
this.customRenderer = factory(this.renderer);
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/gallery-plugin/src/GalleryPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class GalleryPlugin extends AbstractConfigurablePlugin<
* @param [handler] function that will be called when an item is clicked instead of the default behavior
* @throws {@link PSVError} if the configuration is invalid
*/
setItems(items: GalleryItem[], handler?: (id: GalleryItem['id']) => void) {
setItems(items: GalleryItem[] | null, handler?: (id: GalleryItem['id']) => void) {
if (!items) {
items = [];
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/map-plugin/src/MapPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class MapPlugin extends AbstractConfigurablePlugin<
/**
* Changes the hotspots on the map
*/
setHotspots(hotspots: MapHotspot[], render = true) {
setHotspots(hotspots: MapHotspot[] | null, render = true) {
const ids: string[] = [];
let i = 1;

Expand Down Expand Up @@ -276,7 +276,7 @@ export class MapPlugin extends AbstractConfigurablePlugin<
/**
* Changes the highlighted hotspot
*/
setActiveHotspot(hotspotId: string) {
setActiveHotspot(hotspotId: string | null) {
this.component.setActiveHotspot(hotspotId);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/markers-plugin/src/MarkersPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export class MarkersPlugin extends AbstractConfigurablePlugin<
/**
* Replaces all markers
*/
setMarkers(markers: MarkerConfig[], render = true) {
setMarkers(markers: MarkerConfig[] | null, render = true) {
this.clearMarkers(false);

markers?.forEach((marker) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/plan-plugin/src/PlanPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class PlanPlugin extends AbstractConfigurablePlugin<
/**
* Changes the hotspots on the map
*/
setHotspots(hotspots: PlanHotspot[]) {
setHotspots(hotspots: PlanHotspot[] | null) {
const ids: string[] = [];
let i = 1;

Expand Down Expand Up @@ -250,7 +250,7 @@ export class PlanPlugin extends AbstractConfigurablePlugin<
/**
* Changes the highlighted hotspot
*/
setActiveHotspot(hotspotId: string) {
setActiveHotspot(hotspotId: string | null) {
this.component.setActiveHotspot(hotspotId);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/resolution-plugin/src/ResolutionPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class ResolutionPlugin extends AbstractPlugin<ResolutionPluginEvents> {
* @throws {@link PSVError} if the configuration is invalid
*/
setResolutions(resolutions: Resolution[], defaultResolution?: string) {
this.resolutions = resolutions || [];
this.resolutions = resolutions;
this.resolutionsById = {};

resolutions.forEach((resolution) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/video-plugin/src/VideoPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export class VideoPlugin extends AbstractConfigurablePlugin<
* Changes the keypoints
* @throws {@link PSVError} if the configuration is invalid
*/
setKeypoints(keypoints?: VideoKeypoint[]) {
setKeypoints(keypoints?: VideoKeypoint[] | null) {
if (!this.autorotate) {
throw new PSVError('Video keypoints required the AutorotatePlugin');
}
Expand Down
4 changes: 2 additions & 2 deletions packages/visible-range-plugin/src/VisibleRangePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class VisibleRangePlugin extends AbstractConfigurablePlugin<
/**
* Changes the vertical range
*/
setVerticalRange(range?: Range) {
setVerticalRange(range: Range | null) {
// range must have two values
if (range && range.length !== 2) {
utils.logWarn('vertical range must have exactly two elements');
Expand All @@ -154,7 +154,7 @@ export class VisibleRangePlugin extends AbstractConfigurablePlugin<
/**
* Changes the horizontal range
*/
setHorizontalRange(range?: Range) {
setHorizontalRange(range: Range | null) {
// horizontal range must have two values
if (range && range.length !== 2) {
utils.logWarn('horizontal range must have exactly two elements');
Expand Down

0 comments on commit 698bcec

Please sign in to comment.