Sfoglia il codice sorgente

Fix MonacoEnvironment types

Some attempts were made in the past to fix it, but they don’t actually
work, as they don’t override the global Window interface.

Fixes #2958
Remco Haszing 3 anni fa
parent
commit
d1b144b37b
1 ha cambiato i file con 10 aggiunte e 1 eliminazioni
  1. 10 1
      build/release.ts

+ 10 - 1
build/release.ts

@@ -364,7 +364,16 @@ function toExternalDTS(contents: string): string {
 		}
 
 		if (line.indexOf('declare let MonacoEnvironment') === 0) {
-			lines[i] = `declare global {\n    let MonacoEnvironment: Environment | undefined;\n}`;
+			lines[i] = [
+				'declare global {',
+				'    let MonacoEnvironment: Environment | undefined;',
+				'',
+				'    interface Window {',
+				'        MonacoEnvironment?: Environment | undefined;',
+				'    }',
+				'}',
+				''
+			].join('\n');
 		}
 		if (line.indexOf('    MonacoEnvironment?') === 0) {
 			lines[i] = `    MonacoEnvironment?: Environment | undefined;`;