Reduce use of explicit any type (#274723) (#276686)

* Reduce use of explicit `any` type (#274723)

* fix ci
This commit is contained in:
Benjamin Pasero
2025-11-11 11:30:16 +01:00
committed by GitHub
parent 5e8de6eb2c
commit ad3ca06ea4
24 changed files with 72 additions and 74 deletions

View File

@@ -7,6 +7,14 @@ import { getWindowId, onDidUnregisterWindow } from './dom.js';
import { Emitter, Event } from '../common/event.js';
import { Disposable, markAsSingleton } from '../common/lifecycle.js';
type BackingStoreContext = CanvasRenderingContext2D & {
webkitBackingStorePixelRatio?: number;
mozBackingStorePixelRatio?: number;
msBackingStorePixelRatio?: number;
oBackingStorePixelRatio?: number;
backingStorePixelRatio?: number;
};
/**
* See https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio#monitoring_screen_resolution_or_zoom_level_changes
*/
@@ -67,13 +75,13 @@ class PixelRatioMonitorImpl extends Disposable implements IPixelRatioMonitor {
}
private _getPixelRatio(targetWindow: Window): number {
const ctx: any = document.createElement('canvas').getContext('2d');
const ctx = document.createElement('canvas').getContext('2d') as BackingStoreContext | null;
const dpr = targetWindow.devicePixelRatio || 1;
const bsr = ctx.webkitBackingStorePixelRatio ||
ctx.mozBackingStorePixelRatio ||
ctx.msBackingStorePixelRatio ||
ctx.oBackingStorePixelRatio ||
ctx.backingStorePixelRatio || 1;
const bsr = ctx?.webkitBackingStorePixelRatio ||
ctx?.mozBackingStorePixelRatio ||
ctx?.msBackingStorePixelRatio ||
ctx?.oBackingStorePixelRatio ||
ctx?.backingStorePixelRatio || 1;
return dpr / bsr;
}
}