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
This commit is contained in:
Remco Haszing 2022-06-09 14:08:39 +02:00
parent a5298e13bb
commit d1b144b37b
No known key found for this signature in database
GPG key ID: 40D9F5FE9155FD3C

View file

@ -364,7 +364,16 @@ function toExternalDTS(contents: string): string {
} }
if (line.indexOf('declare let MonacoEnvironment') === 0) { 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) { if (line.indexOf(' MonacoEnvironment?') === 0) {
lines[i] = ` MonacoEnvironment?: Environment | undefined;`; lines[i] = ` MonacoEnvironment?: Environment | undefined;`;