Change PixelsPerInch to a class with static properties (issue 14579)
				
					
				
			*Please note:* I'm completely fine with this patch being rejected, and the issue instead closed as WONTFIX, since this is unfortunately a case where the TypeScript definitions dictate how we can/cannot write JavaScript code.
Apparently the TypeScript definitions generation converts the existing `PixelsPerInch` code into a `namespace` and simply ignores the getter; please see a7fc0d33a1/types/src/display/display_utils.d.ts (L223-L226)
Initially I tried tagging `PixelsPerInch` as en `@enum`, see https://jsdoc.app/tags-enum.html, however that unfortunately didn't help.
Hence the only good/simple solution, as far as I'm concerned, is to convert `PixelsPerInch` into a class with `static` properties. This patch results in the following diff, for the `gulp types` build target:
```diff
@@ -195,9 +195,10 @@
      */
     static toDateObject(input: string): Date | null;
 }
-export namespace PixelsPerInch {
-    const CSS: number;
-    const PDF: number;
+export class PixelsPerInch {
+    static CSS: number;
+    static PDF: number;
+    static PDF_TO_CSS_UNITS: number;
 }
 declare const RenderingCancelledException_base: any;
 export class RenderingCancelledException extends RenderingCancelledException_base {
```
			
			
This commit is contained in:
		
							parent
							
								
									530af48b8e
								
							
						
					
					
						commit
						05efe3017b
					
				@ -22,7 +22,6 @@ import {
 | 
				
			|||||||
import {
 | 
					import {
 | 
				
			||||||
  BaseException,
 | 
					  BaseException,
 | 
				
			||||||
  isString,
 | 
					  isString,
 | 
				
			||||||
  shadow,
 | 
					 | 
				
			||||||
  stringToBytes,
 | 
					  stringToBytes,
 | 
				
			||||||
  Util,
 | 
					  Util,
 | 
				
			||||||
  warn,
 | 
					  warn,
 | 
				
			||||||
@ -30,15 +29,13 @@ import {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const SVG_NS = "http://www.w3.org/2000/svg";
 | 
					const SVG_NS = "http://www.w3.org/2000/svg";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const PixelsPerInch = {
 | 
					class PixelsPerInch {
 | 
				
			||||||
  CSS: 96.0,
 | 
					  static CSS = 96.0;
 | 
				
			||||||
  PDF: 72.0,
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /** @type {number} */
 | 
					  static PDF = 72.0;
 | 
				
			||||||
  get PDF_TO_CSS_UNITS() {
 | 
					
 | 
				
			||||||
    return shadow(this, "PDF_TO_CSS_UNITS", this.CSS / this.PDF);
 | 
					  static PDF_TO_CSS_UNITS = this.CSS / this.PDF;
 | 
				
			||||||
  },
 | 
					}
 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DOMCanvasFactory extends BaseCanvasFactory {
 | 
					class DOMCanvasFactory extends BaseCanvasFactory {
 | 
				
			||||||
  constructor({ ownerDocument = globalThis.document } = {}) {
 | 
					  constructor({ ownerDocument = globalThis.document } = {}) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user