33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6+ //@ts -check
7+ 'use strict' ;
8+
69const bootstrap = require ( './bootstrap' ) ;
710
811exports . parseURLQueryArgs = function ( ) {
@@ -15,17 +18,30 @@ exports.parseURLQueryArgs = function () {
1518 . reduce ( function ( r , param ) { r [ param [ 0 ] ] = decodeURIComponent ( param [ 1 ] ) ; return r ; } , { } ) ;
1619} ;
1720
18- exports . assign = function ( destination , source ) {
21+ /**
22+ * @param {object } destination
23+ * @param {object } source
24+ * @returns {object }
25+ */
26+ exports . assign = function assign ( destination , source ) {
1927 return Object . keys ( source ) . reduce ( function ( r , key ) { r [ key ] = source [ key ] ; return r ; } , destination ) ;
2028} ;
2129
30+ /**
31+ *
32+ * @param {string[] } modulePaths
33+ * @param {(result, configuration) => any } resultCallback
34+ * @param {{ removeDeveloperKeybindingsAfterLoad: boolean, canModifyDOM: (config) => void, beforeLoaderConfig: (config, loaderConfig) => void, beforeRequire: () => void }= } options
35+ */
2236exports . load = function ( modulePaths , resultCallback , options ) {
37+ // @ts -ignore
2338 const webFrame = require ( 'electron' ) . webFrame ;
2439
2540 const args = exports . parseURLQueryArgs ( ) ;
2641 const configuration = JSON . parse ( args [ 'config' ] || '{}' ) || { } ;
2742
2843 // Error handler
44+ // @ts -ignore
2945 process . on ( 'uncaughtException' , function ( error ) { onUnexpectedError ( error , enableDeveloperTools ) ; } ) ;
3046
3147 // Developer tools
@@ -70,13 +86,13 @@ exports.load = function (modulePaths, resultCallback, options) {
7086 const amdDefine = amdLoader . require . define ;
7187 const nodeRequire = amdLoader . require . nodeRequire ;
7288
73- window . nodeRequire = nodeRequire ;
74- window . require = amdRequire ;
89+ window [ ' nodeRequire' ] = nodeRequire ;
90+ window [ ' require' ] = amdRequire ;
7591
7692 // replace the patched electron fs with the original node fs for all AMD code
7793 amdDefine ( 'fs' , [ 'original-fs' ] , function ( originalFS ) { return originalFS ; } ) ;
7894
79- window . MonacoEnvironment = { } ;
95+ window [ ' MonacoEnvironment' ] = { } ;
8096
8197 const loaderConfig = {
8298 baseUrl : bootstrap . uriFromPath ( configuration . appRoot ) + '/out' ,
@@ -119,7 +135,11 @@ exports.load = function (modulePaths, resultCallback, options) {
119135 } ) ;
120136} ;
121137
138+ /**
139+ * @returns () => void
140+ */
122141function registerDeveloperKeybindings ( ) {
142+ // @ts -ignore
123143 const ipc = require ( 'electron' ) . ipcRenderer ;
124144
125145 const extractKey = function ( e ) {
@@ -156,6 +176,7 @@ function registerDeveloperKeybindings() {
156176}
157177
158178function onUnexpectedError ( error , enableDeveloperTools ) {
179+ // @ts -ignore
159180 const ipc = require ( 'electron' ) . ipcRenderer ;
160181
161182 if ( enableDeveloperTools ) {
0 commit comments